2019-06-15 18:03:29 +00:00
|
|
|
mod reduced_tree;
|
2019-06-15 15:26:56 +00:00
|
|
|
|
|
|
|
use std::sync::Arc;
|
2019-06-15 18:03:29 +00:00
|
|
|
use store::Store;
|
|
|
|
use types::{EthSpec, Hash256, Slot};
|
2019-06-15 15:26:56 +00:00
|
|
|
|
2019-06-15 18:03:29 +00:00
|
|
|
pub use reduced_tree::ThreadSafeReducedTree;
|
2019-06-15 15:26:56 +00:00
|
|
|
|
2019-06-15 18:03:29 +00:00
|
|
|
pub type Result<T> = std::result::Result<T, String>;
|
2019-06-15 15:26:56 +00:00
|
|
|
|
2019-06-15 18:03:29 +00:00
|
|
|
pub trait LmdGhost<S: Store, E: EthSpec>: Send + Sync {
|
2019-06-16 20:39:48 +00:00
|
|
|
/// Create a new instance, with the given `store` and `finalized_root`.
|
|
|
|
fn new(store: Arc<S>, finalized_root: Hash256) -> Self;
|
2019-06-15 15:26:56 +00:00
|
|
|
|
2019-06-16 20:39:48 +00:00
|
|
|
/// Process an attestation message from some validator that attests to some `block_hash`
|
|
|
|
/// representing a block at some `block_slot`.
|
|
|
|
fn process_attestation(
|
2019-06-15 15:26:56 +00:00
|
|
|
&self,
|
|
|
|
validator_index: usize,
|
|
|
|
block_hash: Hash256,
|
|
|
|
block_slot: Slot,
|
|
|
|
) -> Result<()>;
|
|
|
|
|
2019-06-16 20:39:48 +00:00
|
|
|
/// 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).
|
2019-06-15 19:05:34 +00:00
|
|
|
fn find_head<F>(&self, start_block_root: Hash256, weight: F) -> Result<Hash256>
|
|
|
|
where
|
2019-06-15 22:19:08 +00:00
|
|
|
F: Fn(usize) -> Option<u64> + Copy;
|
|
|
|
|
2019-06-16 20:39:48 +00:00
|
|
|
/// Provide an indication that the blockchain has been finalized at the given `finalized_root`.
|
|
|
|
fn update_finalized_root(&self, finalized_root: Hash256) -> Result<()>;
|
2019-06-15 15:26:56 +00:00
|
|
|
}
|