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.
Example
opp2p_peerCount
Returns the count of connected peers for both discovery and gossip networks.
Example
opp2p_peers
Returns information about peers. If connected parameter is true, only returns connected peers.
Parameters
connected(boolean): If true, only returns connected peers
Example
opp2p_peerStats
Returns statistical information about peers including connection counts and topic subscriptions.
Example
opp2p_discoveryTable
Returns the discovery table entries as a list of ENR strings.
Example
Peer Blocking Methods
opp2p_blockPeer
Blocks a specific peer by peer ID, preventing any connections to or from that peer.
Parameters
peerID(string): The peer ID to block
Example
opp2p_unblockPeer
Unblocks a previously blocked peer by peer ID.
Parameters
peerID(string): The peer ID to unblock
Example
opp2p_listBlockedPeers
Returns a list of all blocked peer IDs.
Example
Address Blocking Methods
opp2p_blockAddr
Blocks connections from a specific IP address.
Parameters
address(string): The IP address to block (IPv4 or IPv6)
Example
opp2p_unblockAddr
Unblocks a previously blocked IP address.
Parameters
address(string): The IP address to unblock (IPv4 or IPv6)
Example
opp2p_listBlockedAddrs
Returns a list of all blocked IP addresses.
Example
Subnet Blocking Methods
opp2p_blockSubnet
Blocks connections from an entire IP subnet using CIDR notation.
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.
Parameters
subnet(string): The subnet to unblock in CIDR notation
Example
opp2p_listBlockedSubnets
Returns a list of all blocked IP subnets.
Example
Peer Protection Methods
opp2p_protectPeer
Protects a peer from being disconnected due to connection limits or other automatic pruning mechanisms.
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.
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.
Parameters
multiaddr(string): The multiaddress of the peer to connect to
Example
opp2p_disconnectPeer
Disconnects from a specific peer by peer ID.
Parameters
peerID(string): The peer ID to disconnect from