Skip to content

Commit

Permalink
Write format version in commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mappum committed Nov 14, 2024
1 parent b92b97a commit 16de2df
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/merk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ use crate::tree::{Batch, Commit, Fetch, GetResult, Hash, Op, RefWalker, Tree, Wa
pub use self::snapshot::Snapshot;

const ROOT_KEY_KEY: &[u8] = b"root";
const FORMAT_VERSION_KEY: &[u8] = b"format";
const AUX_CF_NAME: &str = "aux";
const INTERNAL_CF_NAME: &str = "internal";

const FORMAT_VERSION: u64 = 1;

fn column_families() -> Vec<ColumnFamilyDescriptor> {
vec![
// TODO: clone opts or take args
Expand Down Expand Up @@ -391,6 +394,14 @@ impl Merk {
};
}

// update format version
// TODO: shouldn't need a write per commit
batch.put_cf(
internal_cf,
FORMAT_VERSION_KEY,
&FORMAT_VERSION.to_be_bytes(),
);

// write to db
self.write(batch)?;

Expand Down

0 comments on commit 16de2df

Please sign in to comment.