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) 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网络接口 usage: 设置查询网络状态 prefix:p2p
func (*P2PApi) AddPeer ¶
name: addPeer usage: 添加节点 params: enode://publickey@ip:p2p端口 return:nil example: curl http://127.0.0.1:15645 -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: 获取当前连接的节点 params: return: 和本地建立连接的p2p对端信息 example: curl http://127.0.0.1:15645 -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) RemovePeer ¶
name: removePeer usage: 移除节点 params:enode://publickey@ip:p2p端口 return:nil example: curl http://127.0.0.1:15645 -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 NewP2pService ¶
func NewP2pService(config *p2pTypes.P2pConfig, homeDir string) *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) 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