pub(crate) trait RewardMerkleTreeDataSource:
Send
+ Sync
+ Clone
+ 'static {
Show 15 methods
// Required methods
fn load_v1_reward_account_proof(
&self,
_height: u64,
_account: RewardAccountV1,
) -> impl Send + Future<Output = Result<RewardAccountQueryDataV1>>;
fn persist_reward_proofs(
&self,
node_state: &NodeState,
height: u64,
version: Version,
) -> impl Send + Future<Output = Result<()>>;
fn persist_tree(
&self,
height: u64,
merkle_tree: Vec<u8>,
) -> impl Send + Future<Output = Result<()>>;
fn load_tree(
&self,
height: u64,
) -> impl Send + Future<Output = Result<Vec<u8>>>;
fn load_latest_tree(
&self,
height: u64,
) -> impl Send + Future<Output = Result<Vec<u8>>>;
fn persist_proofs(
&self,
height: u64,
proofs: impl Iterator<Item = (Vec<u8>, Vec<u8>)> + Send,
) -> impl Send + Future<Output = Result<()>>;
fn load_proof(
&self,
height: u64,
account: Vec<u8>,
epoch_height: u64,
) -> impl Send + Future<Output = Result<Vec<u8>>>;
fn load_latest_proof(
&self,
account: Vec<u8>,
) -> impl Send + Future<Output = Result<Vec<u8>>>;
fn proof_exists(&self, height: u64) -> impl Send + Future<Output = bool>;
fn garbage_collect(
&self,
height: u64,
) -> impl Send + Future<Output = Result<()>>;
// Provided methods
fn save_and_gc_reward_tree_v2(
&self,
node_state: &NodeState,
height: u64,
version: Version,
merkle_tree: &RewardMerkleTreeV2,
) -> impl Send + Future<Output = Result<()>> { ... }
fn load_reward_merkle_tree_v2(
&self,
height: u64,
) -> impl Send + Future<Output = Result<PermittedRewardMerkleTreeV2>> { ... }
fn load_latest_reward_merkle_tree_v2(
&self,
height: u64,
) -> impl Send + Future<Output = Result<PermittedRewardMerkleTreeV2>> { ... }
fn load_reward_account_proof_v2(
&self,
_height: u64,
_account: RewardAccountV2,
) -> impl Send + Future<Output = Result<RewardAccountQueryDataV2>> { ... }
fn load_latest_reward_account_proof_v2(
&self,
account: RewardAccountV2,
) -> impl Send + Future<Output = Result<RewardAccountQueryDataV2>> { ... }
}Required Methods§
fn load_v1_reward_account_proof( &self, _height: u64, _account: RewardAccountV1, ) -> impl Send + Future<Output = Result<RewardAccountQueryDataV1>>
fn persist_reward_proofs( &self, node_state: &NodeState, height: u64, version: Version, ) -> impl Send + Future<Output = Result<()>>
fn persist_tree( &self, height: u64, merkle_tree: Vec<u8>, ) -> impl Send + Future<Output = Result<()>>
fn load_tree(&self, height: u64) -> impl Send + Future<Output = Result<Vec<u8>>>
Sourcefn load_latest_tree(
&self,
height: u64,
) -> impl Send + Future<Output = Result<Vec<u8>>>
fn load_latest_tree( &self, height: u64, ) -> impl Send + Future<Output = Result<Vec<u8>>>
Load the latest serialized reward merkle tree v2 at height <= height.
fn persist_proofs( &self, height: u64, proofs: impl Iterator<Item = (Vec<u8>, Vec<u8>)> + Send, ) -> impl Send + Future<Output = Result<()>>
fn load_proof( &self, height: u64, account: Vec<u8>, epoch_height: u64, ) -> impl Send + Future<Output = Result<Vec<u8>>>
fn load_latest_proof( &self, account: Vec<u8>, ) -> impl Send + Future<Output = Result<Vec<u8>>>
fn proof_exists(&self, height: u64) -> impl Send + Future<Output = bool>
Provided Methods§
fn save_and_gc_reward_tree_v2( &self, node_state: &NodeState, height: u64, version: Version, merkle_tree: &RewardMerkleTreeV2, ) -> impl Send + Future<Output = Result<()>>
fn load_reward_merkle_tree_v2( &self, height: u64, ) -> impl Send + Future<Output = Result<PermittedRewardMerkleTreeV2>>
Sourcefn load_latest_reward_merkle_tree_v2(
&self,
height: u64,
) -> impl Send + Future<Output = Result<PermittedRewardMerkleTreeV2>>
fn load_latest_reward_merkle_tree_v2( &self, height: u64, ) -> impl Send + Future<Output = Result<PermittedRewardMerkleTreeV2>>
Returns the RewardMerkleTreeV2 for height <= requested height
After V5 the tree is only written at epoch boundaries, so reward_merkle_tree_v2_data
has no row for most heights. Within an epoch the tree doesn’t change, so the previous
boundary’s tree matches the current block’s reward root but only if we’re actually in
the same epoch. The caller is responsible for checking the returned tree’s commitment
against the header at height.
if they differ we loaded a tree from an older epoch.
fn load_reward_account_proof_v2( &self, _height: u64, _account: RewardAccountV2, ) -> impl Send + Future<Output = Result<RewardAccountQueryDataV2>>
fn load_latest_reward_account_proof_v2( &self, account: RewardAccountV2, ) -> impl Send + Future<Output = Result<RewardAccountQueryDataV2>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl RewardMerkleTreeDataSource for MetricsDataSource
impl RewardMerkleTreeDataSource for MetricsDataSource
fn load_v1_reward_account_proof( &self, _height: u64, _account: RewardAccountV1, ) -> impl Send + Future<Output = Result<RewardAccountQueryDataV1>>
fn persist_reward_proofs( &self, _node_state: &NodeState, _height: u64, _version: Version, ) -> impl Send + Future<Output = Result<()>>
fn persist_tree( &self, _height: u64, _merkle_tree: Vec<u8>, ) -> impl Send + Future<Output = Result<()>>
fn load_tree( &self, _height: u64, ) -> impl Send + Future<Output = Result<Vec<u8>>>
fn load_latest_tree( &self, _height: u64, ) -> impl Send + Future<Output = Result<Vec<u8>>>
fn garbage_collect( &self, _height: u64, ) -> impl Send + Future<Output = Result<()>>
fn persist_proofs( &self, _height: u64, _proofs: impl Iterator<Item = (Vec<u8>, Vec<u8>)> + Send, ) -> impl Send + Future<Output = Result<()>>
fn load_proof( &self, _height: u64, _account: Vec<u8>, _epoch_height: u64, ) -> impl Send + Future<Output = Result<Vec<u8>>>
fn load_latest_proof( &self, _account: Vec<u8>, ) -> impl Send + Future<Output = Result<Vec<u8>>>
fn proof_exists(&self, _height: u64) -> impl Send + Future<Output = bool>
Source§impl RewardMerkleTreeDataSource for SqlStorage
impl RewardMerkleTreeDataSource for SqlStorage
Source§fn load_proof(
&self,
height: u64,
account: Vec<u8>,
epoch_height: u64,
) -> impl Send + Future<Output = Result<Vec<u8>>>
fn load_proof( &self, height: u64, account: Vec<u8>, epoch_height: u64, ) -> impl Send + Future<Output = Result<Vec<u8>>>
Load a reward proof for a given height and account.
For V5+ (epoch rewards), if the requested height is not an epoch boundary, resolves to the previous epoch’s last block. Verifies the boundary block is V5+ to handle V4→V5 upgrades. For V4 (per-block rewards), proofs are stored at every block height.
Source§fn persist_reward_proofs(
&self,
node_state: &NodeState,
height: u64,
version: Version,
) -> impl Send + Future<Output = Result<()>>
fn persist_reward_proofs( &self, node_state: &NodeState, height: u64, version: Version, ) -> impl Send + Future<Output = Result<()>>
Generate and persist reward proofs for the current L1-finalized height.
For V5+ (epoch rewards), the reward tree is only stored at epoch boundaries. We resolve to the nearest epoch boundary to load the tree, verify it’s V5+ (for V4→V5 upgrades), and store the generated proofs at the same boundary height. For V4 (per-block rewards), the tree exists at every block height.