github.com/status-im/status-go@v1.1.0/rtt/README.md (about) 1 # Description 2 3 This module is used by the Status app to select mailservers based on their RTT(Round Trip Time). 4 5 It is exposed via the JSON RPC endpoint in the [`services/mailservers/tcp_ping.go`](../services/mailservers/tcp_ping.go) file. 6 7 # Usage 8 9 The simplest way to use the `mailserver_Ping` RPC command is using `curl`. 10 11 The call takes one struct argument which contains two attributes: 12 13 * `addresses` - A list of `enode` addresses to ping. 14 * `timeoutMs` - Call timeout given in milliseconds. 15 16 The return value consists of a list of objects representing a result for each mailserver, each containing following attributes: 17 18 * `address` - The `enode` address of given mailserver. 19 * `rttMs` - Round Trip Time given in milliseconds. Set to `null` in case of an error.` 20 * `error` - A text of error that caused the ping failure. 21 22 # Example 23 24 ```bash 25 $ cat >payload.json <<EOL 26 { 27 "jsonrpc": "2.0", 28 "method": "mailservers_ping", 29 "params": [ 30 { 31 "addresses": [ 32 "enode://c42f368a23fa98ee546fd247220759062323249ef657d26d357a777443aec04db1b29a3a22ef3e7c548e18493ddaf51a31b0aed6079bd6ebe5ae838fcfaf3a49@206.189.243.162:443", 33 "enode://c42f368a23fa98ee546fd247220759062323249ef657d26d357a777443aec04db1b29a3a22ef3e7c548e18493ddaf51a31b0aed6079bd6ebe5ae838fcfaf3a49@206.189.243.162:999" 34 ], 35 "timeoutMs": 500 36 } 37 ], 38 "id": 1 39 } 40 EOL 41 42 $ curl -s localhost:8545 -H 'content-type: application/json' -d @payload.json 43 ``` 44 ```json 45 { 46 "jsonrpc": "2.0", 47 "id": 1, 48 "result": [ 49 { 50 "address": "enode://c42f368a23fa98ee546fd247220759062323249ef657d26d357a777443aec04db1b29a3a22ef3e7c548e18493ddaf51a31b0aed6079bd6ebe5ae838fcfaf3a49@206.189.243.162:443", 51 "rttMs": 31, 52 "error": null 53 }, 54 { 55 "address": "enode://c42f368a23fa98ee546fd247220759062323249ef657d26d357a777443aec04db1b29a3a22ef3e7c548e18493ddaf51a31b0aed6079bd6ebe5ae838fcfaf3a49@206.189.243.162:999", 56 "rttMs": null, 57 "error": "tcp check timeout: I/O timeout" 58 } 59 ] 60 } 61 ``` 62 63 # Links 64 65 * https://github.com/status-im/status-mobile/issues/9394 66 * https://github.com/status-im/status-go/pull/1672 67 * https://github.com/status-im/tcp-shaker