@@ -242,7 +242,6 @@ var DashGov = ("object" === typeof module && exports) || {};
242
242
secondsPerBlock = 0 ,
243
243
cycles = 3 ,
244
244
) {
245
- console . log ( "CURRENT HEIGHT:" , currentBlock ) ;
246
245
if ( ! currentBlock ) {
247
246
let d = new Date ( MONTHLY_SUPERBLOCK_61_DATE ) ;
248
247
let then = d . valueOf ( ) ;
@@ -269,7 +268,6 @@ var DashGov = ("object" === typeof module && exports) || {};
269
268
/** @type {Array<Estimate> } */
270
269
let estimates = [ ] ;
271
270
for ( let i = - 1 ; i < cycles ; i += 1 ) {
272
- console . log ( "HEIGHT:" , currentBlock ) ;
273
271
let estimate = GObj . estimateNthGovCycle (
274
272
{ block : currentBlock , ms : now } ,
275
273
secondsPerBlock ,
@@ -298,15 +296,14 @@ var DashGov = ("object" === typeof module && exports) || {};
298
296
299
297
/**
300
298
* @param {Uint53 } height
299
+ * @param {Uint53 } offset - 0 (current / previous), 1 (next), 2, 3, nth
301
300
* @returns {Uint53 } - the superblock after the given height
302
301
*/
303
- GObj . getNextSuperblock = function ( height ) {
304
- let isSuperblock = height % SUPERBLOCK_INTERVAL === 0 ;
305
- if ( isSuperblock ) {
306
- height += SUPERBLOCK_INTERVAL ;
307
- }
302
+ GObj . getNthNextSuperblock = function ( height , offset ) {
308
303
let superblockCount = height / SUPERBLOCK_INTERVAL ;
309
- superblockCount = Math . ceil ( superblockCount ) ;
304
+ superblockCount = Math . floor ( superblockCount ) ;
305
+
306
+ superblockCount += offset ;
310
307
let superblockHeight = superblockCount * SUPERBLOCK_INTERVAL ;
311
308
312
309
return superblockHeight ;
@@ -325,7 +322,7 @@ var DashGov = ("object" === typeof module && exports) || {};
325
322
) {
326
323
let blockOffset = offset * SUPERBLOCK_INTERVAL ;
327
324
let blockTarget = block + blockOffset ;
328
- let superblockHeight = GObj . getNextSuperblock ( blockTarget ) ;
325
+ let superblockHeight = GObj . getNthNextSuperblock ( blockTarget , offset ) ;
329
326
330
327
let superblockDelta = superblockHeight - block ;
331
328
// let superblockDeltaMs = superblockDelta * SECONDS_PER_BLOCK_ESTIMATE * 1000;
0 commit comments