Documentation
¶
Index ¶
- Constants
- type P2P
- type P2PApi
- type P2pService
- func (p2pService *P2pService) AddPeer(nodeUrl string) error
- func (p2pService *P2pService) AddProtocols(protocols []p2p.Protocol)
- func (p2pService *P2pService) Api() []app.API
- func (p2pService *P2pService) CommandFlags() ([]cli.Command, []cli.Flag)
- func (p2pService *P2pService) DefaultConfig(netType params.NetType) *p2pTypes.P2pConfig
- func (p2pService *P2pService) Init(executeContext *app.ExecuteContext) error
- func (p2pService *P2pService) LocalNode() *enode.Node
- func (p2pService *P2pService) Name() string
- func (p2pService *P2pService) Peers() []*p2p.Peer
- func (p2pService *P2pService) RemovePeer(nodeUrl string)
- func (p2pService *P2pService) Send(rw p2p.MsgWriter, msgType uint64, msg interface{}) error
- func (p2pService *P2pService) SendAsync(w p2p.MsgWriter, msgType uint64, msg interface{}) chan error
- func (p2pService *P2pService) Start(executeContext *app.ExecuteContext) error
- func (p2pService *P2pService) Stop(executeContext *app.ExecuteContext) error
Constants ¶
const (
MODULENAME = "p2p"
)
const (
MaxConnections = 4000
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type P2P ¶
type P2P interface { app.Service SendAsync(w p2p.MsgWriter, msgType uint64, msg interface{}) chan error Send(w p2p.MsgWriter, msgType uint64, msg interface{}) error Peers() []*p2p.Peer AddPeer(nodeUrl string) error RemovePeer(url string) AddProtocols(protocols []p2p.Protocol) LocalNode() *enode.Node }
type P2PApi ¶
type P2PApi struct {
// contains filtered or unexported fields
}
name: p2p network interface usage: Set or query network status prefix:p2p
func (*P2PApi) AddPeer ¶
name: addPeer usage: Add peer node params: enode://publickey@ip:p2p-Port return:nil example: curl http://127.0.0.1:10085 -X POST --data '{"jsonrpc":"2.0","method":"p2p_addPeer","params":["enode://e1b2f83b7b0f5845cc74ca12bb40152e520842bbd0597b7770cb459bd40f109178811ebddd6d640100cdb9b661a3a43a9811d9fdc63770032a3f2524257fb62d@192.168.74.1:55555"], "id": 3}' -H "Content-Type:application/json" response:
func (*P2PApi) GetPeers ¶
name: getPeers usage: Get currently connected nodes params: return: P2P peer-to-peer information connecting with local example: curl http://127.0.0.1:10085 -X POST --data '{"jsonrpc":"2.0","method":"p2p_getPeers","params":"", "id": 3}' -H "Content-Type:application/json" response:
{"jsonrpc":"2.0","id":3,"result":[{},{},{},{}]}
func (*P2PApi) LocalNode ¶
name: localNode usage: Need to get local eNode for P2P link params: return: local enode example: curl http://127.0.0.1:10085 -X POST --data '{"jsonrpc":"2.0","method":"p2p_localNode","params":[""], "id": 3}' -H "Content-Type:application/json" response:
{"enode://9064107749f41ffffd9177f27af7bb854d702d930462c4be2d91d1772b3f03f3@192.168.31.63:10086}
func (*P2PApi) RemovePeer ¶
name: removePeer usage: remove peer node params:enode://publickey@ip:p2p-port return:nil example: curl http://127.0.0.1:10085 -X POST --data '{"jsonrpc":"2.0","method":"p2p_removePeer","params":["enode://e1b2f83b7b0f5845cc74ca12bb40152e520842bbd0597b7770cb459bd40f109178811ebddd6d640100cdb9b661a3a43a9811d9fdc63770032a3f2524257fb62d@192.168.74.1:55555"], "id": 3}' -H "Content-Type:application/json" response:
type P2pService ¶
func (*P2pService) AddPeer ¶
func (p2pService *P2pService) AddPeer(nodeUrl string) error
func (*P2pService) AddProtocols ¶
func (p2pService *P2pService) AddProtocols(protocols []p2p.Protocol)
func (*P2pService) Api ¶
func (p2pService *P2pService) Api() []app.API
func (*P2pService) CommandFlags ¶
func (p2pService *P2pService) CommandFlags() ([]cli.Command, []cli.Flag)
func (*P2pService) DefaultConfig ¶
func (p2pService *P2pService) DefaultConfig(netType params.NetType) *p2pTypes.P2pConfig
func (*P2pService) Init ¶
func (p2pService *P2pService) Init(executeContext *app.ExecuteContext) error
func (*P2pService) LocalNode ¶
func (p2pService *P2pService) LocalNode() *enode.Node
func (*P2pService) Name ¶
func (p2pService *P2pService) Name() string
func (*P2pService) Peers ¶
func (p2pService *P2pService) Peers() []*p2p.Peer
func (*P2pService) RemovePeer ¶
func (p2pService *P2pService) RemovePeer(nodeUrl string)
nodeUrl:"enode://e1b2f83b7b0f5845cc74ca12bb40152e520842bbd0597b7770cb459bd40f109178811ebddd6d640100cdb9b661a3a43a9811d9fdc63770032a3f2524257fb62d@192.168.74.1:55555"
func (*P2pService) Send ¶
func (p2pService *P2pService) Send(rw p2p.MsgWriter, msgType uint64, msg interface{}) error
func (*P2pService) SendAsync ¶
func (p2pService *P2pService) SendAsync(w p2p.MsgWriter, msgType uint64, msg interface{}) chan error
func (*P2pService) Start ¶
func (p2pService *P2pService) Start(executeContext *app.ExecuteContext) error
func (*P2pService) Stop ¶
func (p2pService *P2pService) Stop(executeContext *app.ExecuteContext) error