Documentation ¶
Index ¶
Constants ¶
const ( StatusThanksABunch = iota StatusBusy StatusAreYouKidding StatusGaveup )
enumeration used in status messages
const (
HashSHA1 = iota
)
which hashes a hasher node offers
Variables ¶
Functions ¶
This section is empty.
Types ¶
type DemoPeer ¶
Every protocol that wants to send messages back to sender, must have a peer abstraction this is because devp2p doesn't let us know about which peer is the sender
type DemoProtocol ¶
type DemoProtocol struct { Protocol p2p.Protocol SkillsHandler func(*Skills, *protocols.Peer) error StatusHandler func(*Status, *protocols.Peer) error RequestHandler func(*Request, *protocols.Peer) error ResultHandler func(*Result, *protocols.Peer) error // contains filtered or unexported fields }
The protocol object wraps the code that starts a protocol on a peer upon connection
This implementation holds a callback function thats called upon a successful connection Any logic needed to be performed in the context of the protocol's service should be put there
func NewDemoProtocol ¶
func NewDemoProtocol(runHook func(*protocols.Peer) error) (*DemoProtocol, error)
func (*DemoProtocol) Init ¶
func (self *DemoProtocol) Init() error
TODO: double-check if we need the Init detached
func (*DemoProtocol) Run ¶
func (self *DemoProtocol) Run(p *p2p.Peer, rw p2p.MsgReadWriter) error
This method is run on every new peer connection
It enters a loop that takes care of dispatching and receiving messages
type Result ¶
Result is a protocol message type
It is used by nodes to transmit the results of a hashing job
type Skills ¶
Skills is a protocol message type
It is an asynchronous handshake message, signaling the state the node is in. The message may be issued at any time, and receiving peers should behave accordingly towards the node:
Difficulty > 0 means it's open for hashing, and what the max difficulty is.
MaxSize tells how many bytes can accompany one data submission