clerkb-lumos-integrator
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -9,2 +9,3 @@ import { Cell, CellDep, Hash, Indexer, HexNumber, Script } from "@ckb-lumos/base"; | ||
cellDeps: CellDep[]; | ||
roundStartSubtime: bigint | undefined; | ||
constructor(ckbAddress: string, indexer: Indexer, cellDeps: CellDep[]); | ||
@@ -11,0 +12,0 @@ shouldIssueNewBlock(medianTimeHex: HexNumber, tipCell: Cell): Promise<State>; |
@@ -26,2 +26,3 @@ "use strict"; | ||
this.cellDeps = cellDeps; | ||
this.roundStartSubtime = undefined; | ||
} | ||
@@ -31,14 +32,21 @@ async shouldIssueNewBlock(medianTimeHex, tipCell) { | ||
const medianTime = BigInt(medianTimeHex) / 1000n; | ||
if (medianTime < | ||
poaData.round_initial_subtime + BigInt(poaSetup.subblock_intervals) && | ||
poaData.subblock_index + 1 < poaSetup.subblocks_per_interval) { | ||
return "YesIfFull"; | ||
if (this.roundStartSubtime) { | ||
if (medianTime < | ||
this.roundStartSubtime + BigInt(poaSetup.subblock_intervals) && | ||
poaData.subblock_index + 1 < poaSetup.subblocks_per_interval) { | ||
return "YesIfFull"; | ||
} | ||
} | ||
const steps = (aggregatorIndex + | ||
let steps = (aggregatorIndex + | ||
poaSetup.identities.length - | ||
poaData.aggregator_index) % | ||
poaSetup.identities.length; | ||
if (steps === 0) { | ||
steps = poaSetup.identities.length; | ||
} | ||
const initialTime = this.roundStartSubtime || poaData.round_initial_subtime; | ||
if (medianTime >= | ||
poaData.round_initial_subtime + | ||
initialTime + | ||
BigInt(poaSetup.subblock_intervals) * BigInt(steps)) { | ||
this.roundStartSubtime = medianTime; | ||
return "Yes"; | ||
@@ -45,0 +53,0 @@ } |
{ | ||
"name": "clerkb-lumos-integrator", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Integrator between clerkb and lumos", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -48,2 +48,3 @@ import { Reader } from "ckb-js-toolkit"; | ||
cellDeps: CellDep[]; | ||
roundStartSubtime: bigint | undefined; | ||
@@ -54,2 +55,3 @@ constructor(ckbAddress: string, indexer: Indexer, cellDeps: CellDep[]) { | ||
this.cellDeps = cellDeps; | ||
this.roundStartSubtime = undefined; | ||
} | ||
@@ -65,10 +67,12 @@ | ||
const medianTime = BigInt(medianTimeHex) / 1000n; | ||
if ( | ||
medianTime < | ||
poaData.round_initial_subtime + BigInt(poaSetup.subblock_intervals) && | ||
poaData.subblock_index + 1 < poaSetup.subblocks_per_interval | ||
) { | ||
return "YesIfFull"; | ||
if (this.roundStartSubtime) { | ||
if ( | ||
medianTime < | ||
this.roundStartSubtime + BigInt(poaSetup.subblock_intervals) && | ||
poaData.subblock_index + 1 < poaSetup.subblocks_per_interval | ||
) { | ||
return "YesIfFull"; | ||
} | ||
} | ||
const steps = | ||
let steps = | ||
(aggregatorIndex + | ||
@@ -78,7 +82,11 @@ poaSetup.identities.length - | ||
poaSetup.identities.length; | ||
if (steps === 0) { | ||
steps = poaSetup.identities.length; | ||
} | ||
const initialTime = this.roundStartSubtime || poaData.round_initial_subtime; | ||
if ( | ||
medianTime >= | ||
poaData.round_initial_subtime + | ||
BigInt(poaSetup.subblock_intervals) * BigInt(steps) | ||
initialTime + BigInt(poaSetup.subblock_intervals) * BigInt(steps) | ||
) { | ||
this.roundStartSubtime = medianTime; | ||
return "Yes"; | ||
@@ -85,0 +93,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
57196
880