Skip to content

Commit

Permalink
Merge pull request #129 from paritytech/insipx/update-polkadot
Browse files Browse the repository at this point in the history
Update Cargo.lock for polkadot 0.8.26
  • Loading branch information
dvdplm authored Nov 6, 2020
2 parents 481ec93 + 25d08ec commit b12c051
Show file tree
Hide file tree
Showing 9 changed files with 1,233 additions and 1,422 deletions.
981 changes: 387 additions & 594 deletions Cargo.lock

Large diffs are not rendered by default.

757 changes: 384 additions & 373 deletions bin/node-template-archive/Cargo.lock

Large diffs are not rendered by default.

490 changes: 263 additions & 227 deletions bin/polkadot-archive/Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bin/polkadot-archive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-archive"
version = "0.2.1"
version = "0.2.2"
authors = ["Andrew Plaza <[email protected]>"]
edition = "2018"

Expand Down
170 changes: 76 additions & 94 deletions bin/polkadot-archive/src/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,108 +23,90 @@ use polkadot_service::westend_runtime as westend_rt;
use polkadot_service::Block;
use sc_chain_spec::ChainSpec;
use substrate_archive::{Archive, ArchiveBuilder};
use substrate_archive_common::database::ReadOnlyDB;
use substrate_archive_common::ReadOnlyDB;

pub fn run_archive<D: ReadOnlyDB + 'static>(config: Config) -> Result<Box<dyn Archive<Block, D>>> {
let mut db_path = if let Some(p) = config.polkadot_path() {
p
} else {
let path = std::env::var("CHAIN_DATA_DB").expect("CHAIN_DATA_DB must be set.");
std::path::PathBuf::from(path)
};
let mut db_path = if let Some(p) = config.polkadot_path() {
p
} else {
let path = std::env::var("CHAIN_DATA_DB").expect("CHAIN_DATA_DB must be set.");
std::path::PathBuf::from(path)
};

let spec = get_spec(config.cli().chain.as_str())?;
let spec = get_spec(config.cli().chain.as_str())?;

let last_path_part = db_path
.file_name()
.context("Polkadot path not valid")?
.to_str()
.context("could not convert path to string")?;
let last_path_part =
db_path.file_name().context("Polkadot path not valid")?.to_str().context("could not convert path to string")?;

match last_path_part {
"polkadot" => db_path.push(format!("chains/{}/db", spec.id())),
"chains" => db_path.push(format!("{}/db", spec.id())),
_ => return Err(anyhow!("invalid path {}", db_path.as_path().display())),
}
match last_path_part {
"polkadot" => db_path.push(format!("chains/{}/db", spec.id())),
"chains" => db_path.push(format!("{}/db", spec.id())),
_ => return Err(anyhow!("invalid path {}", db_path.as_path().display())),
}

let db_path = db_path
.as_path()
.to_str()
.context("could not convert rocksdb path to str")?
.to_string();
let db_path = db_path.as_path().to_str().context("could not convert rocksdb path to str")?.to_string();

match config.cli().chain.to_ascii_lowercase().as_str() {
"kusama" | "ksm" => {
let archive =
ArchiveBuilder::<Block, ksm_rt::RuntimeApi, polkadot_service::KusamaExecutor, D> {
pg_url: config.psql_conf().map(|u| u.url()),
cache_size: config.cache_size(),
block_workers: config.block_workers(),
wasm_pages: config.wasm_pages(),
max_block_load: config.max_block_load(),
..ArchiveBuilder::default()
}
.chain_data_db(db_path)
.chain_spec(spec)
.build()?;
Ok(Box::new(archive))
}
"westend" => {
let archive = ArchiveBuilder::<
Block,
westend_rt::RuntimeApi,
polkadot_service::WestendExecutor,
D,
> {
pg_url: config.psql_conf().map(|u| u.url()),
cache_size: config.cache_size(),
block_workers: config.block_workers(),
wasm_pages: config.wasm_pages(),
max_block_load: config.max_block_load(),
..ArchiveBuilder::default()
}
.chain_data_db(db_path)
.chain_spec(spec)
.build()?;
Ok(Box::new(archive))
}
"polkadot" | "dot" => {
let archive = ArchiveBuilder::<
Block,
dot_rt::RuntimeApi,
polkadot_service::PolkadotExecutor,
D,
> {
pg_url: config.psql_conf().map(|u| u.url()),
cache_size: config.cache_size(),
block_workers: config.block_workers(),
wasm_pages: config.wasm_pages(),
max_block_load: config.max_block_load(),
..ArchiveBuilder::default()
}
.chain_data_db(db_path)
.chain_spec(spec)
.build()?;
Ok(Box::new(archive))
}
c => Err(anyhow!("unknown chain {}", c)),
}
match config.cli().chain.to_ascii_lowercase().as_str() {
"kusama" | "ksm" => {
let archive = ArchiveBuilder::<Block, ksm_rt::RuntimeApi, polkadot_service::KusamaExecutor, D> {
pg_url: config.psql_conf().map(|u| u.url()),
cache_size: config.cache_size(),
block_workers: config.block_workers(),
wasm_pages: config.wasm_pages(),
max_block_load: config.max_block_load(),
..ArchiveBuilder::default()
}
.chain_data_db(db_path)
.chain_spec(spec)
.build()?;
Ok(Box::new(archive))
}
"westend" => {
let archive = ArchiveBuilder::<Block, westend_rt::RuntimeApi, polkadot_service::WestendExecutor, D> {
pg_url: config.psql_conf().map(|u| u.url()),
cache_size: config.cache_size(),
block_workers: config.block_workers(),
wasm_pages: config.wasm_pages(),
max_block_load: config.max_block_load(),
..ArchiveBuilder::default()
}
.chain_data_db(db_path)
.chain_spec(spec)
.build()?;
Ok(Box::new(archive))
}
"polkadot" | "dot" => {
let archive = ArchiveBuilder::<Block, dot_rt::RuntimeApi, polkadot_service::PolkadotExecutor, D> {
pg_url: config.psql_conf().map(|u| u.url()),
cache_size: config.cache_size(),
block_workers: config.block_workers(),
wasm_pages: config.wasm_pages(),
max_block_load: config.max_block_load(),
..ArchiveBuilder::default()
}
.chain_data_db(db_path)
.chain_spec(spec)
.build()?;
Ok(Box::new(archive))
}
c => Err(anyhow!("unknown chain {}", c)),
}
}

