Documentation ¶
Overview ¶
* @file * @copyright defined in aergo/LICENSE.txt
Index ¶
- Constants
- Variables
- func CheckVersion(version string) bool
- type ActorService
- type AergoVersion
- type AgentCertificateV1
- type AsyncHandler
- type AttrModifier
- type CertificateManager
- type ConnWorkResult
- type HSHandler
- type HSHandlerFactory
- type HSHeadReq
- type HSHeadResp
- type HSHeader
- type HSRespCode
- type HandlerAdvice
- type HandshakeResult
- type InternalService
- type ListManager
- type LocalSettings
- type Message
- type MessageBody
- type MessageHandler
- type MessageValue
- func NewLiteMessageValue(protocol SubProtocol, msgID, originalID MsgID, timestamp int64) *MessageValue
- func NewMessageValue(protocol SubProtocol, msgID, originalID MsgID, timestamp int64, payload []byte) *MessageValue
- func NewSimpleMsgVal(protocol SubProtocol, msgID MsgID) *MessageValue
- func NewSimpleRespMsgVal(protocol SubProtocol, msgID MsgID, originalID MsgID) *MessageValue
- type MoFactory
- type MsgID
- type MsgIOListener
- type MsgOrder
- type MsgReadWriter
- type MsgSigner
- type NTContainer
- type NetworkTransport
- type P2PVersion
- type PeerAccessor
- type PeerEventListener
- type PeerFactory
- type PeerFinder
- type PeerManager
- type PeerMeta
- type PeerRoleManager
- type PeerZone
- type RemoteConn
- type RemoteInfo
- type RemotePeer
- type ReportType
- type ResponseReceiver
- type SubProtocol
- type SyncManager
- type TxNoticeTracer
- type VersionedHandshaker
- type VersionedManager
- type WaitingPeer
- type WaitingPeerManager
Constants ¶
const ( // this magic number is useful only in handshaking MAGICMain uint32 = 0x47416841 MAGICTest uint32 = 0x2e415429 MAGICRaftSnap uint32 = 0x8fae0fd4 SigLength = 16 MaxPayloadLength = 1 << 23 // 8MB MaxBlockHeaderResponseCount = 10000 MaxBlockResponseCount = 2000 )
constants of p2p protocol since v0.3
const ( P2PSubAddr core.ProtocolID = "/aergop2p" RaftSnapSubAddr core.ProtocolID = "/aergop2p/raftsnap" )
context of multiaddr, as higher type of p2p message
const ( V030HSHeaderLength = 8 HSMagicLength = 4 HSVersionLength = 4 HSVerCntLength = 4 )
constants for handshake. for calculating byte offset of wire handshake
const ( HSCodeWrongHSReq uint32 HSCodeNoMatchedVersion // HSCodeAuthFail HSCodeNoPermission HSCodeInvalidState )
const ( DefaultPkKeyPrefix = "aergo-peer" DefaultPkKeyExt = ".key" DefaultPubKeyExt = ".pub" DefaultPeerIDExt = ".id" )
constants about private key
const ( // DesignatedNodeTTL is time to determine which the remote designated peer is not working. DesignatedNodeTTL = time.Minute * 60 // DefaultNodeTTL is time to determine which the remote peer is not working. DefaultNodeTTL = time.Minute * 10 )
const ( WaitingPeerManagerInterval = time.Minute >> 2 PolarisQueryInterval = time.Minute * 10 PeerQueryInterval = time.Hour PeerFirstInterval = time.Second * 4 MaxConcurrentHandshake = 5 )
const ( MinimumAergoVersion = "v1.2.3" MaximumAergoVersion = "v2.0.0" )
Supported Aergo version. polaris will register aergosvr within the version range. This version range should be modified when new release is born.
const (
CertVersion0001 uint32 = 0x01
)
const ( // other actor DefaultActorMsgTTL = time.Second * 4 )
constants for inter-communication of aergosvr
const HSError uint32 = 0
const HSMaxVersionCnt = 16
const IDLength = 16
Variables ¶
var ( ErrInvalidCertVersion = errors.New("invalid certificate version") ErrInvalidRole = errors.New("invalid peer role") // receiver is not bp or requester is not registered agent ErrInvalidKey = errors.New("invalid key in certificate ") ErrInvalidPeerID = errors.New("invalid peer id in certificate ") ErrVerificationFailed = errors.New("signature verification failed") ErrMalformedCert = errors.New("malformed certificate data") ErrInvalidCertField = errors.New("invalid field in certificate ") )
var AcceptedInboundVersions = []P2PVersion{P2PVersion200, P2PVersion033, P2PVersion032, P2PVersion031}
AcceptedInboundVersions is list of versions this aergosvr supports. The first is the best recommended version.
var AttemptingOutboundVersions = []P2PVersion{P2PVersion200, P2PVersion033, P2PVersion032, P2PVersion031}
var (
EmptyID = MsgID(uuid.Nil)
)
var (
ErrNoWaiting = errors.New("no waiting peer exists")
)
var ExperimentalVersions = []P2PVersion{P2PVersion200}
Functions ¶
func CheckVersion ¶ added in v1.3.3
Types ¶
type ActorService ¶
type ActorService interface { // TellRequest send actor request, which does not need to get return value, and forget it. TellRequest(actorName string, msg interface{}) // SendRequest send actor request, and the response is expected to go back asynchronously. SendRequest(actorName string, msg interface{}) // CallRequest send actor request and wait the handling of that message to finished, // and get return value. CallRequest(actorName string, msg interface{}, timeout time.Duration) (interface{}, error) // CallRequestDefaultTimeout is CallRequest with default timeout CallRequestDefaultTimeout(actorName string, msg interface{}) (interface{}, error) // FutureRequest send actor request and get the Future object to get the state and return value of message FutureRequest(actorName string, msg interface{}, timeout time.Duration) *actor.Future // FutureRequestDefaultTimeout is FutureRequest with default timeout FutureRequestDefaultTimeout(actorName string, msg interface{}) *actor.Future GetChainAccessor() types.ChainAccessor }
ActorService is collection of helper methods to use actor FIXME move to more general package. it used in p2p and rpc
type AergoVersion ¶ added in v1.3.3
AergoVersion follows sementic versioning https://semver.org/
func ParseAergoVersion ¶ added in v1.3.3
func ParseAergoVersion(verStr string) (AergoVersion, error)
ParseAergoVersion parse version string to sementic version with slightly different manner. This function allows not only standard sementic version but also version strings containing v in prefixes.
type AgentCertificateV1 ¶ added in v1.3.3
type AgentCertificateV1 struct { Version uint32 BPID types.PeerID BPPubKey *btcec.PublicKey CreateTime time.Time ExpireTime time.Time AgentID types.PeerID AgentAddress []string Signature *btcec.Signature }
AgentCertificateV1 is a certificate issued by a block producer to guarantee that it is a trustworthy agent.
func (*AgentCertificateV1) IsNeedUpdate ¶ added in v1.3.3
func (*AgentCertificateV1) IsValidInTime ¶ added in v1.3.3
type AsyncHandler ¶ added in v1.3.3
type AsyncHandler interface { HandleOrNot(msg Message, msgBody MessageBody) bool Handle(msg Message, msgBody MessageBody, ttl time.Duration) }
type AttrModifier ¶ added in v1.3.3
type CertificateManager ¶ added in v1.3.3
type CertificateManager interface { PeerEventListener Start() Stop() // methods for bp // CreateCertificate create certificate for the agent. It will return ErrInvalidRole error if local peer is not block producer CreateCertificate(remoteMeta PeerMeta) (*AgentCertificateV1, error) // methods for agents // GetProducers return list of peer id of which this agent is charge. GetProducers() []types.PeerID // GetCertificates returns my certificates GetCertificates() []*AgentCertificateV1 // AddCertificate add to my certificate list AddCertificate(cert *AgentCertificateV1) CanHandle(bpID types.PeerID) bool }
CertificateManager manages local peer's certificates and related information
type ConnWorkResult ¶ added in v1.3.3
type ConnWorkResult struct { Inbound bool Seq uint32 // TargetPeer is nil if Inbound is true TargetPeer *WaitingPeer Meta PeerMeta ConnInfo RemoteInfo P2PVer uint32 Result error }
type HSHandler ¶ added in v1.3.3
type HSHandler interface { // Handle peer handshake till ttl, and return msgrw for this connection, and status of remote peer. Handle(s io.ReadWriteCloser, ttl time.Duration) (*HandshakeResult, error) }
HSHandler handles whole process of connect, handshake, create of remote Peer
type HSHandlerFactory ¶ added in v1.3.3
HSHandlerFactory is creator of HSHandler
type HSHeadReq ¶ added in v1.3.3
type HSHeadReq struct { Magic uint32 // Versions are p2p versions which the connecting peer can support. Versions []P2PVersion }
HSHeadReq is data which peer send first to listening peer in wire handshake
type HSHeadResp ¶ added in v1.3.3
type HSHeadResp struct { // Magic will be same as the magic in HSHeadReq if wire handshake is successful, or 0 if not. Magic uint32 // RespCode is different meaning by value of Magic. It is p2p version which listening peer will use, if wire handshake is successful, or errCode otherwise. RespCode uint32 }
HSHeadResp is data which listening peer send back to connecting peer as response
func (HSHeadResp) Marshal ¶ added in v1.3.3
func (h HSHeadResp) Marshal() []byte
func (*HSHeadResp) Unmarshal ¶ added in v1.3.3
func (h *HSHeadResp) Unmarshal(b []byte)
type HSHeader ¶ added in v1.3.3
type HSHeader struct { Magic uint32 Version P2PVersion }
HSHeader is legacy type of data which peer send first to listening peer in wire handshake
type HandlerAdvice ¶ added in v1.3.3
type HandlerAdvice interface { PreHandle() PostHandle(msg Message, msgBody MessageBody) }
type HandshakeResult ¶ added in v1.3.3
type HandshakeResult struct { MsgRW MsgReadWriter Meta PeerMeta BestBlockHash types.BlockID BestBlockNo types.BlockNo Hidden bool Certificates []*AgentCertificateV1 }
type InternalService ¶ added in v1.3.3
type InternalService interface { //NetworkTransport SelfMeta() PeerMeta SelfNodeID() types.PeerID LocalSettings() LocalSettings // accessors of other modules GetChainAccessor() types.ChainAccessor CertificateManager() CertificateManager RoleManager() PeerRoleManager }
InternalService provides informations of self node and reference of other p2p components. This service is intended to be used inside p2p modules, and using outside of p2p is not expected.
type ListManager ¶ added in v1.3.3
type ListManager interface { Start() Stop() IsBanned(addr string, pid types.PeerID) (bool, time.Time) // RefineList update white/blacklist RefineList() Summary() map[string]interface{} }
ListManager manages whitelist and blacklist
type LocalSettings ¶ added in v1.3.3
type Message ¶
type Message interface { Subprotocol() SubProtocol // Length is length of payload Length() uint32 // Timestamp is when this message was created with unixNano format Timestamp() int64 // ID is 16 bytes unique identifier ID() MsgID // OriginalID is message id of request which trigger this message. it will be all zero, if message is request or notice. OriginalID() MsgID // Payload is MessageBody struct, marshaled by google protocol buffer v3. object is determined by Subprotocol Payload() []byte }
Message is unit structure transferred from a peer to another peer.
type MessageBody ¶ added in v1.3.3
MessageBody is content of p2p message. The actual data types are varied by subprotocol, so For version 0.3.x, it is just wrapper of proto.Message
type MessageHandler ¶
type MessageHandler interface { AddAdvice(advice HandlerAdvice) ParsePayload([]byte) (MessageBody, error) CheckAuth(msg Message, msgBody MessageBody) error Handle(msg Message, msgBody MessageBody) PreHandle() PostHandle(msg Message, msgBody MessageBody) }
MessageHandler handle incoming message. The Handler belongs to RemotePeer, i.e. every connected remote peer has its own handlers. Each handler handles messages assigned to it sequentially, but multiple handlers can handle their own messages concurrently.
type MessageValue ¶ added in v1.3.3
type MessageValue struct {
// contains filtered or unexported fields
}
MessageValue is basic implementation of Message. It is used since p2p v0.3
func NewLiteMessageValue ¶ added in v1.3.3
func NewLiteMessageValue(protocol SubProtocol, msgID, originalID MsgID, timestamp int64) *MessageValue
NewLiteMessageValue create MessageValue object which payload is empty
func NewMessageValue ¶ added in v1.3.3
func NewMessageValue(protocol SubProtocol, msgID, originalID MsgID, timestamp int64, payload []byte) *MessageValue
NewMessageValue create a new object
func NewSimpleMsgVal ¶ added in v1.3.3
func NewSimpleMsgVal(protocol SubProtocol, msgID MsgID) *MessageValue
func NewSimpleRespMsgVal ¶ added in v1.3.3
func NewSimpleRespMsgVal(protocol SubProtocol, msgID MsgID, originalID MsgID) *MessageValue
func (*MessageValue) ID ¶ added in v1.3.3
func (m *MessageValue) ID() MsgID
func (*MessageValue) Length ¶ added in v1.3.3
func (m *MessageValue) Length() uint32
func (*MessageValue) OriginalID ¶ added in v1.3.3
func (m *MessageValue) OriginalID() MsgID
func (*MessageValue) Payload ¶ added in v1.3.3
func (m *MessageValue) Payload() []byte
func (*MessageValue) SetPayload ¶ added in v1.3.3
func (m *MessageValue) SetPayload(payload []byte)
func (*MessageValue) Subprotocol ¶ added in v1.3.3
func (m *MessageValue) Subprotocol() SubProtocol
func (*MessageValue) Timestamp ¶ added in v1.3.3
func (m *MessageValue) Timestamp() int64
type MoFactory ¶
type MoFactory interface { NewMsgRequestOrder(expectResponse bool, protocolID SubProtocol, message MessageBody) MsgOrder NewMsgBlockRequestOrder(respReceiver ResponseReceiver, protocolID SubProtocol, message MessageBody) MsgOrder NewMsgResponseOrder(reqID MsgID, protocolID SubProtocol, message MessageBody) MsgOrder NewMsgBlkBroadcastOrder(noticeMsg *types.NewBlockNotice) MsgOrder NewMsgTxBroadcastOrder(noticeMsg *types.NewTransactionsNotice) MsgOrder NewMsgBPBroadcastOrder(noticeMsg *types.BlockProducedNotice) MsgOrder NewRaftMsgOrder(msgType raftpb.MessageType, raftMsg *raftpb.Message) MsgOrder NewTossMsgOrder(orgMsg Message) MsgOrder }
type MsgID ¶
MsgID is
func MustParseBytes ¶
MustParseBytes return MsgID from byte slice
func ParseBytesToMsgID ¶
type MsgIOListener ¶ added in v1.3.3
type MsgIOListener interface { OnRead(protocol SubProtocol, read int) OnWrite(protocol SubProtocol, write int) }
MsgIOListener listen read and write of p2p message. The concrete implementations must consume much of times.
type MsgOrder ¶
type MsgOrder interface { GetMsgID() MsgID // Timestamp is unit time value Timestamp() int64 IsRequest() bool IsNeedSign() bool GetProtocolID() SubProtocol // SendTo send message to remote peer. it return err if write fails, or nil if write is successful or ignored. SendTo(p RemotePeer) error CancelSend(pi RemotePeer) }
MsgOrder is abstraction of information about the message that will be sent to peer. Some type of msgOrder, such as notice mo, should thread-safe and re-entrant
type MsgReadWriter ¶
type MsgReadWriter interface { ReadMsg() (Message, error) WriteMsg(msg Message) error Close() error AddIOListener(l MsgIOListener) }
MsgReadWriter read byte stream, parse stream with respect to protocol version and return message object used in p2p module It also write Message to stream with serialized form and have Close() to close underlying io stream. The implementations should be safe for concurrent read and write, but not concurrent reads or writes.
type MsgSigner ¶
type MsgSigner interface { // signMsg calculate signature and fill related fields in msg(peerID, pubkey, signature or etc) SignMsg(msg *types.P2PMessage) error // verifyMsg check signature is valid VerifyMsg(msg *types.P2PMessage, senderID types.PeerID) error }
MsgSigner sign or verify p2p message this is not used since v0.3, but interface is not removed for future version.
type NTContainer ¶
type NTContainer interface { GetNetworkTransport() NetworkTransport // GenesisChainID return inititial chainID of current chain. GenesisChainID() *types.ChainID SelfMeta() PeerMeta }
NTContainer can provide NetworkTransport interface.
type NetworkTransport ¶
type NetworkTransport interface { core.Host Start() error Stop() error SelfMeta() PeerMeta GetAddressesOfPeer(peerID types.PeerID) []string // AddStreamHandler wrapper function which call host.SetStreamHandler after transport is initialized, this method is for preventing nil error. AddStreamHandler(pid core.ProtocolID, handler network.StreamHandler) GetOrCreateStream(meta PeerMeta, protocolIDs ...core.ProtocolID) (core.Stream, error) GetOrCreateStreamWithTTL(meta PeerMeta, ttl time.Duration, protocolIDs ...core.ProtocolID) (core.Stream, error) FindPeer(peerID types.PeerID) bool ClosePeerConnection(peerID types.PeerID) bool }
NetworkTransport do manager network connection TODO need refactoring. it has other role, pk management of self peer
type P2PVersion ¶ added in v1.3.3
type P2PVersion uint32
P2PVersion is version of p2p wire protocol. This version affects p2p handshake, data format transferred, etc
const ( P2PVersionUnknown P2PVersion = 0x00000000 // not supported versions P2PVersion030 P2PVersion = 0x00000300 // legacy versions P2PVersion031 P2PVersion = 0x00000301 // pseudo version for supporting multi version P2PVersion032 P2PVersion = 0x00000302 // added equal check of genesis block hash // current version P2PVersion033 P2PVersion = 0x00000303 // support hardfork (chainid is changed) P2PVersion200 P2PVersion = 0x00020000 // following aergo version. support peer role and multiple addresses )
func (P2PVersion) String ¶ added in v1.3.3
func (v P2PVersion) String() string
func (P2PVersion) Uint32 ¶ added in v1.3.3
func (v P2PVersion) Uint32() uint32
type PeerAccessor ¶ added in v1.3.3
type PeerAccessor interface { // SelfMeta returns peerid, ipaddress and port of server itself SelfMeta() PeerMeta GetPeerBlockInfos() []types.PeerBlockInfo GetPeer(ID types.PeerID) (RemotePeer, bool) }
PeerAccessor is an interface for a another actor module to get info of peers
type PeerEventListener ¶ added in v1.3.3
type PeerEventListener interface { OnPeerConnect(pid types.PeerID) OnPeerDisconnect(peer RemotePeer) }
type PeerFactory ¶ added in v1.3.3
type PeerFactory interface {
CreateRemotePeer(remoteInfo RemoteInfo, seq uint32, rw MsgReadWriter) RemotePeer
}
type PeerFinder ¶ added in v1.3.3
type PeerFinder interface { PeerEventListener // Check if it need to discover more peers and send query request to polaris or other peers if needed. CheckAndFill() }
PeerFinder works for collecting peer candidate. It queries to Polaris or other connected peer efficiently. It determine if peer is NOTE that this object is not thread safe by itself.
type PeerManager ¶
type PeerManager interface { AddPeerEventListener(l PeerEventListener) Start() error Stop() error //NetworkTransport SelfMeta() PeerMeta SelfNodeID() types.PeerID // AddNewPeer connect to peer. It will reset reconnect schedule and try to connect immediately if this peer is in reconnect cooltime. AddNewPeer(meta PeerMeta) // Remove peer from peer list. Peer dispose relative resources and stop itself, and then call PeerManager.RemovePeer RemovePeer(peer RemotePeer) UpdatePeerRole(changes []AttrModifier) NotifyPeerAddressReceived([]PeerMeta) // GetPeer return registered(handshaked) remote peer object. It is thread safe GetPeer(ID types.PeerID) (RemotePeer, bool) // GetPeers return all registered(handshaked) remote peers. It is thread safe GetPeers() []RemotePeer GetPeerAddresses(noHidden bool, showSelf bool) []*message.PeerInfo GetPeerBlockInfos() []types.PeerBlockInfo AddDesignatedPeer(meta PeerMeta) RemoveDesignatedPeer(peerID types.PeerID) ListDesignatedPeers() []PeerMeta }
PeerManager is internal service that provide peer management
type PeerMeta ¶
type PeerMeta struct { ID types.PeerID // AcceptedRole is the role that the remote peer claims: the local peer may not admit it, and only admits it when there is a proper proof, such as vote result in chain or AgentCertificate. Role types.PeerRole // ProducerIDs is a list of block producer IDs produced by this peer if the peer is BP, and if it is Agent, it is a list of block producer IDs that this peer acts as. ProducerIDs []types.PeerID // Address is advertised address to which other peer can connect. Addresses []types.Multiaddr // Version is build version of binary Version string Hidden bool // Hidden means that meta info of this peer will not be sent to other peers when getting peer list }
PeerMeta contains non changeable information of peer node during connected state
func FromPeerAddress ¶
func FromPeerAddress(addr *types.PeerAddress) PeerMeta
FromPeerAddress convert PeerAddress to PeerMeta
func FromPeerAddressNew ¶ added in v1.3.3
func FromPeerAddressNew(addr *types.PeerAddress) PeerMeta
func NewMetaFromStatus ¶
FromStatusToMeta create peerMeta from Status message
func NewMetaWith1Addr ¶ added in v1.3.3
NewMetaWith1Addr make instance of PeerMeta with single address
func (*PeerMeta) GetVersion ¶ added in v1.3.3
func (PeerMeta) PrimaryAddress ¶ added in v1.3.3
PrimaryAddress is first advertised address of peer
func (PeerMeta) PrimaryPort ¶ added in v1.3.3
PrimaryAddress is first advertised port of peer
func (PeerMeta) ToPeerAddress ¶
func (m PeerMeta) ToPeerAddress() types.PeerAddress
ToPeerAddress convert PeerMeta to PeerAddress
type PeerRoleManager ¶ added in v1.3.3
type PeerRoleManager interface { UpdateBP(toAdd []types.PeerID, toRemove []types.PeerID) // SelfRole returns role of this peer itself SelfRole() types.PeerRole // GetRole returns role of remote peer GetRole(pid types.PeerID) types.PeerRole // FilterBPNoticeReceiver selects target peers with the appropriate role and sends them a BlockProducedNotice FilterBPNoticeReceiver(block *types.Block, pm PeerManager, targetZone PeerZone) []RemotePeer // FilterNewBlockNoticeReceiver selects target peers with the appropriate role and sends them a NewBlockNotice FilterNewBlockNoticeReceiver(block *types.Block, pm PeerManager) []RemotePeer }
type RemoteConn ¶ added in v1.3.3
RemoteConn is information of single peer connection
type RemoteInfo ¶ added in v1.3.3
type RemoteInfo struct { Meta PeerMeta Connection RemoteConn Designated bool // Designated means this peer is designated in config file and connect to in startup phase Hidden bool // Hidden means that meta info of this peer will not be sent to other peers when getting peer list // AcceptedRole is role as which the local peer treat the remote peer AcceptedRole types.PeerRole Certificates []*AgentCertificateV1 Zone PeerZone }
RemoteInfo is information of connected remote peer
type RemotePeer ¶
type RemotePeer interface { ID() types.PeerID RemoteInfo() RemoteInfo Meta() PeerMeta ManageNumber() uint32 Name() string Version() string AcceptedRole() types.PeerRole ChangeRole(role types.PeerRole) AddMessageHandler(subProtocol SubProtocol, handler MessageHandler) State() types.PeerState // LastStatus returns last observed status of remote peer. this value will be changed by notice, or ping LastStatus() *types.LastBlockStatus RunPeer() Stop() SendMessage(msg MsgOrder) SendAndWaitMessage(msg MsgOrder, ttl time.Duration) error PushTxsNotice(txHashes []types.TxID) ConsumeRequest(msgID MsgID) GetReceiver(id MsgID) ResponseReceiver // updateBlkCache add hash to block cache and return true if this hash already exists. UpdateBlkCache(blkHash types.BlockID, blkNumber types.BlockNo) bool // updateTxCache add hashes to transaction cache and return newly added hashes. UpdateTxCache(hashes []types.TxID) []types.TxID // updateLastNotice change estimate of the last status of remote peer UpdateLastNotice(blkHash types.BlockID, blkNumber types.BlockNo) // TODO MF() MoFactory // AddCertificate add to my certificate list AddCertificate(cert *AgentCertificateV1) }
type ResponseReceiver ¶
type ResponseReceiver func(Message, MessageBody) bool
ResponseReceiver is handler function for the corresponding response message. It returns true when receiver handled it, or false if this receiver is not the expected handler.
type SubProtocol ¶
type SubProtocol uint32
SubProtocol identifies the lower type of p2p message
const ( StatusRequest SubProtocol PingRequest PingResponse GoAway AddressesRequest AddressesResponse IssueCertificateRequest IssueCertificateResponse CertificateRenewedNotice )
NOTE: change const of protocols_test.go
const ( GetBlocksRequest SubProtocol = 0x010 + iota GetBlocksResponse GetBlockHeadersRequest GetBlockHeadersResponse NewBlockNotice GetAncestorRequest GetAncestorResponse GetHashesRequest GetHashesResponse GetHashByNoRequest GetHashByNoResponse )
const ( GetTXsRequest SubProtocol = 0x020 + iota GetTXsResponse NewTxNotice )
const ( GetClusterRequest SubProtocol GetClusterResponse RaftWrapperMessage // )
const ( // BlockProducedNotice from block producer to trusted nodes and other bp nodes BlockProducedNotice SubProtocol = 0x030 + iota )
subprotocols for block producers and their own trusted nodes
func (SubProtocol) String ¶
func (i SubProtocol) String() string
func (SubProtocol) Uint32 ¶
func (i SubProtocol) Uint32() uint32
type SyncManager ¶
type SyncManager interface { // handle notice from bp HandleBlockProducedNotice(peer RemotePeer, block *types.Block) // handle notice from other node HandleNewBlockNotice(peer RemotePeer, data *types.NewBlockNotice) HandleGetBlockResponse(peer RemotePeer, msg Message, resp *types.GetBlockResponse) HandleNewTxNotice(peer RemotePeer, hashes []types.TxID, data *types.NewTransactionsNotice) }
type TxNoticeTracer ¶ added in v1.3.3
type VersionedHandshaker ¶ added in v1.3.3
type VersionedHandshaker interface { DoForOutbound(ctx context.Context) (*HandshakeResult, error) DoForInbound(ctx context.Context) (*HandshakeResult, error) GetMsgRW() MsgReadWriter }
VersionedHandshaker do handshake related to chain, and return msgreadwriter for a protocol version. It is used inside HSHandler
type VersionedManager ¶ added in v1.3.3
type VersionedManager interface { FindBestP2PVersion(versions []P2PVersion) P2PVersion GetVersionedHandshaker(version P2PVersion, peerID types.PeerID, rwc io.ReadWriteCloser) (VersionedHandshaker, error) GetBestChainID() *types.ChainID GetChainID(no types.BlockNo) *types.ChainID }
type WaitingPeer ¶ added in v1.3.3
type WaitingPeerManager ¶ added in v1.3.3
type WaitingPeerManager interface { PeerEventListener // OnDiscoveredPeers is called when response of discover query came from polaris or other peer. // It returns the count of previously unknown peers. OnDiscoveredPeers(metas []PeerMeta) int // OnWorkDone OnWorkDone(result ConnWorkResult) CheckAndConnect() InstantConnect(meta PeerMeta) OnInboundConn(s network.Stream) }
WaitingPeerManager manage waiting peer pool and role to connect and handshaking of remote peer.
Source Files ¶
- actorservice.go
- certificate.go
- consts.go
- handshake.go
- internalmsg.go
- internalservice.go
- listmanager.go
- message.go
- messagevalue.go
- msgid.go
- msgio.go
- others.go
- p2pconstants.go
- peermanager.go
- peermeta.go
- peerrole.go
- pool.go
- remoteinfo.go
- remotepeer.go
- subprotocol.go
- subprotocol_string.go
- subprotocols.go
- temptype.go
- transport.go
- txnotice.go
- versioning.go