Add stubbed-out block processing to fork choice

This commit is contained in:
Paul Hauner
2019-06-16 16:39:48 -04:00
parent f6c86d0f7f
commit 9c2bbb6c05
4 changed files with 23 additions and 6 deletions

View File

@@ -9,18 +9,27 @@ pub use reduced_tree::ThreadSafeReducedTree;
pub type Result<T> = std::result::Result<T, String>;
pub trait LmdGhost<S: Store, E: EthSpec>: Send + Sync {
fn new(store: Arc<S>, genesis_root: Hash256) -> Self;
/// Create a new instance, with the given `store` and `finalized_root`.
fn new(store: Arc<S>, finalized_root: Hash256) -> Self;
fn process_message(
/// Process an attestation message from some validator that attests to some `block_hash`
/// representing a block at some `block_slot`.
fn process_attestation(
&self,
validator_index: usize,
block_hash: Hash256,
block_slot: Slot,
) -> Result<()>;
/// Process a block that was seen on the network.
fn process_block(&self, block_hash: Hash256, block_slot: Slot) -> Result<()>;
/// Returns the head of the chain, starting the search at `start_block_root` and moving upwards
/// (in block height).
fn find_head<F>(&self, start_block_root: Hash256, weight: F) -> Result<Hash256>
where
F: Fn(usize) -> Option<u64> + Copy;
fn update_finalized_root(&self, new_root: Hash256) -> Result<()>;
/// Provide an indication that the blockchain has been finalized at the given `finalized_root`.
fn update_finalized_root(&self, finalized_root: Hash256) -> Result<()>;
}

View File

@@ -40,7 +40,7 @@ where
}
}
fn process_message(
fn process_attestation(
&self,
validator_index: usize,
block_hash: Hash256,
@@ -52,6 +52,11 @@ where
.map_err(Into::into)
}
/// Process a block that was seen on the network.
fn process_block(&self, block_hash: Hash256, block_slot: Slot) -> SuperResult<()> {
unimplemented!();
}
fn find_head<F>(&self, start_block_root: Hash256, weight_fn: F) -> SuperResult<Hash256>
where
F: Fn(usize) -> Option<u64> + Copy,