Skip to content

Commit

Permalink
chore: update ckb to v0.40.0-rc2
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Remove several rpc methods: get_cells_by_lock_hash, get_live_cells_by_lock_hash,
get_transactions_by_lock_hash, index_lock_hash, deindex_lock_hash, get_lock_hash_index_states,
get_capacity_by_lock_hash
  • Loading branch information
TheWaWaR committed Feb 22, 2021
1 parent 0a13cb3 commit 46679ec
Show file tree
Hide file tree
Showing 15 changed files with 1,170 additions and 1,417 deletions.
2,070 changes: 1,101 additions & 969 deletions Cargo.lock

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
[package]
name = "ckb-cli"
version = "0.39.0"
version = "0.40.0"
license = "MIT"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"

[dependencies]
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2", features = ["secp"] }
ckb-build-info = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-util = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-dao-utils = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-chain-spec = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2", features = ["secp"] }
ckb-build-info = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-util = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-dao-utils = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-chain-spec = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-sdk = { path = "ckb-sdk" }
ckb-index = { path = "ckb-index" }
plugin-protocol = { path = "plugin-protocol", package = "ckb-cli-plugin-protocol" }
jsonrpc-client-core = "0.5.0"
jsonrpc-core = "10.1"
jsonrpc-derive = "10.1"
jsonrpc-http-server = "10.1"
jsonrpc-server-utils = "10.1"
jsonrpc-core-client = "17"
jsonrpc-core = "17"
jsonrpc-derive = "17"
jsonrpc-http-server = "17"
jsonrpc-server-utils = "17"
secp256k1 = { version = "0.19", features = ["recovery"] }
faster-hex = "0.4"
env_logger = "0.6"
crossbeam-channel = "0.3"
clap = "3.0.0-beta.1"
clap_generate = "3.0.0-beta.1"
clap = "=3.0.0-beta.1"
clap_generate = "=3.0.0-beta.1"
serde = { version = "1.0", features = ["rc"] }
serde_derive = "1.0"
serde_json = "1.0"
Expand Down Expand Up @@ -57,7 +57,7 @@ tui = "0.6.0"
termion = "1.5"

[build-dependencies]
ckb-build-info = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-build-info = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }

[workspace]
members = ["ckb-sdk", "ckb-index", "ckb-sdk-types", "plugin-protocol"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ci: fmt clippy test security-audit
git diff --exit-code Cargo.lock

integration:
bash devtools/ci/integration.sh v0.39.0-rc2
bash devtools/ci/integration.sh v0.40.0-rc2

prod: ## Build binary with release profile.
cargo build --release
Expand Down
4 changes: 2 additions & 2 deletions ckb-index/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ckb-index"
version = "0.39.0"
version = "0.40.0"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -11,6 +11,6 @@ serde_derive = "1.0"
bincode = "1.1.4"
log = "0.4.6"
failure = "0.1.5"
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-sdk = { path = "../ckb-sdk" }
rocksdb = { package = "ckb-rocksdb", version = "=0.13.0", features = ["snappy"] }
14 changes: 7 additions & 7 deletions ckb-sdk-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ckb-sdk-types"
version = "0.39.0"
version = "0.40.0"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -9,11 +9,11 @@ license = "MIT"
serde = { version = "1.0", features = ["rc"] }
serde_derive = "1.0"

ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-traits = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-error = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-traits = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-error = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }

[dev-dependencies]
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2", features = ["secp"] }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2", features = ["secp"] }
7 changes: 5 additions & 2 deletions ckb-sdk-types/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,12 @@ impl Resource {
}

