mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-12 02:14:10 +00:00
Plumb reward cache through reward calc
This commit is contained in:
@@ -52,6 +52,7 @@ pub fn get_block_rewards<T: BeaconChainTypes>(
|
||||
.build_all_caches(&chain.spec)
|
||||
.map_err(beacon_state_error)?;
|
||||
|
||||
let mut reward_cache = Default::default();
|
||||
let mut block_rewards = Vec::with_capacity(blocks.len());
|
||||
|
||||
let block_replayer = BlockReplayer::new(state, &chain.spec)
|
||||
@@ -63,6 +64,7 @@ pub fn get_block_rewards<T: BeaconChainTypes>(
|
||||
block.message(),
|
||||
block.canonical_root(),
|
||||
state,
|
||||
&mut reward_cache,
|
||||
query.include_attestations,
|
||||
)?;
|
||||
block_rewards.push(block_reward);
|
||||
@@ -100,6 +102,7 @@ pub fn compute_block_rewards<T: BeaconChainTypes>(
|
||||
) -> Result<Vec<BlockReward>, warp::Rejection> {
|
||||
let mut block_rewards = Vec::with_capacity(blocks.len());
|
||||
let mut state_cache = LruCache::new(STATE_CACHE_SIZE);
|
||||
let mut reward_cache = Default::default();
|
||||
|
||||
for block in blocks {
|
||||
let parent_root = block.parent_root();
|
||||
@@ -170,7 +173,13 @@ pub fn compute_block_rewards<T: BeaconChainTypes>(
|
||||
|
||||
// Compute block reward.
|
||||
let block_reward = chain
|
||||
.compute_block_reward(block.to_ref(), block.canonical_root(), state, true)
|
||||
.compute_block_reward(
|
||||
block.to_ref(),
|
||||
block.canonical_root(),
|
||||
state,
|
||||
&mut reward_cache,
|
||||
true,
|
||||
)
|
||||
.map_err(beacon_chain_error)?;
|
||||
block_rewards.push(block_reward);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user