Expanded fork choice api to provide latest validator message.
This commit is contained in:
parent
bef7ca6bfb
commit
3b8a584c55
@ -43,4 +43,7 @@ pub trait LmdGhost<S: Store, E: EthSpec>: Send + Sync {
|
|||||||
finalized_block: &BeaconBlock,
|
finalized_block: &BeaconBlock,
|
||||||
finalized_block_root: Hash256,
|
finalized_block_root: Hash256,
|
||||||
) -> Result<()>;
|
) -> Result<()>;
|
||||||
|
|
||||||
|
/// Returns the latest message for a given validator index.
|
||||||
|
fn latest_message(&mut self, validator_index: usize) -> Option<(Hash256, Slot)>;
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,12 @@ where
|
|||||||
.update_root(new_block.slot, new_root)
|
.update_root(new_block.slot, new_root)
|
||||||
.map_err(|e| format!("update_finalized_root failed: {:?}", e))
|
.map_err(|e| format!("update_finalized_root failed: {:?}", e))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn latest_message(&mut self, validator_index: usize) -> Option<(Hash256, Slot)> {
|
||||||
|
self.core
|
||||||
|
.write()
|
||||||
|
.latest_message(validator_index)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ReducedTree<T, E> {
|
struct ReducedTree<T, E> {
|
||||||
@ -222,6 +228,13 @@ where
|
|||||||
Ok(head_node.block_hash)
|
Ok(head_node.block_hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn latest_message(&mut self, validator_index: usize) -> Option<(Hash256, Slot)> {
|
||||||
|
match self.latest_votes.get(validator_index) {
|
||||||
|
Some(v) => Some((v.hash.clone(), v.slot.clone())),
|
||||||
|
None => None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn find_head_from<'a>(&'a self, start_node: &'a Node) -> Result<&'a Node> {
|
fn find_head_from<'a>(&'a self, start_node: &'a Node) -> Result<&'a Node> {
|
||||||
if start_node.does_not_have_children() {
|
if start_node.does_not_have_children() {
|
||||||
Ok(start_node)
|
Ok(start_node)
|
||||||
|
Loading…
Reference in New Issue
Block a user