Skip to content

Commit

Permalink
Update kvdb version in availability-store (paritytech#709)
Browse files Browse the repository at this point in the history
* update availability store

* also fix warning

* update Cargo.lock
  • Loading branch information
NikVolf authored and gavofyork committed Jan 3, 2020
1 parent d3e2d9e commit dd113a7
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 12 deletions.
44 changes: 41 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions availability-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "pol
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
keystore = { package = "sc-keystore", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
kvdb = "0.1.1"
kvdb-memorydb = "0.1.2"
kvdb = "0.2.0"
kvdb-memorydb = "0.2.0"

[target.'cfg(not(target_os = "unknown"))'.dependencies]
kvdb-rocksdb = "0.2"
kvdb-rocksdb = "0.3"
2 changes: 1 addition & 1 deletion availability-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl Store {
client: Arc<P>,
thread_pool: TaskExecutor,
keystore: KeyStorePtr,
) -> ClientResult<(AvailabilityBlockImport<I, P>)>
) -> ClientResult<AvailabilityBlockImport<I, P>>
where
P: ProvideRuntimeApi + BlockchainEvents<Block> + BlockBody<Block> + Send + Sync + 'static,
P::Api: ParachainHost<Block>,
Expand Down
10 changes: 5 additions & 5 deletions availability-store/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ use std::io;
use crate::{LOG_TARGET, Data, Config};

mod columns {
pub const DATA: Option<u32> = Some(0);
pub const META: Option<u32> = Some(1);
pub const DATA: u32 = 0;
pub const META: u32 = 1;
pub const NUM_COLUMNS: u32 = 2;
}

Expand Down Expand Up @@ -85,12 +85,12 @@ impl Store {
/// Create a new `Store` with given condig on disk.
#[cfg(not(target_os = "unknown"))]
pub(super) fn new(config: Config) -> io::Result<Self> {
let mut db_config = DatabaseConfig::with_columns(Some(columns::NUM_COLUMNS));
let mut db_config = DatabaseConfig::with_columns(columns::NUM_COLUMNS);

if let Some(cache_size) = config.cache_size {
let mut memory_budget = std::collections::HashMap::new();
for i in 0..columns::NUM_COLUMNS {
memory_budget.insert(Some(i), cache_size / columns::NUM_COLUMNS as usize);
memory_budget.insert(i, cache_size / columns::NUM_COLUMNS as usize);
}

db_config.memory_budget = memory_budget;
Expand Down Expand Up @@ -396,7 +396,7 @@ impl Store {
self.query_inner(columns::META, &block_to_candidate_key(&block_hash))
}

fn query_inner<T: Decode>(&self, column: Option<u32>, key: &[u8]) -> Option<T> {
fn query_inner<T: Decode>(&self, column: u32, key: &[u8]) -> Option<T> {
match self.inner.get(column, key) {
Ok(Some(raw)) => {
let res = T::decode(&mut &raw[..]).expect("all stored data serialized correctly; qed");
Expand Down

0 comments on commit dd113a7

Please sign in to comment.