|
1 | | -import { nowInSeconds, sleep } from "@happychain/common" |
| 1 | +import { sleep } from "@happychain/common" |
2 | 2 | import { TransactionManager, TransactionStatus, TxmHookType } from "@happychain/transaction-manager" |
3 | 3 | import type { LatestBlock, Transaction } from "@happychain/transaction-manager" |
4 | 4 | import { abis } from "./ABI/random.js" |
@@ -60,11 +60,7 @@ class RandomnessService { |
60 | 60 | const now = Date.now() |
61 | 61 | const nextDrandBeaconTimestamp = |
62 | 62 | Math.ceil((now - drandGenesisTimestampMs) / periodMs) * periodMs + drandGenesisTimestampMs |
63 | | - console.log("nextDrandBeaconTimestamp", nextDrandBeaconTimestamp) |
64 | | - console.log("now", now) |
65 | 63 | await sleep(nextDrandBeaconTimestamp - now) |
66 | | - console.log("Awaked on", Date.now()) |
67 | | - |
68 | 64 | setInterval(async () => { |
69 | 65 | await this.handleNewDrandBeacons() |
70 | 66 | }, Number(env.EVM_DRAND_PERIOD_SECONDS) * 1000) |
@@ -145,34 +141,16 @@ class RandomnessService { |
145 | 141 |
|
146 | 142 | private async handleNewDrandBeacons() { |
147 | 143 | const currentRound = this.drandService.currentRound() |
148 | | - const latestDrandBeacon = await this.drandService.getLatestDrandBeacon() |
149 | | - |
150 | | - if (latestDrandBeacon.isErr()) { |
151 | | - return |
152 | | - } |
153 | | - |
154 | | - console.log("currentRound", currentRound) |
155 | | - console.log("Now in seconds", nowInSeconds()) |
156 | | - console.log("latestDrandBeacon", latestDrandBeacon.value.round) |
157 | | - console.log( |
158 | | - "LATEST BEACON EXPECTED TIMESTAMP", |
159 | | - (latestDrandBeacon.value.round - 1) * Number(env.EVM_DRAND_PERIOD_SECONDS) + |
160 | | - Number(env.EVM_DRAND_GENESIS_TIMESTAMP_SECONDS), |
161 | | - ) |
162 | 144 |
|
163 | 145 | const oldestDrand = this.drandRepository.getOldestDrandRound() ?? env.EVM_DRAND_START_ROUND |
164 | 146 |
|
165 | 147 | const drandGaps = this.drandRepository.findRoundGapsInRange(oldestDrand, currentRound) |
166 | 148 |
|
167 | | - console.log("drandGaps", drandGaps) |
168 | | - |
169 | 149 | await Promise.all( |
170 | 150 | drandGaps.map(async (round) => { |
171 | 151 | let drandBeacon = await this.drandService.getDrandBeacon(round) |
172 | | - console.log("returned beacon", drandBeacon) |
173 | 152 | if (drandBeacon.isErr()) { |
174 | 153 | if (drandBeacon.error === DrandError.TooEarly) { |
175 | | - console.log("Too early, waiting 1 second") |
176 | 154 | await sleep(1000) |
177 | 155 | drandBeacon = await this.drandService.getDrandBeacon(round) |
178 | 156 |
|
|
0 commit comments