Skip to content

Commit

Permalink
rename var
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfirefist committed Feb 23, 2024
1 parent c4f5d4c commit 579bfab
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions fortuna/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub struct BlockchainState {
pub reveal_delay_blocks: u64,
/// The BlockNumber of the block that includes the random number request.
/// For eg., Finalized, Safe
pub request_block_status: BlockNumber,
pub confirmed_block_status: BlockNumber,
}

pub struct Metrics {
Expand Down Expand Up @@ -245,7 +245,7 @@ mod test {
contract: eth_read.clone(),
provider_address: PROVIDER,
reveal_delay_blocks: 1,
request_block_status: BlockStatus::Latest,
confirmed_block_status: BlockStatus::Latest,
};

let avax_read = Arc::new(MockEntropyReader::with_requests(10, &[]));
Expand All @@ -255,7 +255,7 @@ mod test {
contract: avax_read.clone(),
provider_address: PROVIDER,
reveal_delay_blocks: 2,
request_block_status: BlockStatus::Latest,
confirmed_block_status: BlockStatus::Latest,
};

let api_state = ApiState::new(&[
Expand Down
2 changes: 1 addition & 1 deletion fortuna/src/api/revelation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub async fn revelation(

let maybe_request_fut = state.contract.get_request(state.provider_address, sequence);

let current_block_number_fut = state.contract.get_block_number(state.request_block_status);
let current_block_number_fut = state.contract.get_block_number(state.confirmed_block_status);

let (maybe_request, current_block_number) =
try_join!(maybe_request_fut, current_block_number_fut).map_err(|e| {
Expand Down
4 changes: 2 additions & 2 deletions fortuna/src/chain/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ impl EntropyReader for PythContract {
}
}

async fn get_block_number(&self, request_block_status: BlockNumber) -> Result<u64> {
async fn get_block_number(&self, confirmed_block_status: BlockNumber) -> Result<u64> {
let block = self
.client()
.get_block(request_block_status)
.get_block(confirmed_block_status)
.await?
.ok_or_else(|| Error::msg("pending block confirmation"))?;

Expand Down
2 changes: 1 addition & 1 deletion fortuna/src/chain/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub trait EntropyReader: Send + Sync {
async fn get_request(&self, provider: Address, sequence_number: u64)
-> Result<Option<Request>>;

async fn get_block_number(&self, request_block_status: BlockNumber) -> Result<u64>;
async fn get_block_number(&self, confirmed_block_status: BlockNumber) -> Result<u64>;
}

/// An in-flight request stored in the contract.
Expand Down
2 changes: 1 addition & 1 deletion fortuna/src/command/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub async fn run(opts: &RunOptions) -> Result<()> {
contract,
provider_address: opts.provider,
reveal_delay_blocks: chain_config.reveal_delay_blocks,
request_block_status: chain_config.request_block_status,
confirmed_block_status: chain_config.confirmed_block_status,
};

chains.insert(chain_id.clone(), state);
Expand Down
5 changes: 3 additions & 2 deletions fortuna/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,15 @@ pub struct EthereumConfig {
pub contract_addr: Address,

/// How many blocks to wait before revealing the random number.
#[serde(default=0)]
pub reveal_delay_blocks: u64,

/// Use the legacy transaction format (for networks without EIP 1559)
#[serde(default)]
pub legacy_tx: bool,

/// The BlockNumber of the block that includes the random number request.
/// The BlockNumber of the block that is considered confirmed.
/// For eg., Finalized, Safe
#[serde(default)]
pub request_block_status: BlockNumber,
pub confirmed_block_status: BlockNumber,
}

0 comments on commit 579bfab

Please sign in to comment.