Make BeaconState.balances a tree list!

This commit is contained in:
Michael Sproul
2021-12-01 14:14:47 +11:00
parent 4b808d3c72
commit fca92c37ad
11 changed files with 76 additions and 31 deletions

View File

@@ -217,12 +217,13 @@ where
};
let finalized_checkpoint = justified_checkpoint;
// FIXME(sproul): avoid `to_vec` perf penalty
Self {
store,
balances_cache: <_>::default(),
time: anchor_state.slot(),
justified_checkpoint,
justified_balances: anchor_state.balances().clone().into(),
justified_balances: anchor_state.balances().to_vec(),
finalized_checkpoint,
best_justified_checkpoint: justified_checkpoint,
_phantom: PhantomData,
@@ -327,8 +328,7 @@ where
.map_err(Error::FailedToReadState)?
.ok_or_else(|| Error::MissingState(justified_block.state_root()))?
.balances()
.clone()
.into();
.to_vec();
}
Ok(())