Track detached slots in blocktree (#3536)

* Add contains_all_parents flag to SlotMeta to prep for tracking detached heads

* Add new DetachedHeads column family

* Remove has_complete_parents

* Fix test
This commit is contained in:
carllin
2019-03-29 16:07:24 -07:00
committed by GitHub
parent dee5ede16d
commit 9369ea86ea
4 changed files with 268 additions and 55 deletions

View File

@ -31,6 +31,12 @@ pub struct ErasureCf {
db: Arc<Kvs>,
}
/// The detached heads column family
#[derive(Debug)]
pub struct DetachedHeadsCf {
db: Arc<Kvs>,
}
/// Dummy struct to get things compiling
/// TODO: all this goes away with Blocktree
pub struct EntryIterator(i32);
@ -208,6 +214,34 @@ impl IndexColumn<Kvs> for MetaCf {
}
}
impl LedgerColumnFamilyRaw<Kvs> for DetachedHeadsCf {
fn db(&self) -> &Arc<Kvs> {
&self.db
}
fn handle(&self) -> ColumnFamily {
self.db.cf_handle(super::DETACHED_HEADS_CF).unwrap()
}
}
impl LedgerColumnFamily<Kvs> for DetachedHeadsCf {
type ValueType = bool;
}
impl IndexColumn<Kvs> for DetachedHeadsCf {
type Index = u64;
fn index(key: &Key) -> u64 {
BigEndian::read_u64(&key.0[8..16])
}
fn key(slot: &u64) -> Key {
let mut key = Key::default();
BigEndian::write_u64(&mut key.0[8..16], *slot);
key
}
}
impl std::convert::From<kvstore::Error> for Error {
fn from(e: kvstore::Error) -> Error {
Error::BlocktreeError(BlocktreeError::KvsDb(e))