p2p api provides methods for interacting with Kona’s P2P stack.
Peer Information Methods
opp2p_self
Returns information about the local node in the form of PeerInfo.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_self"} |
Example
opp2p_peerCount
Returns the count of connected peers for both discovery and gossip networks.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_peerCount"} |
Example
opp2p_peers
Returns information about peers. If connected parameter is true, only returns connected peers.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_peers", "params": [connected]} |
Parameters
connected(boolean): If true, only returns connected peers
Example
opp2p_peerStats
Returns statistical information about peers including connection counts and topic subscriptions.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_peerStats"} |
Example
opp2p_discoveryTable
Returns the discovery table entries as a list of ENR strings.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_discoveryTable"} |
Example
Peer Blocking Methods
opp2p_blockPeer
Blocks a specific peer by peer ID, preventing any connections to or from that peer.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_blockPeer", "params": [peerID]} |
Parameters
peerID(string): The peer ID to block
Example
opp2p_unblockPeer
Unblocks a previously blocked peer by peer ID.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_unblockPeer", "params": [peerID]} |
Parameters
peerID(string): The peer ID to unblock
Example
opp2p_listBlockedPeers
Returns a list of all blocked peer IDs.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_listBlockedPeers"} |
Example
Address Blocking Methods
opp2p_blockAddr
Blocks connections from a specific IP address.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_blockAddr", "params": [address]} |
Parameters
address(string): The IP address to block (IPv4 or IPv6)
Example
opp2p_unblockAddr
Unblocks a previously blocked IP address.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_unblockAddr", "params": [address]} |
Parameters
address(string): The IP address to unblock (IPv4 or IPv6)
Example
opp2p_listBlockedAddrs
Returns a list of all blocked IP addresses.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_listBlockedAddrs"} |
Example
Subnet Blocking Methods
opp2p_blockSubnet
Blocks connections from an entire IP subnet using CIDR notation.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_blockSubnet", "params": [subnet]} |
Parameters
subnet(string): The subnet to block in CIDR notation (e.g., “192.168.1.0/24”)
Example
opp2p_unblockSubnet
Unblocks a previously blocked IP subnet.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_unblockSubnet", "params": [subnet]} |
Parameters
subnet(string): The subnet to unblock in CIDR notation
Example
opp2p_listBlockedSubnets
Returns a list of all blocked IP subnets.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_listBlockedSubnets"} |
Example
Peer Protection Methods
opp2p_protectPeer
Protects a peer from being disconnected due to connection limits or other automatic pruning mechanisms.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_protectPeer", "params": [peerID]} |
Parameters
peerID(string): The peer ID to protect
Example
opp2p_unprotectPeer
Removes protection from a peer, allowing it to be disconnected by automatic pruning mechanisms.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_unprotectPeer", "params": [peerID]} |
Parameters
peerID(string): The peer ID to unprotect
Example
Connection Management Methods
opp2p_connectPeer
Attempts to establish a connection to a specific peer using a multiaddress.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_connectPeer", "params": [multiaddr]} |
Parameters
multiaddr(string): The multiaddress of the peer to connect to
Example
opp2p_disconnectPeer
Disconnects from a specific peer by peer ID.
| Client | Method invocation |
|---|---|
| RPC | {"method": "opp2p_disconnectPeer", "params": [peerID]} |
Parameters
peerID(string): The peer ID to disconnect from