service

package
v0.0.0-...-9faecf3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2020 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MODULENAME = "p2p"
)
View Source
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

func (p2pApis *P2PApi) AddPeer(addr string)

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

func (p2pApis *P2PApi) GetPeers() []string

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) LocalNode

func (p2pApis *P2PApi) LocalNode() *enode.Node

func (*P2PApi) RemovePeer

func (p2pApis *P2PApi) RemovePeer(addr string)

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

type P2pService struct {
	Config *p2pTypes.P2pConfig
	// contains filtered or unexported fields
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL