Skip to content

Commit

Permalink
chore: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
quake committed Sep 17, 2021
1 parent f4adbbb commit 36c95ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ Connect to default ckb rpc service at `http://127.0.0.1:8114` and stores the ind
RUST_LOG=info ./target/release/ckb-indexer -s /tmp/ckb-indexer-test
```

Or connect to ckb rpc service at `tcp::/127.0.0.1:18114`
Or connect to ckb rpc service at `tcp://127.0.0.1:18114`
```bash
RUST_LOG=info ./target/release/ckb-indexer -s /tmp/ckb-indexer-test -c tcp::/127.0.0.1:18114
RUST_LOG=info ./target/release/ckb-indexer -s /tmp/ckb-indexer-test -c tcp://127.0.0.1:18114
```

Indexing the pending txs in the ckb tx-pool
```bash
RUST_LOG=info ./target/release/ckb-indexer -s /tmp/ckb-indexer-test -c tcp://127.0.0.1:18114 --index-tx-pool
```

Run `ckb-indexer --help` for more information
Expand Down
9 changes: 4 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async fn main() {
.arg(
Arg::with_name("ckb_uri")
.short("c")
.help("CKB rpc service uri, supports http and tcp, for example: `http://127.0.0.1:8114` or `tcp::/127.0.0.1:18114`")
.help("CKB rpc service uri, supports http and tcp, for example: `http://127.0.0.1:8114` or `tcp://127.0.0.1:18114`")
.takes_value(true),
)
.arg(
Expand Down Expand Up @@ -69,8 +69,8 @@ async fn main() {
.unwrap_or("http://127.0.0.1:8114")
.to_owned();

if uri.starts_with("tcp:://") {
let uri = uri.split_off(7);
if uri.starts_with("tcp://") {
let uri = uri.split_off(6);
let codec = StreamCodec::stream_incoming();
let tcp_stream = TcpStream::connect(&uri)
.await
Expand Down Expand Up @@ -189,11 +189,10 @@ async fn main() {
}

service.poll(rpc_channel.into()).await;
} else if !uri.starts_with("http") {
} else {
if index_tx_pool {
error!("indexing the pending txs in the ckb tx-pool is only supported when connecting to ckb rpc service with tcp protocol")
} else {
uri = format!("http://{}", uri);
let client = http::connect(&uri)
.await
.expect(&format!("Failed to connect to {:?}", uri));
Expand Down

0 comments on commit 36c95ad

Please sign in to comment.