Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to remove setInterval #1119

Draft
wants to merge 1 commit into
base: beta
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions agent/bls.js
Original file line number Diff line number Diff line change
Expand Up @@ -1071,12 +1071,10 @@ async function do_sign_messages_impl(
details.write( strLogPrefix + cc.debug( "Waiting for BLS glue result " ) + "\n" );
let errGathering = null;
const promise_gathering_complete = new Promise( ( resolve, reject ) => {
const iv = setInterval( async function() {
++ joGatheringTracker.nWaitIntervalStepsDone;
++joGatheringTracker.nWaitIntervalStepsDone;
cntSuccess = joGatheringTracker.nCountReceived - joGatheringTracker.nCountErrors;
if( cntSuccess >= nCountOfBlsPartsToCollect ) {
while ( cntSuccess >= nCountOfBlsPartsToCollect ) {
const strLogPrefixB = cc.bright( strDirection ) + cc.debug( "/" ) + cc.info( "BLS" ) + cc.debug( "/" ) + cc.sunny( "Summary" ) + cc.debug( ":" ) + " ";
clearInterval( iv );
let strError = null, strSuccessfulResultDescription = null;
const joGlueResult = perform_bls_glue(
details,
Expand Down Expand Up @@ -1129,7 +1127,6 @@ async function do_sign_messages_impl(
return;
}
if( joGatheringTracker.nCountReceived >= jarrNodes.length ) {
clearInterval( iv );
await fn( "signature error(2), got " + joGatheringTracker.nCountErrors + " errors(s) for " + jarrNodes.length + " node(s)", jarrMessages, null ).catch( ( err ) => {
const strErrorMessage =
cc.error( "Problem(3) in BLS sign result handler, not enough successful BLS signature parts(" ) +
Expand All @@ -1146,7 +1143,6 @@ async function do_sign_messages_impl(
return;
}
if( joGatheringTracker.nWaitIntervalStepsDone >= joGatheringTracker.nWaitIntervalMaxSteps ) {
clearInterval( iv );
await fn( "signature error(3), got " + joGatheringTracker.nCountErrors + " errors(s) for " + jarrNodes.length + " node(s)", jarrMessages, null ).catch( ( err ) => {
const strErrorMessage =
cc.error( "Problem(4) in BLS sign result handler, not enough successful BLS signature parts(" ) +
Expand All @@ -1162,8 +1158,7 @@ async function do_sign_messages_impl(
bHaveResultReportCalled = true;
return;
}
}, joGatheringTracker.nWaitIntervalStepMilliseconds );
} );
});
log.write( cc.debug( "Will await for message BLS verification and sending..." ) + "\n" );
details.write( cc.debug( "Will await for message BLS verification and sending..." ) + "\n" );
await with_timeout( "BLS verification and sending", promise_gathering_complete, g_secondsMessageVerifySendTimeout ).then( strSuccessfulResultDescription => {
Expand Down