From aceeefbbdff6a1900976f4472e26cc4f6aa90eb8 Mon Sep 17 00:00:00 2001 From: Carl Date: Wed, 21 Nov 2018 03:40:57 -0800 Subject: [PATCH] Create RocksDb ledger in bin/fullnode --- src/bin/fullnode.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/bin/fullnode.rs b/src/bin/fullnode.rs index 67af9371dbf995..e8b03e951c6fce 100644 --- a/src/bin/fullnode.rs +++ b/src/bin/fullnode.rs @@ -6,13 +6,17 @@ extern crate log; extern crate serde_json; #[macro_use] extern crate solana; +extern crate rocksdb; extern crate solana_metrics; use clap::{App, Arg}; +use rocksdb::{Options, DB}; use solana::client::mk_client; use solana::cluster_info::{Node, FULLNODE_PORT_RANGE}; +use solana::db_ledger::{write_entries_to_ledger, DB_LEDGER_DIRECTORY}; use solana::fullnode::{Config, Fullnode, FullnodeReturnType}; use solana::leader_scheduler::LeaderScheduler; +use solana::ledger::read_ledger; use solana::logger; use solana::netutil::find_available_port_in_range; use solana::signature::{Keypair, KeypairUtil}; @@ -85,6 +89,17 @@ fn main() { let ledger_path = matches.value_of("ledger").unwrap(); + // Create the RocksDb ledger + let db_ledger_path = format!("{}/{}", ledger_path, DB_LEDGER_DIRECTORY); + // Destroy old ledger + DB::destroy(&Options::default(), &db_ledger_path) + .expect("Expected successful database destruction"); + let ledger_entries: Vec<_> = read_ledger(ledger_path, true) + .expect("opening ledger") + .map(|entry| entry.unwrap()) + .collect(); + write_entries_to_ledger(&vec![db_ledger_path], &ledger_entries[..]); + // socketaddr that is initial pointer into the network's gossip (ncp) let network = matches .value_of("network")