Skip to content

Commit

Permalink
db_ledger now fully encapsulates rocksdb
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Dec 20, 2018
1 parent 7148c14 commit 034c5d0
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 155 deletions.
13 changes: 5 additions & 8 deletions benches/db_ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn bench_write_blobs(bench: &mut Bencher, blobs: &mut [&mut Blob], ledger_path:
let size = blob.size().unwrap();
db_ledger
.data_cf
.put(&db_ledger.db, &key, &blob.data[..BLOB_HEADER_SIZE + size])
.put(&key, &blob.data[..BLOB_HEADER_SIZE + size])
.unwrap();
blob.set_index(index + num_blobs as u64).unwrap();
}
Expand Down Expand Up @@ -99,10 +99,9 @@ fn bench_read_sequential(bench: &mut Bencher) {
// Generate random starting point in the range [0, total_blobs - 1], read num_reads blobs sequentially
let start_index = rng.gen_range(0, num_small_blobs + num_large_blobs);
for i in start_index..start_index + num_reads {
let _ =
db_ledger
.data_cf
.get_by_slot_index(&db_ledger.db, slot, i as u64 % total_blobs);
let _ = db_ledger
.data_cf
.get_by_slot_index(slot, i as u64 % total_blobs);
}
});

Expand Down Expand Up @@ -133,9 +132,7 @@ fn bench_read_random(bench: &mut Bencher) {
.collect();
bench.iter(move || {
for i in indexes.iter() {
let _ = db_ledger
.data_cf
.get_by_slot_index(&db_ledger.db, slot, *i as u64);
let _ = db_ledger.data_cf.get_by_slot_index(slot, *i as u64);
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/broadcast_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ mod test {
.expect("Leader should exist");
let result = db_ledger
.data_cf
.get_by_slot_index(&db_ledger.db, slot, entry_height + i)
.get_by_slot_index(slot, entry_height + i)
.unwrap();

assert!(result.is_some());
Expand Down
6 changes: 2 additions & 4 deletions src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,15 +678,13 @@ impl ClusterInfo {
ix: u64,
) -> Vec<SharedBlob> {
if let Some(db_ledger) = db_ledger {
let meta = db_ledger
.meta_cf
.get(&db_ledger.db, &MetaCf::key(DEFAULT_SLOT_HEIGHT));
let meta = db_ledger.meta_cf.get(&MetaCf::key(DEFAULT_SLOT_HEIGHT));

if let Ok(Some(meta)) = meta {
let max_slot = meta.received_slot;
// Try to find the requested index in one of the slots
for i in 0..=max_slot {
let get_result = db_ledger.data_cf.get_by_slot_index(&db_ledger.db, i, ix);
let get_result = db_ledger.data_cf.get_by_slot_index(i, ix);

if let Ok(Some(blob_data)) = get_result {
inc_new_counter_info!("cluster_info-window-request-ledger", 1);
Expand Down
Loading

0 comments on commit 034c5d0

Please sign in to comment.