Skip to content

Commit

Permalink
rename var and document
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfirefist committed Feb 23, 2024
1 parent a461431 commit c4f5d4c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
8 changes: 5 additions & 3 deletions fortuna/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ pub struct BlockchainState {
/// The server will wait for this many block confirmations of a request before revealing
/// the random number.
pub reveal_delay_blocks: u64,
pub recent_block_status: BlockNumber,
/// The BlockNumber of the block that includes the random number request.
/// For eg., Finalized, Safe
pub request_block_status: BlockNumber,
}

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

let avax_read = Arc::new(MockEntropyReader::with_requests(10, &[]));
Expand All @@ -253,7 +255,7 @@ mod test {
contract: avax_read.clone(),
provider_address: PROVIDER,
reveal_delay_blocks: 2,
recent_block_status: BlockStatus::Latest,
request_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.recent_block_status);
let current_block_number_fut = state.contract.get_block_number(state.request_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, recent_block_status: BlockNumber) -> Result<u64> {
async fn get_block_number(&self, request_block_status: BlockNumber) -> Result<u64> {
let block = self
.client()
.get_block(recent_block_status)
.get_block(request_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, recent_block_status: BlockNumber) -> Result<u64>;
async fn get_block_number(&self, request_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,
recent_block_status: chain_config.block_status,
request_block_status: chain_config.request_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 @@ -138,7 +138,8 @@ pub struct EthereumConfig {
#[serde(default)]
pub legacy_tx: bool,

/// Use the legacy transaction format (for networks without EIP 1559)
/// The BlockNumber of the block that includes the random number request.
/// For eg., Finalized, Safe
#[serde(default)]
pub block_status: BlockNumber,
pub request_block_status: BlockNumber,
}

0 comments on commit c4f5d4c

Please sign in to comment.