@@ -51,6 +51,10 @@ class RandomnessService {
5151 console . error ( description )
5252 } )
5353
54+ // Start fetching Drand beacons for past rounds. Subsequently, beacons will be fetched at regular intervals
55+ // to maintain synchronization with the Drand network
56+ this . handleNewDrandBeacons ( )
57+
5458 // Synchronize the retrieval of new Drand beacons with the Drand network to request them as soon as they become available.
5559 const periodMs = Number ( env . EVM_DRAND_PERIOD_SECONDS ) * MS_IN_SECOND
5660 const drandGenesisTimestampMs = Number ( env . EVM_DRAND_GENESIS_TIMESTAMP_SECONDS ) * MS_IN_SECOND
@@ -255,22 +259,19 @@ class RandomnessService {
255259
256260 const randomnessToReveal = this . randomnessRepository . getRandomnessForBlockNumber ( nextBlockNumber )
257261
258- if ( ! randomnessToReveal ) {
259- console . warn ( "Not found randomness to reveal with block number" , nextBlockNumber )
260- return transactions
261- }
262-
263- const revealValueTransaction = this . transactionFactory . createRevealValueTransaction ( randomnessToReveal )
262+ if ( randomnessToReveal ) {
263+ const revealValueTransaction = this . transactionFactory . createRevealValueTransaction ( randomnessToReveal )
264264
265- transactions . unshift ( revealValueTransaction )
265+ transactions . unshift ( revealValueTransaction )
266266
267- randomnessToReveal . addRevealTransactionIntentId ( revealValueTransaction . intentId )
267+ randomnessToReveal . addRevealTransactionIntentId ( revealValueTransaction . intentId )
268268
269- this . randomnessRepository . updateRandomness ( randomnessToReveal ) . then ( ( result ) => {
270- if ( result . isErr ( ) ) {
271- console . error ( "Failed to update randomness" , result . error )
272- }
273- } )
269+ this . randomnessRepository . updateRandomness ( randomnessToReveal ) . then ( ( result ) => {
270+ if ( result . isErr ( ) ) {
271+ console . error ( "Failed to update randomness" , result . error )
272+ }
273+ } )
274+ }
274275
275276 transactions . push ( ...this . pendingPostDrandTransactions )
276277
0 commit comments