Trait snarkos_rpc::RpcFunctions [−][src]
pub trait RpcFunctions {
Show 15 methods
fn get_block<'life0, 'async_trait>(
&'life0 self,
block_hash_string: String
) -> Pin<Box<dyn Future<Output = Result<BlockInfo, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_block_count<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<u32, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_best_block_hash<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<String, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_block_hash<'life0, 'async_trait>(
&'life0 self,
block_height: u32
) -> Pin<Box<dyn Future<Output = Result<String, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_raw_transaction<'life0, 'async_trait>(
&'life0 self,
transaction_id: String
) -> Pin<Box<dyn Future<Output = Result<String, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_transaction_info<'life0, 'async_trait>(
&'life0 self,
transaction_id: String
) -> Pin<Box<dyn Future<Output = Result<TransactionInfo, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn decode_raw_transaction<'life0, 'async_trait>(
&'life0 self,
transaction_bytes: String
) -> Pin<Box<dyn Future<Output = Result<TransactionInfo, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn send_raw_transaction<'life0, 'async_trait>(
&'life0 self,
transaction_bytes: String
) -> Pin<Box<dyn Future<Output = Result<String, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn validate_raw_transaction<'life0, 'async_trait>(
&'life0 self,
transaction_bytes: String
) -> Pin<Box<dyn Future<Output = Result<bool, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_connection_count<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<usize, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_peer_info<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<PeerInfo, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_node_info<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<NodeInfo, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_node_stats<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<NodeStats, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_block_template<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<BlockTemplate, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_network_graph<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<NetworkGraph, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
}
Expand description
Definition of public RPC endpoints.
Required methods
Returns information about a block from a block hash.
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
block_hash | string | Yes | The block hash of the requested block |
Response
Parameter | Type | Description |
---|---|---|
confirmations | number | The number of confirmations for this block |
difficulty_target | number | The difficulty of the block |
hash | string | The block hash (same as provided) |
height | number | The block height |
merkle_root | number | The Merkle root of the transactions in the block |
nonce | number | The nonce for solving the PoSW puzzle |
pedersen_merkle_root_hash | number | The Merkle root of the transactions in the block using a Pedersen hash |
previous_block_hash | string | The block hash of the parent block |
proof | string | The Proof of Succinct Work |
size | number | The size of the block in bytes |
time | number | The block time |
transactions | array | The list of transaction ids included in the block |
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getblock", "params": ["caf49293d36f0215cfb3296dbc871a0ef5e5dcfc61f91cd0c9ac2c730f84d853"] }' -H 'content-type: application/json' http://127.0.0.1:3030/
Returns the number of blocks in the best valid chain.
Arguments
None
Response
Parameter | Type | Description |
---|---|---|
result | number | The number of blocks in the best valid chain |
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getblockcount", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/
Returns the block hash of the head of the best valid chain.
Arguments
None
Response
Parameter | Type | Description |
---|---|---|
result | string | The block hash of the most recent valid block |
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getbestblockhash", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/
Returns the block hash of a block at the given block height in the best valid chain.
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
block_height | number | Yes | The block height of the requested block hash |
Response
Parameter | Type | Description |
---|---|---|
result | string | The block hash of the block at the given block height |
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getblockhash", "params": [100] }' -H 'content-type: application/json' http://127.0.0.1:3030/
Returns hex encoded bytes of a transaction from its transaction id.
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
transaction_id | string | Yes | The transaction id of the requested transaction hex |
Response
Parameter | Type | Description |
---|---|---|
result | string | The hex-encoded transaction bytes |
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getrawtransaction", "params": ["83fc73b8a104d7cdabe514ec4ddfeb7fd6284ff8e0a757d25d8479ed0ffe608b"] }' -H 'content-type: application/json' http://127.0.0.1:3030/
fn get_transaction_info<'life0, 'async_trait>(
&'life0 self,
transaction_id: String
) -> Pin<Box<dyn Future<Output = Result<TransactionInfo, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn get_transaction_info<'life0, 'async_trait>(
&'life0 self,
transaction_id: String
) -> Pin<Box<dyn Future<Output = Result<TransactionInfo, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Returns information about a transaction from a transaction id.
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
transaction_id | string | Yes | The transaction id of the requested transaction info |
Response
Parameter | Type | Description |
---|---|---|
txid | string | The transaction id |
size | number | The size of the transaction in bytes |
old_serial_numbers | array | The list of old record serial numbers |
new_commitments | array | The list of new record commitments |
memo | string | The transaction memo |
network_id | number | The transaction network id |
digest | string | The merkle tree digest |
transaction_proof | string | The transaction zero knowledge proof |
program_commitment | string | The program verification key commitment |
local_data_root | string | The local data root |
value_balance | number | The transaction value balance |
signatures | array | The list of transaction signatures |
encrypted_records | array | The list of new encrypted records |
transaction_metadata | object | The transaction metadata |
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "gettransactioninfo", "params": ["83fc73b8a104d7cdabe514ec4ddfeb7fd6284ff8e0a757d25d8479ed0ffe608b"] }' -H 'content-type: application/json' http://127.0.0.1:3030/
fn decode_raw_transaction<'life0, 'async_trait>(
&'life0 self,
transaction_bytes: String
) -> Pin<Box<dyn Future<Output = Result<TransactionInfo, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn decode_raw_transaction<'life0, 'async_trait>(
&'life0 self,
transaction_bytes: String
) -> Pin<Box<dyn Future<Output = Result<TransactionInfo, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Returns information about a transaction from serialized transaction bytes.
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
transaction_bytes | string | Yes | The raw transaction hex to decode |
Response
Parameter | Type | Description |
---|---|---|
txid | string | The transaction id |
size | number | The size of the transaction in bytes |
old_serial_numbers | array | The list of old record serial numbers |
new_commitments | array | The list of new record commitments |
memo | string | The transaction memo |
network_id | number | The transaction network id |
digest | string | The merkle tree digest |
transaction_proof | string | The transaction zero knowledge proof |
program_commitment | string | The program verification key commitment |
local_data_root | string | The local data root |
value_balance | number | The transaction value balance |
signatures | array | The list of transaction signatures |
encrypted_records | array | The list of new encrypted records |
transaction_metadata | object | The transaction metadata |
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "decoderawtransaction", "params": ["transaction_hexstring"] }' -H 'content-type: application/json' http://127.0.0.1:3030/
Send raw transaction bytes to this node to be added into the mempool. If valid, the transaction will be stored and propagated to all peers.
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
transaction_bytes | string | Yes | The raw transaction hex to broadcast |
Response
Parameter | Type | Description |
---|---|---|
result | string | The transaction id of the sent transaction |
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "sendtransaction", "params": ["transaction_hexstring"] }' -H 'content-type: application/json' http://127.0.0.1:3030/
Validate and return if the transaction is valid.
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
transaction_bytes | string | Yes | The raw transaction hex to validate |
Response
Parameter | Type | Description |
---|---|---|
result | boolean | Check that the transaction is valid |
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "validaterawtransaction", "params": ["transaction_hexstring"] }' -H 'content-type: application/json' http://127.0.0.1:3030/
Returns the number of connected peers this node has.
Arguments
None
Response
Parameter | Type | Description |
---|---|---|
result | number | The number of connected nodes |
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getconnectioncount", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/
Returns information about the node.
Arguments
None
Response
Parameter | Type | Description |
---|---|---|
node_type | NodeType | Flag indicating the node type |
is_miner | bool | Flag indicating if the node is a miner |
is_syncing | bool | Flag indicating if the node currently syncing |
launched | timestamp | The timestamp of when the node was launched |
listening_addr | SocketAddr | The configured listening address of the node |
version | string | The version of the client binary |
min_peers | number | The minimum desired number of connected peers |
max_peers | number | The maximum allowed number of connected peers |
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getnodeinfo", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/
Returns statistics related to the node.
Arguments
None
Response
Parameter | Type | Description |
---|---|---|
blocks.height | u32 | The current block height of the node |
blocks.mined | u32 | The number of blocks the node has mined |
blocks.inbound_processing_time | f64 | The average processing time of an inbound block in seconds |
blocks.commit_time | f64 | The block verification and commit time in seconds |
blocks.duplicates | u64 | The number of duplicate blocks received |
blocks.duplicates_sync | u64 | The number of duplicate sync blocks received |
connections.all_accepted | u64 | The number of connection requests the node has received |
connections.all_initiated | u64 | The number of connection requests the node has made |
connections.all_rejected | u64 | The number of connection requests the node has rejected |
connections.average_duration | f64 | The average connection duration in seconds |
connections.connected_peers | u32 | The number of currently connected peers |
connections.connecting_peers | u32 | The number of currently connecting peers |
connections.disconnected_peers | u32 | The number of known disconnected peers |
handshakes.failures_init | u64 | The number of failed handshakes as the initiator |
handshakes.failures_resp | u64 | The number of failed handshakes as the responder |
handshakes.successes_init | u64 | The number of successful handshakes as the initiator |
handshakes.successes_resp | u64 | The number of successful handshakes as the responder |
handshakes.timeouts_init | u64 | The number of handshake timeouts as the initiator |
handshakes.timeouts_resp | u64 | The number of handshake timeouts as the responder |
inbound.all_successes | u64 | The number of successfully processed inbound messages |
inbound.all_failures | u64 | The number of inbound messages that couldn’t be processed |
inbound.blocks | u64 | The number of all received Block messages |
inbound.getblocks | u64 | The number of all received GetBlocks messages |
inbound.getmemorypool | u64 | The number of all received GetMemoryPool messages |
inbound.getpeers | u64 | The number of all received GetPeers messages |
inbound.getsync | u64 | The number of all received GetSync messages |
inbound.memorypool | u64 | The number of all received MemoryPool messages |
inbound.peers | u64 | The number of all received Peers messages |
inbound.pings | u64 | The number of all received Ping messages |
inbound.pongs | u64 | The number of all received Pong messages |
inbound.syncs | u64 | The number of all received Sync messages |
inbound.syncblocks | u64 | The number of all received SyncBlock messages |
inbound.transactions | u64 | The number of all received Transaction messages |
inbound.unknown | u64 | The number of all received Unknown messages |
internal_rtt.getpeer | f64 | The average internal RTT (query to response) for GetPeer messages in seconds |
internal_rtt.getsync | f64 | The average internal RTT for GetSync messages in seconds |
internal_rtt.getblocks | f64 | The average internal RTT for GetBlocks messages in seconds |
internal_rtt.getmemorypool | f64 | The average internal RTT for GetMemoryPool messages in seconds |
misc.rpc_requests | f64 | The number of RPC requests received by the node |
outbound.all_successes | u64 | The number of successfully sent messages |
outbound.all_failures | u64 | The number of failures to send messages |
queues.consensus | u64 | The number of queued consensus requests |
queues.inbound | u64 | The number of messages queued in the common inbound channel |
queues.outbound | u64 | The number of messages queued in the individual outbound channels |
queues.peer_events | u64 | The number of queued peer events |
queues.storage | u64 | The number of queued storage requests |
queues.sync_items | u64 | The number of queued sync items |
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getnodestats", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/
fn get_block_template<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<BlockTemplate, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn get_block_template<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<BlockTemplate, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Returns the current mempool and consensus information known by this node.
Arguments
None
Response
Parameter | Type | Description |
---|---|---|
previous_block_hash | string | The hash of current highest block |
block_height | number | The height of the next block |
time | number | The current timestamp |
difficulty_target | number | The block difficulty target |
transactions | array | The list of raw transactions to include in the block |
coinbase_value | number | The amount spendable by the coinbase transaction |
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getblocktemplate", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/
fn get_network_graph<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<NetworkGraph, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn get_network_graph<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<NetworkGraph, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Returns the network graph crawled by this node (if it is a crawler).
Arguments
None
Response
Parameter | Type | Description |
---|---|---|
node_count | usize | The number of nodes known by the node |
connection_count | usize | The number of connection known by the node |
density | f64 | The density of the known network |
algebraic_connectivity | f64 | The algebraic connectivity, aka the fiedler eigenvalue of the known network |
degree_centrality_delta | f64 | The difference between the largest and the smallest peer count in the network |
potential_tip | Option | The crawler’s best guess at the canon block height and member addresses |
potential_forks | array | The crawler’s best guess at the forks in the network |
edges | array | The list of connections known by the node |
vertices | array | The list of nodes known by the node |
edges[i].source | SocketAddr | One side of the crawled connection |
edges[i].target | SocketAddr | The other side of the crawled connection |
vertices[i].addr | SocketAddr | The recorded address of the crawled node |
vertices[i].is_beacon | bool | Indicates whether the node is a beacon |
vertices[i].is_sync_provider | bool | Indicates whether the node is a sync provider |
vertices[i].degree_centrality | u16 | The node’s degree centrality, aka its connection count |
vertices[i].eigenvector_centrality | f64 | The node’s eigenvector centrality, indicates its relative importance in the network |
vertices[i].fiedler_value | f64 | The node’s fiedler value, can be used to partition the network graph |
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getnetworkgraph", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/