impl<'a> HeaderChecker for Resource {
fn check_valid(&self, block_hash: &Byte32) -> Result<(), ckb_error::Error> {
fn check_valid(
&self,
block_hash: &Byte32,
) -> Result<(), ckb_types::core::error::OutPointError> {
if !self.required_headers.contains_key(block_hash) {
return Err(OutPointError::InvalidHeader(block_hash.clone()).into());
return Err(OutPointError::InvalidHeader(block_hash.clone()));
}
Ok(())
}
Expand Down
20 changes: 10 additions & 10 deletions ckb-sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ckb-sdk"
version = "0.39.0"
version = "0.40.0"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -11,11 +11,11 @@ serde_derive = "1.0"
serde_json = "1.0"
bech32 = "0.6.0"
log = "0.4.6"
reqwest = "0.9"
reqwest = { version = "0.11", features = ["json", "blocking"] }
secp256k1 = { version = "0.19", features = ["recovery"] }
faster-hex = "0.4"
fnv = "1.0.3"
aes-ctr = "0.3.0"
aes-ctr = "0.6.0"
scrypt = "0.2.0"
rand = "0.6.5"
tiny-keccak = "1.4"
Expand All @@ -25,11 +25,11 @@ uuid = { version = "0.7.4", features = ["v4"] }
chrono = "0.4.6"
failure = "0.1.5"

ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-error = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-script = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.39.0-rc2", features = ["secp"] }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-error = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-script = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.40.0-rc2", features = ["secp"] }
ckb-sdk-types = { path = "../ckb-sdk-types" }
104 changes: 7 additions & 97 deletions ckb-sdk/src/rpc/client.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use ckb_jsonrpc_types::{
BannedAddr, Block, BlockNumber, BlockReward, BlockTemplate, BlockView, CellOutputWithOutPoint,
CellTransaction, CellWithStatus, ChainInfo, Consensus, EpochNumber, EpochView,
ExtraLoggerConfig, HeaderView, JsonBytes, LiveCell, LocalNode, LockHashIndexState,
MainLoggerConfig, OutPoint, PeerState, RawTxPool, RemoteNode, Script, Timestamp, Transaction,
TransactionProof, TransactionWithStatus, TxPoolInfo, Uint64, Version,
BannedAddr, Block, BlockNumber, BlockReward, BlockTemplate, BlockView, CellWithStatus,
ChainInfo, Consensus, EpochNumber, EpochView, ExtraLoggerConfig, HeaderView, JsonBytes,
LocalNode, MainLoggerConfig, OutPoint, PeerState, RawTxPool, RemoteNode, Script, Timestamp,
Transaction, TransactionProof, TransactionWithStatus, TxPoolInfo, Uint64, Version,
};

