# sharding-p2p-poc CLI
CLI(Command line interface) for [sharding-p2p-poc](https://github.com/ethresearch/sharding-p2p-poc). Behind the CLI are RPC calls to the existing running node. Results are printed to `stdout` in the JSON format. If errors occur, the `returncode` will be set non-zero.
Template
```
./sharding-p2p-poc -client -rpcport={rpcport} {method_name} {params}
# if -rpcport is not specified, this will connect you to the default rpcport
```
Identify: get the peer ID and the listening multiaddress
```
$ ./sharding-p2p-poc -client identify
```
Add a peer
```
# addpeer {ip} {port} {node_seed}
$ ./sharding-p2p-poc -client addpeer 127.0.0.1 10001 1 # node adds the node 1 who listens to 127.0.0.1:10001 as peer
```
Remove a peer
```
# removepeer {peer_id}
$ ./sharding-p2p-poc -client removepeer Qmd8vXqRiFVkcXcB1nigjCDuUyHcFkja6fQcU9w2zMzwwi # node removes the peer whose peer ID is Qmd8vXqRiFVkcXcB1nigjCDuUyHcFkja6fQcU9w2zMzwwi
```
Subscribe shards
```
# subshard {numShardPeerToConnect} {shard_id} {shard_id} ...
$ ./sharding-p2p-poc -client subshard 1 42 87 # node subscribes to shards 42 87, and discovers 1 peer in each shard
```
Unsubscribe shards
```
# unsubshard {shard_id} {shard_id} ...
$ ./sharding-p2p-poc -client unsubshard 1 42 87 # node unsubscribes shards 0, 42, 87
```
Get subscribed shards
```
# getsubshard
$ ./sharding-p2p-poc -client getsubshard # list the shards subscribed by node 0
```
Broadcast collation
```
# broadcastcollation {shard_id} {num_collations} {collation_size} {time_in_ms}
$ ./sharding-p2p-poc -client broadcastcollation 0 1 1000 100 # broadcasts 1 1kb collation in shard 0 every 100ms
```
Discover peers in the shards
```
# discovershard {shard_id} {shard_id} ...
$ ./sharding-p2p-poc -client discovershard 32 42 87 # node discovers peers in shards 32, 42, 87
```
Stop the server
```
# stop
$ ./sharding-p2p-poc -client stop
```
List the peers with connections
```
# listpeer
$ ./sharding-p2p-poc -client listpeer
```
List the peers subscribing to the topics. If no topic specified, list the peers in all topics.
```
# listtopicpeer {topic} {topic} ...
$ ./sharding-p2p-poc -client listtopicpeer shardCollations_0 # list the peers subscribing to the topic `shardCollations_0`
$ ./sharding-p2p-poc -client listtopicpeer # list the peers in all topics
```
List the peers subscribing to the shards. If no shard specified, list all shards.
```
# listshardpeer {shard_id} {shard_id} ...
$ ./sharding-p2p-poc -client listshardpeer 0 1 2 # list the peers subscribing in shards 0 1 2
$ ./sharding-p2p-poc -client listshardpeer # list the peers in all shards
```
Start/Stop the bootstrapping process
```
# bootstrap start/stop
$ ./sharding-p2p-poc -client bootstrap start # start the bootstrapping process
$ ./sharding-p2p-poc -client bootstrap stop # stop the bootstrapping process
```
### More example
Check out [cli-example](https://github.com/ethresearch/sharding-p2p-poc/tree/master/cli-example)