Skip to content

Commit

Permalink
Dynamic erasure (anza-xyz#4653)
Browse files Browse the repository at this point in the history
Remove erasure-related constants

Remove unneeded `Iterator::collect` call

Document erasure module

Randomize coding blobs used for repair
  • Loading branch information
mark-solana authored Jun 21, 2019
1 parent 4069ef2 commit ada4d16
Show file tree
Hide file tree
Showing 14 changed files with 1,091 additions and 1,037 deletions.
729 changes: 429 additions & 300 deletions core/src/blocktree.rs

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions core/src/blocktree/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ pub mod columns {
#[derive(Debug)]
/// The root column
pub struct Root;

#[derive(Debug)]
/// The index column
pub struct Index;
}

pub trait Backend: Sized + Send + Sync {
Expand Down
29 changes: 20 additions & 9 deletions core/src/blocktree/kvs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,21 @@ impl Backend for Kvs {

impl Column<Kvs> for cf::Coding {
const NAME: &'static str = super::ERASURE_CF;
type Index = (u64, u64);
type Index = (u64, u64, u64);

fn key(index: (u64, u64)) -> Key {
cf::Data::key(index)
fn key((slot, set_index, index): (u64, u64, u64)) -> Vec<u8> {
let mut key = Key::default();
BigEndian::write_u64(&mut key.0[..8], slot);
BigEndian::write_u64(&mut key.0[8..16], set_index);
BigEndian::write_u64(&mut key.0[16..], index);
key
}

fn index(key: &Key) -> (u64, u64) {
cf::Data::index(key)
fn index(key: &Key) -> (u64, u64, u64) {
let slot = BigEndian::read_u64(&key.0[..8]);
let set_index = BigEndian::read_u64(&key.0[8..16]);
let index = BigEndian::read_u64(&key.0[16..]);
(slot, set_index, index)
}
}

Expand Down Expand Up @@ -172,8 +179,12 @@ impl Column<Kvs> for cf::SlotMeta {
}
}

impl Column<Kvs> for cf::SlotMeta {
const NAME: &'static str = super::META_CF;
impl TypedColumn<Kvs> for cf::SlotMeta {
type Type = super::SlotMeta;
}

impl Column<Kvs> for cf::Index {
const NAME: &'static str = super::INDEX_CF;
type Index = u64;

fn key(slot: u64) -> Key {
Expand All @@ -187,8 +198,8 @@ impl Column<Kvs> for cf::SlotMeta {
}
}

impl TypedColumn<Kvs> for cf::SlotMeta {
type Type = super::SlotMeta;
impl TypedColumn<Kvs> for cf::Index {
type Type = crate::blocktree::meta::Index;
}

impl Column<Kvs> for cf::ErasureMeta {
Expand Down
Loading

0 comments on commit ada4d16

Please sign in to comment.