Documentation ¶
Index ¶
- Constants
- Variables
- func NewServer(privkey *ecdsa.PrivateKey, name string, version string, proto p2p.Protocol, ...) *p2p.Server
- func NewServiceNode(port int, httpport int, wsport int, modules ...string) (*node.Node, error)
- func WaitHealthy(ctx context.Context, minbinsize int, rpcs ...*rpc.Client) error
- type FooAPI
- type FooPingMsg
- type FooService
Constants ¶
View Source
const ( BzzDefaultNetworkId = 4242 WSDefaultPort = 18543 BzzDefaultPort = 8542 )
View Source
const ( P2pPort = 30100 IPCName = "demo.ipc" DatadirPrefix = ".data_" )
View Source
const ( FooProtocolName = "fooping" FooProtocolVersion = 42 FooProtocolMaxMsgSize = 1024 )
Variables ¶
View Source
var ( // custom log, easily grep'able Log = log.New("demolog", "*") // our working directory BasePath string // out local port for p2p connections P2PPort int )
View Source
var ( FooMessages = []interface{}{ &FooPingMsg{}, } FooProtocol = protocols.Spec{ Name: FooProtocolName, Version: FooProtocolVersion, MaxMsgSize: FooProtocolMaxMsgSize, Messages: FooMessages, } )
Functions ¶
func NewServer ¶
func NewServer(privkey *ecdsa.PrivateKey, name string, version string, proto p2p.Protocol, port int) *p2p.Server
create a new p2p server
func NewServiceNode ¶
set up the local service node
Types ¶
type FooAPI ¶
type FooAPI struct {
// contains filtered or unexported fields
}
Specify the API in this example we don't care about who the pongs comes from, we count them all note it is a bit fragile; we don't check for closed channels
type FooPingMsg ¶
type FooService ¶
type FooService struct {
// contains filtered or unexported fields
}
the service we want to offer on the node it must implement the node.Service interface
func NewFooService ¶
func NewFooService() *FooService
func (*FooService) APIs ¶
func (self *FooService) APIs() []rpc.API
specify API structs that carry the methods we want to use
func (*FooService) Protocols ¶
func (self *FooService) Protocols() []p2p.Protocol
the p2p.Protocol to run sends a ping to its peer, waits pong
func (*FooService) Stop ¶
func (self *FooService) Stop() error
Click to show internal directories.
Click to hide internal directories.