Skip to content

Commit

Permalink
Support include tx_pool for get_live_cell
Browse files Browse the repository at this point in the history
Signed-off-by: Eval EXEC <[email protected]>
  • Loading branch information
eval-exec committed Jun 25, 2024
1 parent e38fae7 commit 7fd801c
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 14 deletions.
5 changes: 2 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ckb-util = "=0.116.1"
ckb-error = "=0.116.1"
ckb-script = "=0.116.1"
ckb-chain-spec = "=0.116.1"
ckb-sdk = { version = "=3.2.0", features = ["native-tls-vendored"] }
ckb-sdk = { git="https://github.com/eval-exec/ckb-sdk-rust", branch="exec/support-include-tx-pool", features = ["native-tls-vendored"] }
ckb-mock-tx-types = { version = "=0.116.1" }
ckb-signer = { path = "ckb-signer", version = "0.4.1" }
plugin-protocol = { path = "plugin-protocol", package = "ckb-cli-plugin-protocol", version = "=1.3.1" }
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ci: fmt clippy test security-audit check-crates check-licenses
git diff --exit-code Cargo.lock

integration:
bash devtools/ci/integration.sh v0.116.0-rc2
bash devtools/ci/integration.sh v0.117.0-rc3

prod: ## Build binary with release profile.
cargo build --release
Expand Down
2 changes: 1 addition & 1 deletion ckb-signer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ anyhow = "1.0.63"
ckb-types = "=0.116.1"
ckb-hash = "=0.116.1"
ckb-crypto = { version = "=0.116.1", features = ["secp"] }
ckb-sdk = { version = "=3.2.0", features = ["native-tls-vendored"] }
ckb-sdk = { git="https://github.com/eval-exec/ckb-sdk-rust", branch="exec/support-include-tx-pool", features = ["native-tls-vendored"] }
2 changes: 1 addition & 1 deletion src/subcommands/deploy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ fn load_cell_info(
.index(index.pack())
.build();
let cell_with_status = rpc_client
.get_live_cell(out_point, true)
.get_live_cell(out_point, true, None)
.map_err(Error::msg)?;
if cell_with_status.status != "live" {
return Err(anyhow!(
Expand Down
2 changes: 1 addition & 1 deletion src/subcommands/mock_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ impl<'a> MockResourceLoader for Loader<'a> {
) -> Result<Option<(CellOutput, Bytes, Option<Byte32>)>, String> {
let output: Option<CellOutput> = self
.rpc_client
.get_live_cell(out_point.clone(), true)
.get_live_cell(out_point.clone(), true, None)
.map(|resp| resp.cell.map(|info| info.output.into()))?;
if let Some(output) = output {
Ok(self
Expand Down
12 changes: 10 additions & 2 deletions src/subcommands/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,12 @@ impl<'a> CliSubCommand for RpcSubCommand<'a> {
}
("get_live_cell", Some(m)) => {
let is_raw_data = is_raw_data || m.is_present("raw-data");
let include_tx_pool = if m.is_present("include-tx-pool") {
Some(true)
} else {
None
};

let tx_hash: H256 =
FixedHashParser::<H256>::default().from_matches(m, "tx-hash")?;
let index: u32 = FromStrParser::<u32>::default().from_matches(m, "index")?;
Expand All @@ -657,11 +663,13 @@ impl<'a> CliSubCommand for RpcSubCommand<'a> {
if is_raw_data {
let resp = self
.raw_rpc_client
.get_live_cell(out_point.into(), with_data)
.get_live_cell(out_point.into(), with_data, include_tx_pool)
.map_err(|err| err.to_string())?;
Ok(Output::new_output(resp))
} else {
let resp = self.rpc_client.get_live_cell(out_point, with_data)?;
let resp =
self.rpc_client
.get_live_cell(out_point, with_data, include_tx_pool)?;
Ok(Output::new_output(resp))
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/subcommands/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ message = "0x"
.tx_hash(tx_hash.pack())
.index(index.pack())
.build();
let cell_with_status = self.rpc_client.get_live_cell(out_point, true)?;
let cell_with_status = self.rpc_client.get_live_cell(out_point, true, None)?;
if cell_with_status.status != "live" {
Ok(Output::new_output(cell_with_status))
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/other.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pub fn get_live_cell_internal(
out_point: OutPoint,
with_data: bool,
) -> Result<(CellOutput, Bytes), String> {
let cell = client.get_live_cell(out_point.clone(), with_data)?;
let cell = client.get_live_cell(out_point.clone(), with_data, None)?;
if cell.status != "live" {
return Err(format!(
"Invalid cell status: {}, out_point: {}",
Expand Down
3 changes: 2 additions & 1 deletion src/utils/rpc/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,10 @@ impl HttpRpcClient {
&mut self,
out_point: packed::OutPoint,
with_data: bool,
include_tx_pool: Option<bool>,
) -> Result<CellWithStatus, String> {
self.client
.get_live_cell(out_point.into(), with_data)
.get_live_cell(out_point.into(), with_data, include_tx_pool)
.map_err(|err| err.to_string())
}
pub fn get_tip_block_number(&mut self) -> Result<u64, String> {
Expand Down
2 changes: 1 addition & 1 deletion test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ log = "0.4"
env_logger = "0.6"
toml = "0.5.0"
serde_yaml = "0.8.9"
ckb-sdk = { version = "=3.2.0", features = ["native-tls-vendored"] }
ckb-sdk = { git="https://github.com/eval-exec/ckb-sdk-rust", branch="exec/support-include-tx-pool", features = ["native-tls-vendored"] }
serde_json = "1.0"
ckb-types = "=0.116.1"
ckb-jsonrpc-types = "=0.116.1"
Expand Down

0 comments on commit 7fd801c

Please sign in to comment.