Documentation ¶
Overview ¶
Package api implements the P2P API.
Index ¶
- Constants
- func PubKeyToPublicKey(pubKey libp2pCrypto.PubKey) (signature.PublicKey, error)
- func PublicKeyToPeerID(pk signature.PublicKey) (core.PeerID, error)
- func SignerToPrivKey(signer signature.Signer) libp2pCrypto.PrivKey
- type CommitteeMessage
- type Handler
- type ImportanceKind
- type Service
- type TopicKind
- type TxMessage
Constants ¶
View Source
const ( ImportantNodeCompute = 1 ImportantNodeKeyManager = 2 )
Variables ¶
This section is empty.
Functions ¶
func PubKeyToPublicKey ¶
func PubKeyToPublicKey(pubKey libp2pCrypto.PubKey) (signature.PublicKey, error)
PubKeyToPublicKey converts a libp2pCrypto.PubKey to a PublicKey.
func PublicKeyToPeerID ¶
PublicKeyToPeerID converts a public key to a peer identifier.
func SignerToPrivKey ¶
func SignerToPrivKey(signer signature.Signer) libp2pCrypto.PrivKey
SignerToPrivKey converts a Signer to a libp2pCrypto.PrivKey.
Types ¶
type CommitteeMessage ¶
type CommitteeMessage struct { // Epoch is the epoch this message belongs to. Epoch beacon.EpochTime `json:"epoch,omitempty"` // Proposal is a batch proposal. Proposal *commitment.Proposal `json:",omitempty"` }
CommitteeMessage is a message published to nodes via gossipsub on the committee topic.
type Handler ¶
type Handler interface { // DecodeMessage decodes the given incoming message. DecodeMessage(msg []byte) (interface{}, error) // AuthorizeMessage handles authorizing an incoming message. // // The message handler will be re-invoked on error with a periodic backoff unless errors are // wrapped via `p2pError.Permanent`. AuthorizeMessage(ctx context.Context, peerID signature.PublicKey, msg interface{}) error // HandleMessage handles an incoming message from a peer. // // The message handler will be re-invoked on error with a periodic backoff unless errors are // wrapped via `p2pError.Permanent`. HandleMessage(ctx context.Context, peerID signature.PublicKey, msg interface{}, isOwn bool) error }
Handler is a handler for P2P messages.
type ImportanceKind ¶
type ImportanceKind uint8
ImportanceKind is the node importance kind.
func (ImportanceKind) Tag ¶
func (ik ImportanceKind) Tag(runtimeID common.Namespace) string
Tag returns the connection manager tag associated with the given importance kind.
func (ImportanceKind) TagValue ¶
func (ik ImportanceKind) TagValue() int
TagValue returns the connection manager tag value associated with the given importance kind.
type Service ¶
type Service interface { service.BackgroundService // Addresses returns the P2P addresses of the node. Addresses() []node.Address // Peers returns a list of connected P2P peers for the given runtime. Peers(runtimeID common.Namespace) []string // PublishCommittee publishes a committee message. PublishCommittee(ctx context.Context, runtimeID common.Namespace, msg *CommitteeMessage) // PublishTx publishes a transaction message. PublishTx(ctx context.Context, runtimeID common.Namespace, msg TxMessage) // RegisterHandler registers a message handler for the specified runtime and topic kind. RegisterHandler(runtimeID common.Namespace, kind TopicKind, handler Handler) // BlockPeer blocks a specific peer from being used by the local node. BlockPeer(peerID core.PeerID) // GetHost returns the P2P host. GetHost() core.Host // RegisterProtocolServer registers a protocol server for the given protocol. RegisterProtocolServer(srv rpc.Server) // GetMinRepublishInterval returns the minimum republish interval that needs to be respected by // the caller when publishing the same message. If Publish is called for the same message more // quickly, the message may be dropped and not published. GetMinRepublishInterval() time.Duration // SetNodeImportance configures node importance for the given set of nodes. // // This makes it less likely for those nodes to be pruned. SetNodeImportance(kind ImportanceKind, runtimeID common.Namespace, p2pIDs map[signature.PublicKey]bool) }
Service is a P2P node service interface.
Click to show internal directories.
Click to hide internal directories.