mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-18 02:07:43 +00:00
Merge remote-tracking branch 'fyookball/fusion' into fusion
This commit is contained in:
commit
59379faa4c
2 changed files with 27 additions and 17 deletions
|
@ -198,8 +198,9 @@ class Connection {
|
|||
return recvBuf;
|
||||
}
|
||||
|
||||
Future<List<int>> recv_message2(SocketWrapper socketwrapper,
|
||||
{Duration? timeout}) async {
|
||||
|
||||
Future<List<int>> recv_message2(SocketWrapper socketwrapper, {Duration? timeout}) async {
|
||||
print ("START OF RECV2");
|
||||
if (timeout == null) {
|
||||
timeout = this.timeout;
|
||||
}
|
||||
|
@ -247,8 +248,8 @@ class Connection {
|
|||
'Got a frame with msg_length=$messageLength > $MAX_MSG_LENGTH (max)');
|
||||
}
|
||||
|
||||
print(
|
||||
"DEBUG recv_message2 3 - about to read the message body, messageLength: $messageLength");
|
||||
/*
|
||||
print("DEBUG recv_message2 3 - about to read the message body, messageLength: $messageLength");
|
||||
|
||||
print("DEBUG recvfbuf len is ");
|
||||
print(recvBuf.length);
|
||||
|
@ -256,13 +257,14 @@ class Connection {
|
|||
print(bytesRead);
|
||||
print("message length is ");
|
||||
print(messageLength);
|
||||
|
||||
*/
|
||||
if (recvBuf.length == bytesRead && bytesRead == 12 + messageLength) {
|
||||
final message = recvBuf.sublist(12, 12 + messageLength);
|
||||
|
||||
print(
|
||||
"DEBUG recv_message2 4 - message received, length: ${message.length}");
|
||||
print("DEBUG recv_message2 5 - message content: $message");
|
||||
|
||||
//print("DEBUG recv_message2 4 - message received, length: ${message.length}");
|
||||
//print("DEBUG recv_message2 5 - message content: $message");
|
||||
print ("END OF RECV2");
|
||||
return message;
|
||||
} else {
|
||||
// Throwing exception if the length doesn't match
|
||||
|
|
|
@ -779,14 +779,14 @@ class Fusion {
|
|||
|
||||
print('Possible tiers: $tierOutputs');
|
||||
|
||||
print("CHECK socketwrapper 839");
|
||||
socketwrapper.status();
|
||||
safety_sum_in = sumInputsValue;
|
||||
safety_exess_fees = excessFees;
|
||||
return;
|
||||
}
|
||||
|
||||
Future<void> registerAndWait(SocketWrapper socketwrapper) async {
|
||||
|
||||
print ("DEBUG register and wait top.");
|
||||
// msg can be different classes depending on which protobuf msg is sent.
|
||||
dynamic? msg;
|
||||
|
||||
|
@ -826,8 +826,8 @@ class Fusion {
|
|||
};
|
||||
|
||||
while (true) {
|
||||
var msg = await recv2(socketwrapper, ['tierstatusupdate', 'fusionbegin'],
|
||||
timeout: Duration(seconds: 10));
|
||||
print ("RECEIVE LOOP 870............DEBUG");
|
||||
var msg = await recv2(socketwrapper,['tierstatusupdate', 'fusionbegin'], timeout: Duration(seconds: 10));
|
||||
|
||||
var fieldInfoFusionBegin = msg.info_.byName["fusionbegin"];
|
||||
if (fieldInfoFusionBegin != null &&
|
||||
|
@ -865,23 +865,31 @@ class Fusion {
|
|||
int? besttime;
|
||||
int? besttimetier;
|
||||
for (var entry in statuses.entries) {
|
||||
double frac = entry.value.players / entry.value.min_players;
|
||||
double frac = entry.value.players.toInt() / entry.value.minPlayers.toInt();
|
||||
if (frac >= maxfraction) {
|
||||
if (frac > maxfraction) {
|
||||
maxfraction = frac;
|
||||
maxtiers.clear();
|
||||
}
|
||||
maxtiers.add(entry.key);
|
||||
maxtiers.add(entry.key.toInt());
|
||||
}
|
||||
if (entry.value.hasField('time_remaining')) {
|
||||
int tr = entry.value.time_remaining;
|
||||
|
||||
var fieldInfoTimeRemaining = entry.value.info_.byName["timeRemaining"];
|
||||
if (fieldInfoTimeRemaining == null) {
|
||||
throw FusionError('Expected field not found in message: timeRemaining');
|
||||
}
|
||||
|
||||
if (entry.value.hasField(fieldInfoTimeRemaining.tagNumber)) {
|
||||
|
||||
int tr = entry.value.timeRemaining.toInt();
|
||||
if (besttime == null || tr < besttime) {
|
||||
besttime = tr;
|
||||
besttimetier = entry.key;
|
||||
besttimetier = entry.key.toInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var displayBest = <String>[];
|
||||
var displayMid = <String>[];
|
||||
var displayQueued = <String>[];
|
||||
|
|
Loading…
Reference in a new issue