Skip to content

Commit 56bbdf3

Browse files
authored
Merge 4485e8f into ce8ab15
2 parents ce8ab15 + 4485e8f commit 56bbdf3

28 files changed

+392
-824
lines changed

Cargo.lock

Lines changed: 59 additions & 214 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/indexer/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ starcoin-types = {path= "../../types" }
2020
starcoin-rpc-client = { path= "../../rpc/client" }
2121
starcoin-rpc-api = {path = "../../rpc/api" }
2222
starcoin-logger = {path = "../../commons/logger"}
23-
jsonrpc-core-client="~15"
23+
jsonrpc-core-client="~17"
2424
tokio={version="0.2", features=["full"]}
2525
tokio-compat = "0.1.6"
2626
futures-util = "~0.3"

cmd/indexer/src/block_client.rs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::{BlockData, TransactionData};
22
use anyhow::Result;
3-
use futures_util::compat::Future01CompatExt;
43
use jsonrpc_core_client::RpcError;
54
use starcoin_rpc_api::chain::ChainClient;
65
use starcoin_rpc_api::types::{
@@ -19,21 +18,15 @@ impl BlockClient {
1918
}
2019
}
2120
pub async fn get_block_whole_by_height(&self, height: u64) -> Result<BlockData, RpcError> {
22-
let block: Option<BlockView> = self
23-
.node_client
24-
.get_block_by_number(height)
25-
.compat()
26-
.await?;
21+
let block: Option<BlockView> = self.node_client.get_block_by_number(height).await?;
2722
let block = block.ok_or_else(|| {
28-
RpcError::Other(failure::err_msg(format!(
29-
"cannot find block of height {}",
30-
height
31-
)))
23+
RpcError::Other(Box::new(
24+
failure::err_msg(format!("cannot find block of height {}", height)).compat(),
25+
))
3226
})?;
3327
let mut txn_infos: Vec<TransactionInfoView> = self
3428
.node_client
3529
.get_block_txn_infos(block.header.block_hash)
36-
.compat()
3730
.await?;
3831
let mut txns_data = vec![];
3932

@@ -42,19 +35,20 @@ impl BlockClient {
4235
let txn: Option<TransactionView> = self
4336
.node_client
4437
.get_transaction(txn_info.transaction_hash)
45-
.compat()
4638
.await?;
4739
let txn = txn.ok_or_else(|| {
48-
RpcError::Other(failure::err_msg(format!(
49-
"cannot find txn with id {}",
50-
txn_info.transaction_hash
51-
)))
40+
RpcError::Other(Box::new(
41+
failure::err_msg(format!(
42+
"cannot find txn with id {}",
43+
txn_info.transaction_hash
44+
))
45+
.compat(),
46+
))
5247
})?;
5348

5449
let events: Vec<TransactionEventView> = self
5550
.node_client
5651
.get_events_by_txn_hash(txn_info.transaction_hash)
57-
.compat()
5852
.await?;
5953
txns_data.push(TransactionData {
6054
info: txn_info,
@@ -71,7 +65,7 @@ impl BlockClient {
7165
let fetch_events_tasks = txn_infos
7266
.iter()
7367
.map(|txn_info| txn_info.transaction_hash)
74-
.map(|txn_hash| self.node_client.get_events_by_txn_hash(txn_hash).compat());
68+
.map(|txn_hash| self.node_client.get_events_by_txn_hash(txn_hash));
7569

7670
let events = futures_util::future::try_join_all(fetch_events_tasks).await?;
7771

@@ -89,7 +83,7 @@ impl BlockClient {
8983
Ok(BlockData { block, txns_data })
9084
}
9185
pub async fn get_chain_head(&self) -> Result<BlockHeaderView, RpcError> {
92-
let chain_info: ChainInfoView = self.node_client.info().compat().await?;
86+
let chain_info: ChainInfoView = self.node_client.info().await?;
9387
Ok(chain_info.head)
9488
}
9589
}

cmd/indexer/src/main.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
use anyhow::Result;
1+
use anyhow::{anyhow, Result};
22
use clap::Clap;
33
use elasticsearch::auth::Credentials;
44
use elasticsearch::http::transport::SingleNodeConnectionPool;
55
use elasticsearch::http::Url;
66
use elasticsearch::Elasticsearch;
7-
use failure::Fail;
87
use futures_retry::{FutureRetry, RetryPolicy};
98
use futures_util::TryFutureExt;
109
use jsonrpc_core_client::transports::http;
1110
use starcoin_indexer::{BlockClient, BlockData, EsSinker, IndexConfig};
1211
use starcoin_logger::prelude::*;
1312
use starcoin_rpc_api::chain::ChainClient;
1413
use std::time::Duration;
15-
use tokio_compat::runtime;
14+
use tokio::runtime;
1615

1716
#[derive(Clap, Debug, Clone)]
1817
#[clap(version = "0.1.0", author = "Starcoin Core Dev <dev@starcoin.org>")]
@@ -38,7 +37,7 @@ async fn start_loop(block_client: BlockClient, sinker: EsSinker) -> Result<()> {
3837

3938
loop {
4039
let remote_tip_header = FutureRetry::new(
41-
|| block_client.get_chain_head().map_err(|e| e.compat()),
40+
|| block_client.get_chain_head().map_err(|e| e),
4241
|e| {
4342
warn!("[Retry]: get chain head, err: {}", &e);
4443
RetryPolicy::<anyhow::Error>::WaitRetry(Duration::from_secs(1))
@@ -68,9 +67,8 @@ async fn start_loop(block_client: BlockClient, sinker: EsSinker) -> Result<()> {
6867
} else {
6968
let next_block: BlockData = FutureRetry::new(
7069
|| {
71-
block_client
72-
.get_block_whole_by_height(next_block_number)
73-
.map_err(|e| e.compat())
70+
block_client.get_block_whole_by_height(next_block_number)
71+
//.map_err(|e| e.compat())
7472
},
7573
|e| {
7674
warn!("[Retry]: get chain block data, err: {}", &e);
@@ -125,11 +123,13 @@ fn main() -> anyhow::Result<()> {
125123
let opts: Options = Options::parse();
126124
info!("opts: {:?}", &opts);
127125
let mut rt = runtime::Builder::new()
128-
.name_prefix("starcoin-indexer")
126+
.thread_name("starcoin-indexer")
127+
.threaded_scheduler()
128+
.enable_all()
129129
.build()?;
130130
let channel: ChainClient = rt
131131
.block_on(http::connect(opts.node_url.as_str()))
132-
.map_err(|e| e.compat())?;
132+
.map_err(|e| anyhow!(format!("{}", e)))?;
133133
let block_client = BlockClient::new(channel);
134134
let mut transport = elasticsearch::http::transport::TransportBuilder::new(
135135
SingleNodeConnectionPool::new(opts.es_url),
@@ -145,7 +145,7 @@ fn main() -> anyhow::Result<()> {
145145
let index_config = IndexConfig::new_with_prefix(opts.es_index_prefix.as_str());
146146
let sinker = EsSinker::new(es, index_config);
147147

148-
rt.block_on_std(start_loop(block_client, sinker))?;
148+
rt.block_on(start_loop(block_client, sinker))?;
149149

150150
Ok(())
151151
}

cmd/miner_client/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ tokio = { version = "0.2", features = ["full"] }
1818
logger = { path = "../../commons/logger", package = "starcoin-logger" }
1919
futures-channel = "0.3"
2020
crypto = { package = "starcoin-crypto", path = "../../commons/crypto" }
21-
jsonrpc-core = { version = "15.1.0", features = ["arbitrary_precision"] }
22-
jsonrpc-tcp-server = "15.1.0"
21+
jsonrpc-core = { version = "17.0.0", features = ["arbitrary_precision"] }
22+
jsonrpc-tcp-server = "17.0.0"
2323
serde_json = { version = "1.0", features = ["arbitrary_precision"] }
2424
serde = { version = "1.0", features = ["derive"] }
2525
rust-argon2 = "0.8"

rpc/api/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ hex = "0.4.2"
1515
async-trait = "0.1"
1616
actix = "0.10.0"
1717
actix-rt = "1.1"
18-
jsonrpc-core = { version = "15.1.0", features = ["arbitrary_precision"] }
19-
jsonrpc-derive = "15.1.0"
20-
jsonrpc-server-utils = "15.1.0"
21-
jsonrpc-pubsub = "15.1.0"
22-
jsonrpc-core-client = { version = "15.1.0", features = ["http", "ipc", "ws", "arbitrary_precision"]}
18+
jsonrpc-core = { version = "17.0.0", features = ["arbitrary_precision"] }
19+
jsonrpc-derive = "17.0.0"
20+
jsonrpc-server-utils = "17.0.0"
21+
jsonrpc-pubsub = "17.0.0"
22+
jsonrpc-core-client = { version = "17.0.0", features = ["http", "ipc", "ws", "arbitrary_precision"]}
2323
futures = { version = "0.3", features = ["compat"] }
2424
scs = { package="starcoin-canonical-serialization", path = "../../commons/scs"}
2525
starcoin-rpc-middleware = { path = "../middleware" }

rpc/api/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// Copyright (c) The Starcoin Core Contributors
22
// SPDX-License-Identifier: Apache-2
33

4-
use jsonrpc_core::Error;
4+
use jsonrpc_core::{BoxFuture, Error};
55

6-
pub type FutureResult<T> = Box<dyn jsonrpc_core::futures::Future<Item = T, Error = Error> + Send>;
6+
pub type FutureResult<T> = BoxFuture<Result<T, Error>>;
7+
//pub type FutureResult<T> = Pin<Box<dyn futures::Future<Output = Result<T, Error>> + Send>>;
78

89
pub mod account;
910
pub mod chain;

rpc/client/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ actix-rt = "1.1"
2222
tokio = "0.2"
2323
log = "0.4.13"
2424
parking_lot = "0.11.1"
25-
jsonrpc-core = { version = "15.1.0", features = ["arbitrary_precision"] }
26-
jsonrpc-derive = "15.1.0"
27-
jsonrpc-server-utils = "15.1.0"
28-
jsonrpc-pubsub = "15.1.0"
29-
jsonrpc-core-client = { version = "15.1.0", features = ["http", "ipc", "ws", "arbitrary_precision"]}
30-
jsonrpc-client-transports = { version = "15.1.0", features = ["http", "ipc", "ws", "arbitrary_precision"] }
25+
jsonrpc-core = { version = "17.0.0", features = ["arbitrary_precision"] }
26+
jsonrpc-derive = "17.0.0"
27+
jsonrpc-server-utils = "17.0.0"
28+
jsonrpc-pubsub = "17.0.0"
29+
jsonrpc-core-client = { version = "17.0.0", features = ["http", "ipc", "ws", "arbitrary_precision"]}
30+
jsonrpc-client-transports = { version = "17.0.0", features = ["http", "ipc", "ws", "arbitrary_precision"] }
3131
futures03 = { package="futures",version = "0.3", features = ["compat"] }
3232
futures = "0.1.29"
3333
parity-tokio-ipc = { version = "0.2"}

rpc/client/src/chain_watcher.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::pubsub_client::PubSubClient;
55
use actix::prelude::*;
66
use actix::AsyncContext;
77
use futures03::channel::oneshot;
8-
use futures03::compat::Stream01CompatExt;
98
use jsonrpc_core_client::RpcError;
109
use serde::{Deserialize, Serialize};
1110
use starcoin_crypto::HashValue;
@@ -54,7 +53,7 @@ impl ChainWatcher {
5453
.then(|res, act, ctx| {
5554
match res {
5655
Ok(s) => {
57-
ctx.add_stream(s.compat());
56+
ctx.add_stream(s);
5857
}
5958
Err(e) => {
6059
// TODO: figure out why this error cannot printed.

0 commit comments

Comments
 (0)