use super::types;
Expand All @@ -20,15 +19,15 @@ macro_rules! jsonrpc {
) => (
$(#[$struct_attr])*
pub struct $struct_name {
pub client: reqwest::Client,
pub client: reqwest::blocking::Client,
pub url: reqwest::Url,
pub id: u64,
}

impl $struct_name {
pub fn new(uri: &str) -> Self {
let url = reqwest::Url::parse(uri).expect("ckb uri, e.g. \"http://127.0.0.1:8114\"");
$struct_name { url, id: 0, client: reqwest::Client::new(), }
$struct_name { url, id: 0, client: reqwest::blocking::Client::new(), }
}

$(
Expand All @@ -44,7 +43,7 @@ macro_rules! jsonrpc {
req_json.insert("method".to_owned(), serde_json::json!(method));
req_json.insert("params".to_owned(), params);

let mut resp = $selff.client.post($selff.url.clone()).json(&req_json).send()?;
let resp = $selff.client.post($selff.url.clone()).json(&req_json).send()?;
let output = resp.json::<ckb_jsonrpc_types::response::Output>()?;
match output {
ckb_jsonrpc_types::response::Output::Success(success) => {
Expand All @@ -71,7 +70,6 @@ jsonrpc!(pub struct RawHttpRpcClient {
pub fn get_block_by_number(&mut self, number: BlockNumber) -> Option<BlockView>;
pub fn get_block_hash(&mut self, number: BlockNumber) -> Option<H256>;
pub fn get_cellbase_output_capacity_details(&mut self, hash: H256) -> Option<BlockReward>;
pub fn get_cells_by_lock_hash(&mut self, lock_hash: H256, from: BlockNumber, to: BlockNumber) -> Vec<CellOutputWithOutPoint>;
pub fn get_current_epoch(&mut self) -> EpochView;
pub fn get_epoch_by_number(&mut self, number: EpochNumber) -> Option<EpochView>;
pub fn get_header(&mut self, hash: H256) -> Option<HeaderView>;
Expand All @@ -89,28 +87,6 @@ jsonrpc!(pub struct RawHttpRpcClient {
pub fn get_fork_block(&mut self, block_hash: H256) -> Option<BlockView>;
pub fn get_consensus(&mut self) -> Consensus;

// Indexer
pub fn deindex_lock_hash(&mut self, lock_hash: H256) -> ();
pub fn get_live_cells_by_lock_hash(
&mut self,
lock_hash: H256,
page: Uint64,
per_page: Uint64,
reverse_order: Option<bool>
) -> Vec<LiveCell>;
pub fn get_transactions_by_lock_hash(
&mut self,
lock_hash: H256,
page: Uint64,
per_page: Uint64,
reverse_order: Option<bool>
) -> Vec<CellTransaction>;
pub fn index_lock_hash(
&mut self,
lock_hash: H256,
index_from: Option<BlockNumber>
) -> LockHashIndexState;

// Net
pub fn get_banned_addresses(&mut self) -> Vec<BannedAddr>;
pub fn get_peers(&mut self) -> Vec<RemoteNode>;
Expand Down Expand Up @@ -203,17 +179,6 @@ impl HttpRpcClient {
.map(|opt| opt.map(Into::into))
.map_err(|err| err.to_string())
}
pub fn get_cells_by_lock_hash(
&mut self,
lock_hash: H256,
from: u64,
to: u64,
) -> Result<Vec<types::CellOutputWithOutPoint>, String> {
self.client
.get_cells_by_lock_hash(lock_hash, BlockNumber::from(from), BlockNumber::from(to))
.map(|vec| vec.into_iter().map(Into::into).collect())
.map_err(|err| err.to_string())
}
pub fn get_current_epoch(&mut self) -> Result<types::EpochView, String> {
self.client
.get_current_epoch()
Expand Down Expand Up @@ -303,61 +268,6 @@ impl HttpRpcClient {
.map_err(|err| err.to_string())
}

// Indexer
#[deprecated(since = "0.36.0", note = "Use standalone ckb-indexer")]
pub fn deindex_lock_hash(&mut self, lock_hash: H256) -> Result<(), String> {
self.client
.deindex_lock_hash(lock_hash)
.map_err(|err| err.to_string())
}
#[deprecated(since = "0.36.0", note = "Use standalone ckb-indexer")]
pub fn get_live_cells_by_lock_hash(
&mut self,
lock_hash: H256,
page: u64,
per_page: u64,
reverse_order: Option<bool>,
) -> Result<Vec<types::LiveCell>, String> {
self.client
.get_live_cells_by_lock_hash(
lock_hash,
Uint64::from(page),
Uint64::from(per_page),
reverse_order,
)
.map(|vec| vec.into_iter().map(Into::into).collect())
.map_err(|err| err.to_string())
}
#[deprecated(since = "0.36.0", note = "Use standalone ckb-indexer")]
pub fn get_transactions_by_lock_hash(
&mut self,
lock_hash: H256,
page: u64,
per_page: u64,
reverse_order: Option<bool>,
) -> Result<Vec<types::CellTransaction>, String> {
self.client
.get_transactions_by_lock_hash(
lock_hash,
Uint64::from(page),
Uint64::from(per_page),
reverse_order,
)
.map(|vec| vec.into_iter().map(Into::into).collect())
.map_err(|err| err.to_string())
}
#[deprecated(since = "0.36.0", note = "Use standalone ckb-indexer")]
pub fn index_lock_hash(
&mut self,
lock_hash: H256,
index_from: Option<u64>,
) -> Result<types::LockHashIndexState, String> {
self.client
.index_lock_hash(lock_hash, index_from.map(BlockNumber::from))
.map(Into::into)
.map_err(|err| err.to_string())
}

// Net
pub fn get_banned_addresses(&mut self) -> Result<Vec<types::BannedAddr>, String> {
self.client
Expand Down
9 changes: 4 additions & 5 deletions ckb-sdk/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ pub use client::{HttpRpcClient, RawHttpRpcClient};
pub use primitive::{Capacity, EpochNumberWithFraction, Since, Timestamp};
pub use types::{
Alert, AlertMessage, BannedAddr, Block, BlockReward, BlockView, Byte32, CellDep, CellInput,
CellOutput, CellOutputWithOutPoint, CellTransaction, ChainInfo, DepType, EpochView, Header,
HeaderView, JsonBytes, LiveCell, LocalNode, LockHashIndexState, MerkleProof, NodeAddress,
OutPoint, ProposalShortId, RemoteNode, Script, ScriptHashType, Transaction, TransactionPoint,
TransactionProof, TransactionView, TransactionWithStatus, TxPoolInfo, TxStatus, Uint128,
UncleBlock, UncleBlockView,
CellOutput, ChainInfo, DepType, EpochView, Header, HeaderView, JsonBytes, LocalNode,
MerkleProof, NodeAddress, OutPoint, ProposalShortId, RemoteNode, Script, ScriptHashType,
Transaction, TransactionProof, TransactionView, TransactionWithStatus, TxPoolInfo, TxStatus,
Uint128, UncleBlock, UncleBlockView,
};
Loading

0 comments on commit 46679ec

Please sign in to comment.