Documentation
¶
Index ¶
- Constants
- type IncomingShare
- type Node
- func (n *Node) Bootstrap(bootstrapPeers []string) error
- func (n *Node) BroadcastShare(shareData []byte) error
- func (n *Node) BroadcastTemplate(b []byte)
- func (n *Node) Close()
- func (n *Node) DownloadShares()
- func (n *Node) ExchangePeers(pid peer.ID)
- func (n *Node) PullTemplateFromPeers()
- func (n *Node) QueryBlockConfirmations(blockHash string) int
- func (n *Node) RecordShareOutcome(id peer.ID, bad bool)
- func (n *Node) RelaySolvedBlockHex(hexStr string) int
- func (n *Node) SetShareValidator(f func(data []byte) ShareVerdict) error
- func (n *Node) SyncWithPeer(pid peer.ID)
- type ShareReq
- type ShareVerdict
- type SyncPayload
- type VersionMsg
Constants ¶
const BlockCheckProtocolID = protocol.ID("/p2pool/blockcheck/1.0.0")
const BlockRelayProtocolID = protocol.ID("/p2pool/blockrelay/1.0.0")
const HeaderProofProtocolID = protocol.ID("/p2pool/headerproof/1.0.0")
const P2PNetworkTopic = "vtc-p2pool-shares-v1"
const PeerExProtocolID = protocol.ID("/p2pool/peers/1.0.0")
const SyncProtocolID = protocol.ID("/p2pool/sync/1.0.0")
const SyncZProtocolID = protocol.ID("/p2pool/sync/1.1.0")
The 1.1.0 protocols carry the same JSON as their 1.0.0 versions, zstd-compressed in each direction. Dialers offer both and peers that predate them get 1.0.0.
const TemplateProtocolID = protocol.ID("/p2pool/template/1.0.0")
const VersionProtocolID = protocol.ID("/p2pool/version/1.0.0")
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IncomingShare ¶
type IncomingShare struct {
}
IncomingShare is a gossiped share and the peer that relayed it.
type Node ¶
type Node struct {
Host host.Host
DHT *dht.IpfsDHT
PubSub *pubsub.PubSub
Topic *pubsub.Topic
Sub *pubsub.Subscription
GetSyncDataFunc func(withShares bool) ([]byte, []byte)
OnSyncDataFunc func(sharesJSON []byte, blocksJSON []byte)
GetStopHashesFunc func() []string
GetTemplateFunc func() []byte
OnTemplateFunc func(peerID string, voterKey string, tmplJSON []byte)
OnRawBlockFunc func(peerID string, rawHex string) bool
CheckBlockFunc func(blockHash string) int
GetRawHeaderFunc func(blockHash string) string
GetChallengeHashFunc func() string
// contains filtered or unexported fields
}
func NewNode ¶
NewNode starts the libp2p host on bindAddr:listenPort. When bindAddr is a loopback address the node runs outbound-only: it opens no non-loopback sockets (no UPnP, mDNS or UDP transports), advertises no addresses and uses the DHT in client mode, so peers never try to dial it.
func (*Node) BroadcastShare ¶
func (*Node) BroadcastTemplate ¶
func (*Node) DownloadShares ¶
func (n *Node) DownloadShares()
DownloadShares requests missing parent shares from peers until the node closes.
func (*Node) ExchangePeers ¶
func (*Node) PullTemplateFromPeers ¶
func (n *Node) PullTemplateFromPeers()
func (*Node) QueryBlockConfirmations ¶
func (*Node) RecordShareOutcome ¶
RecordShareOutcome counts a share relayed by id as accepted or provably invalid, and disconnects id when its invalid shares cross the threshold. A peer's score starts over when it reconnects.
func (*Node) RelaySolvedBlockHex ¶
func (*Node) SetShareValidator ¶
func (n *Node) SetShareValidator(f func(data []byte) ShareVerdict) error
SetShareValidator runs f on every gossip share before it is delivered or forwarded.
func (*Node) SyncWithPeer ¶
type ShareReq ¶
type ShareReq struct {
}
ShareReq asks a peer for the shares in Hashes, each followed by up to Parents ancestors. The walk back from each hash ends before any hash in Stops. Peers that predate Stops ignore it.
type ShareVerdict ¶
type ShareVerdict int
ShareVerdict is a gossip share validator's decision.
const ( ShareReject // our own clock that a peer could pass honestly. ShareIgnore )
type SyncPayload ¶
type SyncPayload struct {
Blocks json.RawMessage `json:"blocks"`
FullNode bool `json:"full_node,omitempty"`
// Pull is set by a sender that fetches shares with share requests instead. It
// sends no shares, and a responder that understands the field replies with none.
Pull bool `json:"pull,omitempty"`
}
type VersionMsg ¶
type VersionMsg struct {
}
VersionMsg is swapped when a node contacts a peer, like p2pool's version message, so each side can request the other's best share right away.