mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-24 12:29:37 +00:00
autoformatting
This commit is contained in:
parent
59379faa4c
commit
571fd960b8
2 changed files with 17 additions and 12 deletions
|
@ -53,7 +53,9 @@ class Connection {
|
||||||
static final Uint8List magic =
|
static final Uint8List magic =
|
||||||
Uint8List.fromList([0x76, 0x5b, 0xe8, 0xb4, 0xe4, 0x39, 0x6d, 0xcf]);
|
Uint8List.fromList([0x76, 0x5b, 0xe8, 0xb4, 0xe4, 0x39, 0x6d, 0xcf]);
|
||||||
final Uint8List recvbuf = Uint8List(0);
|
final Uint8List recvbuf = Uint8List(0);
|
||||||
|
|
||||||
Connection({required this.socket, this.timeout = const Duration(seconds: 1)});
|
Connection({required this.socket, this.timeout = const Duration(seconds: 1)});
|
||||||
|
|
||||||
Connection.withoutSocket({this.timeout = const Duration(seconds: 1)});
|
Connection.withoutSocket({this.timeout = const Duration(seconds: 1)});
|
||||||
|
|
||||||
Future<void> sendMessageWithSocketWrapper(
|
Future<void> sendMessageWithSocketWrapper(
|
||||||
|
@ -198,9 +200,9 @@ class Connection {
|
||||||
return recvBuf;
|
return recvBuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<int>> recv_message2(SocketWrapper socketwrapper,
|
||||||
Future<List<int>> recv_message2(SocketWrapper socketwrapper, {Duration? timeout}) async {
|
{Duration? timeout}) async {
|
||||||
print ("START OF RECV2");
|
print("START OF RECV2");
|
||||||
if (timeout == null) {
|
if (timeout == null) {
|
||||||
timeout = this.timeout;
|
timeout = this.timeout;
|
||||||
}
|
}
|
||||||
|
@ -264,7 +266,7 @@ class Connection {
|
||||||
|
|
||||||
//print("DEBUG recv_message2 4 - message received, length: ${message.length}");
|
//print("DEBUG recv_message2 4 - message received, length: ${message.length}");
|
||||||
//print("DEBUG recv_message2 5 - message content: $message");
|
//print("DEBUG recv_message2 5 - message content: $message");
|
||||||
print ("END OF RECV2");
|
print("END OF RECV2");
|
||||||
return message;
|
return message;
|
||||||
} else {
|
} else {
|
||||||
// Throwing exception if the length doesn't match
|
// Throwing exception if the length doesn't match
|
||||||
|
|
|
@ -23,7 +23,9 @@ import 'validation.dart';
|
||||||
|
|
||||||
class FusionError implements Exception {
|
class FusionError implements Exception {
|
||||||
final String message;
|
final String message;
|
||||||
|
|
||||||
FusionError(this.message);
|
FusionError(this.message);
|
||||||
|
|
||||||
String toString() => "FusionError: $message";
|
String toString() => "FusionError: $message";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +217,7 @@ class Fusion {
|
||||||
Fusion() {
|
Fusion() {
|
||||||
//initializeConnection(host, port)
|
//initializeConnection(host, port)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Future<void> initializeConnection(String host, int port) async {
|
Future<void> initializeConnection(String host, int port) async {
|
||||||
Socket socket = await Socket.connect(host, port);
|
Socket socket = await Socket.connect(host, port);
|
||||||
|
@ -785,8 +788,7 @@ class Fusion {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> registerAndWait(SocketWrapper socketwrapper) async {
|
Future<void> registerAndWait(SocketWrapper socketwrapper) async {
|
||||||
|
print("DEBUG register and wait top.");
|
||||||
print ("DEBUG register and wait top.");
|
|
||||||
// msg can be different classes depending on which protobuf msg is sent.
|
// msg can be different classes depending on which protobuf msg is sent.
|
||||||
dynamic? msg;
|
dynamic? msg;
|
||||||
|
|
||||||
|
@ -826,8 +828,9 @@ class Fusion {
|
||||||
};
|
};
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
print ("RECEIVE LOOP 870............DEBUG");
|
print("RECEIVE LOOP 870............DEBUG");
|
||||||
var msg = await recv2(socketwrapper,['tierstatusupdate', 'fusionbegin'], timeout: Duration(seconds: 10));
|
var msg = await recv2(socketwrapper, ['tierstatusupdate', 'fusionbegin'],
|
||||||
|
timeout: Duration(seconds: 10));
|
||||||
|
|
||||||
var fieldInfoFusionBegin = msg.info_.byName["fusionbegin"];
|
var fieldInfoFusionBegin = msg.info_.byName["fusionbegin"];
|
||||||
if (fieldInfoFusionBegin != null &&
|
if (fieldInfoFusionBegin != null &&
|
||||||
|
@ -865,7 +868,8 @@ class Fusion {
|
||||||
int? besttime;
|
int? besttime;
|
||||||
int? besttimetier;
|
int? besttimetier;
|
||||||
for (var entry in statuses.entries) {
|
for (var entry in statuses.entries) {
|
||||||
double frac = entry.value.players.toInt() / entry.value.minPlayers.toInt();
|
double frac =
|
||||||
|
entry.value.players.toInt() / entry.value.minPlayers.toInt();
|
||||||
if (frac >= maxfraction) {
|
if (frac >= maxfraction) {
|
||||||
if (frac > maxfraction) {
|
if (frac > maxfraction) {
|
||||||
maxfraction = frac;
|
maxfraction = frac;
|
||||||
|
@ -876,11 +880,11 @@ class Fusion {
|
||||||
|
|
||||||
var fieldInfoTimeRemaining = entry.value.info_.byName["timeRemaining"];
|
var fieldInfoTimeRemaining = entry.value.info_.byName["timeRemaining"];
|
||||||
if (fieldInfoTimeRemaining == null) {
|
if (fieldInfoTimeRemaining == null) {
|
||||||
throw FusionError('Expected field not found in message: timeRemaining');
|
throw FusionError(
|
||||||
|
'Expected field not found in message: timeRemaining');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.value.hasField(fieldInfoTimeRemaining.tagNumber)) {
|
if (entry.value.hasField(fieldInfoTimeRemaining.tagNumber)) {
|
||||||
|
|
||||||
int tr = entry.value.timeRemaining.toInt();
|
int tr = entry.value.timeRemaining.toInt();
|
||||||
if (besttime == null || tr < besttime) {
|
if (besttime == null || tr < besttime) {
|
||||||
besttime = tr;
|
besttime = tr;
|
||||||
|
@ -889,7 +893,6 @@ class Fusion {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var displayBest = <String>[];
|
var displayBest = <String>[];
|
||||||
var displayMid = <String>[];
|
var displayMid = <String>[];
|
||||||
var displayQueued = <String>[];
|
var displayQueued = <String>[];
|
||||||
|
|
Loading…
Reference in a new issue