File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,14 @@ interface HeartbeatNetwork {
28
28
29
29
const isTestnet = assertEnvironmentVariable ( 'NETWORK' ) === 'TESTNET' ;
30
30
31
+ /**
32
+ * Wormhole Foundation requested an additional buffer to increase the likelihood of success in
33
+ * the event that a guardian is tracking a height but not properly handling requests.
34
+ */
35
+ const QUORUM_BUFFER = 1 ;
36
+
31
37
export function getQuorumCount ( numGuardians : number ) : number {
32
- return isTestnet ? 1 : Math . floor ( ( numGuardians * 2 ) / 3 + 1 ) ;
38
+ return isTestnet ? 1 : Math . floor ( ( numGuardians * 2 ) / 3 + 1 ) + QUORUM_BUFFER ;
33
39
}
34
40
35
41
async function getHeartbeats_ ( ) {
@@ -106,7 +112,10 @@ export async function getQuorumHeight(req: any, res: any) {
106
112
latestHeights . sort ( ( a , b ) => ( a > b ? - 1 : a < b ? 1 : 0 ) ) ;
107
113
safeHeights . sort ( ( a , b ) => ( a > b ? - 1 : a < b ? 1 : 0 ) ) ;
108
114
finalizedHeights . sort ( ( a , b ) => ( a > b ? - 1 : a < b ? 1 : 0 ) ) ;
109
- const quorumIdx = getQuorumCount ( latestHeights . length ) - 1 ;
115
+ const quorumIdx = Math . min (
116
+ getQuorumCount ( latestHeights . length ) - 1 ,
117
+ latestHeights . length - 1
118
+ ) ;
110
119
res . status ( 200 ) . send (
111
120
JSON . stringify ( {
112
121
latest : latestHeights [ quorumIdx ] . toString ( ) ,
You can’t perform that action at this time.
0 commit comments