Skip to content

Commit

Permalink
enha: make how many blocks relayer fetches configurable (#1321)
Browse files Browse the repository at this point in the history
  • Loading branch information
carneiro-cw authored Jul 2, 2024
1 parent 7a55af7 commit 4984bad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ pub struct ExternalRelayerServerConfig {

#[arg(long = "signer", env = "SIGNER")]
pub signer: String,

#[arg(long = "blocks-to-fetch", env = "BLOCKS_TO_FETCH", default_value = "3")]
pub blocks_to_fetch: u64,
}

impl ExternalRelayerServerConfig {
Expand Down
8 changes: 6 additions & 2 deletions src/eth/relayer/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ pub struct ExternalRelayer {
stratus_chain: BlockchainClient,

signer: TxSigner,

blocks_to_fetch: u64,
}

impl ExternalRelayer {
Expand All @@ -148,6 +150,7 @@ impl ExternalRelayer {
stratus_chain: BlockchainClient::new_http(&config.stratus_rpc, config.rpc_timeout).await?,
pool,
signer,
blocks_to_fetch: config.blocks_to_fetch,
})
}

Expand Down Expand Up @@ -265,13 +268,14 @@ impl ExternalRelayer {
FROM relayer_blocks
WHERE finished = false
ORDER BY number ASC
LIMIT 3
LIMIT $1
)
UPDATE relayer_blocks r
SET started = true
FROM cte
WHERE r.number = cte.number
RETURNING r.number, r.payload"#
RETURNING r.number, r.payload"#,
self.blocks_to_fetch as i64
)
.fetch_all(&self.pool)
.await?;
Expand Down

0 comments on commit 4984bad

Please sign in to comment.