-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathaccount.rs
56 lines (51 loc) · 1.87 KB
/
account.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use alloy_primitives::{Address, BlockNumber};
use auto_impl::auto_impl;
use reth_db_models::AccountBeforeTx;
use reth_primitives_traits::Account;
use reth_storage_errors::provider::ProviderResult;
use std::{
collections::{BTreeMap, BTreeSet},
ops::{RangeBounds, RangeInclusive},
};
/// Account reader
#[auto_impl(&, Arc, Box)]
pub trait AccountReader: Send + Sync {
/// Get basic account information.
///
/// Returns `None` if the account doesn't exist.
fn basic_account(&self, address: Address) -> ProviderResult<Option<Account>>;
}
/// Account reader
#[auto_impl(&, Arc, Box)]
pub trait AccountExtReader: Send + Sync {
/// Iterate over account changesets and return all account address that were changed.
fn changed_accounts_with_range(
&self,
_range: impl RangeBounds<BlockNumber>,
) -> ProviderResult<BTreeSet<Address>>;
/// Get basic account information for multiple accounts. A more efficient version than calling
/// [`AccountReader::basic_account`] repeatedly.
///
/// Returns `None` if the account doesn't exist.
fn basic_accounts(
&self,
_iter: impl IntoIterator<Item = Address>,
) -> ProviderResult<Vec<(Address, Option<Account>)>>;
/// Iterate over account changesets and return all account addresses that were changed alongside
/// each specific set of blocks.
///
/// NOTE: Get inclusive range of blocks.
fn changed_accounts_and_blocks_with_range(
&self,
range: RangeInclusive<BlockNumber>,
) -> ProviderResult<BTreeMap<Address, Vec<BlockNumber>>>;
}
/// AccountChange reader
#[auto_impl(&, Arc, Box)]
pub trait ChangeSetReader: Send + Sync {
/// Iterate over account changesets and return the account state from before this block.
fn account_block_changeset(
&self,
block_number: BlockNumber,
) -> ProviderResult<Vec<AccountBeforeTx>>;
}