Rename JustificationManager

This commit is contained in:
Paul Hauner
2020-01-17 12:48:29 +11:00
parent 272c16c2f2
commit 991223db1e
3 changed files with 16 additions and 42 deletions

View File

@@ -211,22 +211,7 @@ impl ProtoArray {
/// - The finalized epoch is less than the current one.
/// - The finalized epoch is equal to the current one, but the finalized root is different.
/// - There is some internal error relating to invalid indices inside `self`.
pub fn maybe_prune(
&mut self,
finalized_epoch: Epoch,
finalized_root: Hash256,
) -> Result<(), Error> {
if finalized_epoch < self.finalized_epoch {
// It's illegal to swap to an earlier finalized root (this is assumed to be reverting a
// finalized block).
return Err(Error::RevertedFinalizedEpoch {
current_finalized_epoch: self.finalized_epoch,
new_finalized_epoch: finalized_epoch,
});
} else if finalized_epoch != self.finalized_epoch {
self.finalized_epoch = finalized_epoch;
}
pub fn maybe_prune(&mut self, finalized_root: Hash256) -> Result<(), Error> {
let finalized_index = *self
.indices
.get(&finalized_root)

View File

@@ -34,11 +34,6 @@ where
}
}
pub fn get(&mut self, i: usize) -> &T {
self.ensure(i);
&self.0[i]
}
pub fn get_mut(&mut self, i: usize) -> &mut T {
self.ensure(i);
&mut self.0[i]
@@ -164,14 +159,10 @@ impl ProtoArrayForkChoice {
.map_err(|e| format!("find_head failed: {:?}", e))
}
pub fn update_finalized_root(
&self,
finalized_epoch: Epoch,
finalized_root: Hash256,
) -> Result<(), String> {
pub fn maybe_prune(&self, finalized_root: Hash256) -> Result<(), String> {
self.proto_array
.write()
.maybe_prune(finalized_epoch, finalized_root)
.maybe_prune(finalized_root)
.map_err(|e| format!("find_head maybe_prune failed: {:?}", e))
}