Documentation ¶
Index ¶
- Constants
- func MakeBootstrapMultiaddr(bootstrap []string) (peersIDs []peer.ID, addrs []ma.Multiaddr, err error)
- func MakeMultiaddr(address string) (ma.Multiaddr, error)
- func VerifySignature(spOpAddr string, signBytes []byte, sig []byte) error
- type ApprovalProtocol
- type Node
- func (n *Node) Bootstrap() []string
- func (n *Node) GetSecondaryReplicatePieceApproval(ctx context.Context, task coretask.ApprovalReplicatePieceTask, ...) (accept []coretask.ApprovalReplicatePieceTask, err error)
- func (n *Node) Name() string
- func (n *Node) PeersProvider() *PeerProvider
- func (n *Node) Start(ctx context.Context) error
- func (n *Node) Stop(ctx context.Context) error
- type Peer
- type PeerProvider
Constants ¶
const ( // PingPeriodMin defines the min value that the period of sending ping request PingPeriodMin = 1 // DailTimeout defines default value that the timeout of dail other p2p node DailTimeout = 1 // DefaultDataPath defines default value that the path of peer store DefaultDataPath = "./data" // P2PNode defines the p2p protocol node name P2PNode = "p2p_protocol_node" // MinSecondaryApprovalExpiredHeight defines the min expired height for secondary // approval MinSecondaryApprovalExpiredHeight = 900 )
const ( // PeerFailureMax defines the threshold of setting node to fail PeerFailureMax = 1 // PrunePeersNumberMax defines the threshold to trigger the prune p2p node PrunePeersNumberMax = 10 // PeerSpUnspecified defines default sp operator address PeerSpUnspecified = "PEER_SP_UNSPECIFIED" )
const ( PingProtocol = "/ping/0.0.1" PongProtocol = "/pong/0.0.1" )
const GetApprovalRequest = "/approval/request/0.0.1"
pattern: /protocol-name/request-or-response-message/version
const GetApprovalResponse = "/approval/response/0.0.1"
const ResponseChannelSize = 12
ResponseChannelSize defines the approval response size
Variables ¶
This section is empty.
Functions ¶
func MakeBootstrapMultiaddr ¶
func MakeBootstrapMultiaddr(bootstrap []string) (peersIDs []peer.ID, addrs []ma.Multiaddr, err error)
MakeBootstrapMultiaddr new bootstrap nodes multi addr.
func MakeMultiaddr ¶
MakeMultiaddr new multi addr by address
Types ¶
type ApprovalProtocol ¶
type ApprovalProtocol struct {
// contains filtered or unexported fields
}
ApprovalProtocol define the approval protocol and callback maintains requests for getting approvals in memory
func NewApprovalProtocol ¶
func NewApprovalProtocol(host *Node) *ApprovalProtocol
NewApprovalProtocol return an instance of ApprovalProtocol
func (*ApprovalProtocol) ComputeApprovalExpiredHeight ¶
func (a *ApprovalProtocol) ComputeApprovalExpiredHeight(task coretask.ApprovalReplicatePieceTask) (uint64, error)
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node defines the p2p protocol node, encapsulates the go-lib.p2p p2p protocol message interactive security based on storage provider operator private-public key pair signature, use leveldb as underlying DB.
func NewNode ¶
func NewNode(baseApp *gfspapp.GfSpBaseApp, privateKey string, address string, bootstrap []string, pingPeriod int, secondaryApprovalExpiredHeight uint64, p2pAntAddress string) (*Node, error)
NewNode return an instance of Node
func (*Node) GetSecondaryReplicatePieceApproval ¶
func (n *Node) GetSecondaryReplicatePieceApproval( ctx context.Context, task coretask.ApprovalReplicatePieceTask, expectedAccept int, timeout int64) ( accept []coretask.ApprovalReplicatePieceTask, err error)
GetSecondaryReplicatePieceApproval broadcast get approval request and blocking goroutine until timeout or collect expect accept approval response number
func (*Node) PeersProvider ¶
func (n *Node) PeersProvider() *PeerProvider
PeersProvider returns the p2p peers provider
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
Peer defines the peer info in memory
type PeerProvider ¶
type PeerProvider struct {
// contains filtered or unexported fields
}
PeerProvider implements the pruning function of permanent nodes. Ping service only add permanent node, for zombie nodes, PeerProvider's pruning strategy takes into account the information of the storage provider dimension, and uses a very conservative pruning strategy. Nodes are only pruned if there are enough backups and multiple failed interactions, can try to keep each storage provider with enough nodes to try to connect, so that each sp has an equal opportunity to receive requests
func NewPeerProvider ¶
func NewPeerProvider(store peerstore.Peerstore) *PeerProvider
NewPeerProvider return an instance of PeerProvider
func (*PeerProvider) DeletePeer ¶
func (pr *PeerProvider) DeletePeer(peerID peer.ID)
DeletePeer increase the peer's fail counter and trigger prunePeers
func (*PeerProvider) UpdateSp ¶
func (pr *PeerProvider) UpdateSp(SPs []string)
UpdateSp change the storage provider