conflux-rust
conflux-rust copied to clipboard
Rpc to check node status, and related errors.
Let's say, the full node are disconnected from the Conflux network, after a while, it should not serve blockchain related rpc any more.
Possible unhealthy status can be:
NOT_CATCHED_UP NO_TRUSTED_PEERS NO_PEERS PIVOT_CHAIN_UNSTABLE SUSPICIOUS_MINING_RATE SUSPICIOUS_PIVOT_TIMESTAMP ... (the list can go on)
For each related rpc call, we should at first check the system status to determine whether we can continue to serve the rpc under each condition.
For light node, since it has to forward queries to other peers / resend the request if it times out or if the peer replied malicious result. For each retry, the light node should check its status again.
Note that this status rpc is different from start phase, because unhealthy status can occur at any phase.
Here are some useful but missing rpc functions implemented in Parity https://wiki.parity.io/JSONRPC-parity-module#network-information
We should consider add some of them.
We also need an rpc to let client know the rpc protocol version. I think the status() rpc call is a good place.