Skip to content

Commit

Permalink
Merge #3028
Browse files Browse the repository at this point in the history
3028: refactor(rpc): change 'connected_duration' duration unit to milliseconds r=chanhsu001 a=chanhsu001

<!--
Thank you for contributing to nervosnetwork/ckb!

If you haven't already, please read [CONTRIBUTING](https://github.com/nervosnetwork/ckb/blob/develop/CONTRIBUTING.md) document.

If you're unsure about anything, just ask; somebody should be along to answer within a day or two.

PR Title Format:
1. module [, module2, module3]: what's changed
2. *: what's changed
-->

### What problem does this PR solve?

make duration unit consistent in `get_peers` RPC 

Problem Summary:

### What is changed and how it works?

Proposal: in 'get_peer' RPC, connected_duration uses secs but last_ping_duration uses millis,  we need to change connected_duration uses millis.

What's Changed: 

### Related changes

- PR to update `owner/repo`:
- Need to cherry-pick to the release branch

### Check List <!--REMOVE the items that are not applicable-->

Tests <!-- At least one of them must be included. -->

- Unit test

Side effects

- rpc client should change 'connected_duration' duration unit from 'second' to 'millisecond' when `get_peers` RPC is used.

### Release note <!-- Choose from None, Title Only and Note. Bugfixes or new features need a release note. -->

```release-note
**BREAKING RPC**. Change field `connected_duration` time unit from seconds to **milliseconds** in `get_peers` RPC to make time unit  used  consistently in `get_peers` , RPC clients are suggested to modify time quantity correspond with this change.
```


Co-authored-by: chanhsu001 <[email protected]>
  • Loading branch information
bors[bot] and chanhsu001 authored Sep 14, 2021
2 parents a3395fe + 29db346 commit d0ad674
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4082,7 +4082,7 @@ A remote node connects to the local node via the P2P network. It is often called

If the connection is established by the local node, `is_outbound` is true.

* `connected_duration`: [`Uint64`](#type-uint64) - Elapsed time in seconds since the remote node is connected.
* `connected_duration`: [`Uint64`](#type-uint64) - Elapsed time in milliseconds since the remote node is connected.

* `last_ping_duration`: [`Uint64`](#type-uint64) `|` `null` - Elapsed time in milliseconds since receiving the ping response from this remote node.

Expand Down
2 changes: 1 addition & 1 deletion rpc/src/module/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ impl NetRpc for NetRpcImpl {
.map(|peer_id| peer_id.to_base58())
.unwrap_or_default(),
addresses: node_addresses,
connected_duration: peer.connected_time.elapsed().as_secs().into(),
connected_duration: (peer.connected_time.elapsed().as_millis() as u64).into(),
last_ping_duration: peer
.ping_rtt
.map(|duration| (duration.as_millis() as u64).into()),
Expand Down
2 changes: 1 addition & 1 deletion util/jsonrpc-types/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub struct RemoteNode {
///
/// If the connection is established by the local node, `is_outbound` is true.
pub is_outbound: bool,
/// Elapsed time in seconds since the remote node is connected.
/// Elapsed time in milliseconds since the remote node is connected.
pub connected_duration: Uint64,
/// Elapsed time in milliseconds since receiving the ping response from this remote node.
///
Expand Down

0 comments on commit d0ad674

Please sign in to comment.