fn get_spec(chain: &str) -> Result<Box<dyn ChainSpec>> {
match chain.to_ascii_lowercase().as_str() {
"kusama" | "ksm" => {
let spec = polkadot_service::chain_spec::kusama_config().unwrap();
Ok(Box::new(spec) as Box<dyn ChainSpec>)
}
"westend" => {
let spec = polkadot_service::chain_spec::westend_config().unwrap();
Ok(Box::new(spec) as Box<dyn ChainSpec>)
}
"polkadot" | "dot" => {
let spec = polkadot_service::chain_spec::polkadot_config().unwrap();
Ok(Box::new(spec) as Box<dyn ChainSpec>)
}
c => Err(anyhow!("unknown chain {}", c)),
}
match chain.to_ascii_lowercase().as_str() {
"kusama" | "ksm" => {
let spec = polkadot_service::chain_spec::kusama_config().unwrap();
Ok(Box::new(spec) as Box<dyn ChainSpec>)
}
"westend" => {
let spec = polkadot_service::chain_spec::westend_config().unwrap();
Ok(Box::new(spec) as Box<dyn ChainSpec>)
}
"polkadot" | "dot" => {
let spec = polkadot_service::chain_spec::polkadot_config().unwrap();
Ok(Box::new(spec) as Box<dyn ChainSpec>)
}
c => Err(anyhow!("unknown chain {}", c)),
}
}
47 changes: 21 additions & 26 deletions bin/polkadot-archive/src/cli_opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,28 @@ use std::path::PathBuf;

#[derive(Debug, Clone)]
pub struct CliOpts {
pub file: Option<PathBuf>,
pub log_level: log::LevelFilter,
pub log_num: u64,
pub chain: String,
pub file: Option<PathBuf>,
pub log_level: log::LevelFilter,
pub log_num: u64,
pub chain: String,
}

impl CliOpts {
pub fn parse() -> Self {
let yaml = load_yaml!("cli_opts.yaml");
let matches = App::from(yaml).get_matches();
let log_level = match matches.occurrences_of("verbose") {
0 => log::LevelFilter::Info,
1 => log::LevelFilter::Info,
2 => log::LevelFilter::Info,
3 => log::LevelFilter::Debug,
4 | _ => log::LevelFilter::Trace,
};
let log_num = matches.occurrences_of("verbose");
let file = matches.value_of("config");

let chain = matches.value_of("chain").unwrap_or("polkadot");

CliOpts {
file: file.map(|f| PathBuf::from(f)),
log_level,
log_num,
chain: chain.to_string(),
}
}
pub fn parse() -> Self {
let yaml = load_yaml!("cli_opts.yaml");
let matches = App::from(yaml).get_matches();
let log_level = match matches.occurrences_of("verbose") {
0 => log::LevelFilter::Info,
1 => log::LevelFilter::Info,
2 => log::LevelFilter::Info,
3 => log::LevelFilter::Debug,
4 | _ => log::LevelFilter::Trace,
};
let log_num = matches.occurrences_of("verbose");
let file = matches.value_of("config");

let chain = matches.value_of("chain").unwrap_or("polkadot");

CliOpts { file: file.map(|f| PathBuf::from(f)), log_level, log_num, chain: chain.to_string() }
}
}
4 changes: 2 additions & 2 deletions bin/polkadot-archive/src/cli_opts.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: polkadot-archive
version: "0.2"
name: polkadot-archive
version: "0.2.2"
author: Andrew P. <[email protected]>
about: Indexes the Polkadot, Kusama and Westend Networks
args:
Expand Down
Loading

0 comments on commit b12c051

Please sign in to comment.