[][src]Trait grin_api::OwnerRpc

pub trait OwnerRpc: Sync + Send {
    fn get_status(&self) -> Result<Status, ErrorKind>;
fn validate_chain(&self) -> Result<(), ErrorKind>;
fn compact_chain(&self) -> Result<(), ErrorKind>;
fn get_peers(
        &self,
        peer_addr: Option<SocketAddr>
    ) -> Result<Vec<PeerData>, ErrorKind>;
fn get_connected_peers(&self) -> Result<Vec<PeerInfoDisplay>, ErrorKind>;
fn ban_peer(&self, peer_addr: SocketAddr) -> Result<(), ErrorKind>;
fn unban_peer(&self, peer_addr: SocketAddr) -> Result<(), ErrorKind>; }

Public definition used to generate Node jsonrpc api.

  • When running grin with defaults, the V2 api is available at localhost:3413/v2/owner
  • The endpoint only supports POST operations, with the json-rpc request as the body

Required methods

fn get_status(&self) -> Result<Status, ErrorKind>

Networked version of Owner::get_status.

Json rpc example

{
	"jsonrpc": "2.0",
	"method": "get_status",
	"params": [],
	"id": 1
}
{
	"id": 1,
	"jsonrpc": "2.0",
	"result": {
		"Ok": {
		"protocol_version": "2",
		"user_agent": "MW/Grin 2.x.x",
		"connections": "8",
		"tip": {
			"height": 371553,
			"last_block_pushed": "00001d1623db988d7ed10c5b6319360a52f20c89b4710474145806ba0e8455ec",
			"prev_block_to_last": "0000029f51bacee81c49a27b4bc9c6c446e03183867c922890f90bb17108d89f",
			"total_difficulty": 1127628411943045
		},
		"sync_status": "header_sync",
		"sync_info": {
			"current_height": 371553,
			"highest_height": 0
		}
		}
	}
}

fn validate_chain(&self) -> Result<(), ErrorKind>

Networked version of Owner::validate_chain.

Json rpc example

{
	"jsonrpc": "2.0",
	"method": "validate_chain",
	"params": [],
	"id": 1
}
{
	"id": 1,
	"jsonrpc": "2.0",
	"result": {
		"Ok": null
	}
}

fn compact_chain(&self) -> Result<(), ErrorKind>

Networked version of Owner::compact_chain.

Json rpc example

{
	"jsonrpc": "2.0",
	"method": "compact_chain",
	"params": [],
	"id": 1
}
{
	"id": 1,
	"jsonrpc": "2.0",
	"result": {
		"Ok": null
	}
}

fn get_peers(
    &self,
    peer_addr: Option<SocketAddr>
) -> Result<Vec<PeerData>, ErrorKind>

Networked version of Owner::get_peers.

Json rpc example

{
	"jsonrpc": "2.0",
	"method": "get_peers",
	"params": ["70.50.33.130:3414"],
	"id": 1
}
{
	"id": 1,
	"jsonrpc": "2.0",
	"result": {
		"Ok": [
		{
			"addr": "70.50.33.130:3414",
			"ban_reason": "None",
			"capabilities": {
			"bits": 15
			},
			"flags": "Defunct",
			"last_banned": 0,
			"last_connected": 1570129317,
			"user_agent": "MW/Grin 2.0.0"
		}
		]
	}
}

fn get_connected_peers(&self) -> Result<Vec<PeerInfoDisplay>, ErrorKind>

Networked version of Owner::get_connected_peers.

Json rpc example

{
	"jsonrpc": "2.0",
	"method": "get_connected_peers",
	"params": [],
	"id": 1
}
{
	"id": 1,
	"jsonrpc": "2.0",
	"result": {
		"Ok": [
		{
			"addr": "35.176.195.242:3414",
			"capabilities": {
			"bits": 15
			},
			"direction": "Outbound",
			"height": 374510,
			"total_difficulty": 1133954621205750,
			"user_agent": "MW/Grin 2.0.0",
			"version": 1
		},
		{
			"addr": "47.97.198.21:3414",
			"capabilities": {
			"bits": 15
			},
			"direction": "Outbound",
			"height": 374510,
			"total_difficulty": 1133954621205750,
			"user_agent": "MW/Grin 2.0.0",
			"version": 1
		},
		{
			"addr": "148.251.16.13:3414",
			"capabilities": {
			"bits": 15
			},
			"direction": "Outbound",
			"height": 374510,
			"total_difficulty": 1133954621205750,
			"user_agent": "MW/Grin 2.0.0",
			"version": 1
		},
		{
			"addr": "68.195.18.155:3414",
			"capabilities": {
			"bits": 15
			},
			"direction": "Outbound",
			"height": 374510,
			"total_difficulty": 1133954621205750,
			"user_agent": "MW/Grin 2.0.0",
			"version": 1
		},
		{
			"addr": "52.53.221.15:3414",
			"capabilities": {
			"bits": 15
			},
			"direction": "Outbound",
			"height": 0,
			"total_difficulty": 1133954621205750,
			"user_agent": "MW/Grin 2.0.0",
			"version": 1
		},
		{
			"addr": "109.74.202.16:3414",
			"capabilities": {
			"bits": 15
			},
			"direction": "Outbound",
			"height": 374510,
			"total_difficulty": 1133954621205750,
			"user_agent": "MW/Grin 2.0.0",
			"version": 1
		},
		{
			"addr": "121.43.183.180:3414",
			"capabilities": {
			"bits": 15
			},
			"direction": "Outbound",
			"height": 374510,
			"total_difficulty": 1133954621205750,
			"user_agent": "MW/Grin 2.0.0",
			"version": 1
		},
		{
			"addr": "35.157.247.209:23414",
			"capabilities": {
			"bits": 15
			},
			"direction": "Outbound",
			"height": 374510,
			"total_difficulty": 1133954621205750,
			"user_agent": "MW/Grin 2.0.0",
			"version": 1
		}
		]
	}
}

fn ban_peer(&self, peer_addr: SocketAddr) -> Result<(), ErrorKind>

Networked version of Owner::ban_peer.

Json rpc example

{
	"jsonrpc": "2.0",
	"method": "ban_peer",
	"params": ["70.50.33.130:3414"],
	"id": 1
}
{
	"id": 1,
	"jsonrpc": "2.0",
	"result": {
		"Ok": null
	}
}

fn unban_peer(&self, peer_addr: SocketAddr) -> Result<(), ErrorKind>

Networked version of Owner::unban_peer.

Json rpc example

{
	"jsonrpc": "2.0",
	"method": "unban_peer",
	"params": ["70.50.33.130:3414"],
	"id": 1
}
{
	"id": 1,
	"jsonrpc": "2.0",
	"result": {
		"Ok": null
	}
}
Loading content...

Trait Implementations

impl Handler for dyn OwnerRpc[src]

Implementors

Loading content...