File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { getDecryptionKey } from './helpers/shutter';
5
5
import { hasStrategyOverride , sha256 } from './helpers/utils' ;
6
6
7
7
const scoreAPIUrl = process . env . SCORE_API_URL || 'https://score.snapshot.org' ;
8
+ const FINALIZE_SCORE_SECONDS_DELAY = 60 ;
8
9
9
10
async function getProposal ( id : string ) : Promise < any | undefined > {
10
11
const query = 'SELECT * FROM proposals WHERE id = ? LIMIT 1' ;
@@ -108,8 +109,16 @@ export async function updateProposalAndVotes(proposalId: string, force = false)
108
109
return true ;
109
110
}
110
111
111
- // Ignore score calculation if proposal have more than 100k votes and scores_updated greater than 5 minute
112
112
const ts = Number ( ( Date . now ( ) / 1e3 ) . toFixed ( ) ) ;
113
+
114
+ // Delay computation of final scores, to allow time for last minute votes to finish
115
+ // up to 1 minute after the end of the proposal
116
+ if ( proposal . end <= ts ) {
117
+ const secondsSinceEnd = ts - proposal . end ;
118
+ await snapshot . utils . sleep ( Math . max ( FINALIZE_SCORE_SECONDS_DELAY - secondsSinceEnd , 0 ) * 1000 ) ;
119
+ }
120
+
121
+ // Ignore score calculation if proposal have more than 100k votes and scores_updated greater than 5 minute
113
122
if (
114
123
( proposal . votes > 20000 && proposal . scores_updated > ts - 300 ) ||
115
124
pendingRequests [ proposalId ]
You can’t perform that action at this time.
0 commit comments