layer2

package
v0.0.0-...-872243e Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: GPL-3.0, LGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DcrmProtocol_type = discover.Dcrmprotocol_type
	Xprotocol_type    = discover.Xprotocol_type
	ProtocolName      = "dcrm"
	Xp_ProtocolName   = "xp"

	Dcrm_msgCode
	Xp_msgCode

	ProtocolVersion      = 1
	ProtocolVersionStr   = "1"
	NumberOfMessageCodes = 8 + iota // msgLength

)

TODO

Variables

View Source
var (
	Dcrm_callback func(interface{}) <-chan string
	Xp_callback   func(interface{})
)
View Source
var DefaultConfig = Config{
	Nodes: make([]*discover.Node, 0),
}

Functions

func Broadcast

func Broadcast(msg string)

func BroadcastToGroup

func BroadcastToGroup(msg string, p2pType int)

func CC_startTest

func CC_startTest()

func DcrmProtocol_broadcastInGroup

func DcrmProtocol_broadcastInGroup(msg string)

broadcast to group's nodes

func DcrmProtocol_getEnodes

func DcrmProtocol_getEnodes() (int, string)

func DcrmProtocol_getGroup

func DcrmProtocol_getGroup() (int, string)

get info

func DcrmProtocol_registerMsgRecvCallback

func DcrmProtocol_registerMsgRecvCallback(dcrmcallback func(interface{}) <-chan string)

receive message from dccp

func DcrmProtocol_registerMsgRetCallback

func DcrmProtocol_registerMsgRetCallback(dcrmcallback func(interface{}))

receive message from dccp result

func DcrmProtocol_registerPriKeyCallback

func DcrmProtocol_registerPriKeyCallback(recvPrivkeyFunc func(interface{}))

callback receive private key

func DcrmProtocol_registerRecvCallback

func DcrmProtocol_registerRecvCallback(recvDcrmFunc func(interface{}) <-chan string)

receive message form peers

func DcrmProtocol_sendMsgToNode

func DcrmProtocol_sendMsgToNode(toid discover.NodeID, toaddr *net.UDPAddr, msg string) error

unicast to anyone

func DcrmProtocol_sendMsgToPeer

func DcrmProtocol_sendMsgToPeer(enode string, msg string) error

to peers

func DcrmProtocol_sendToGroupOneNode

func DcrmProtocol_sendToGroupOneNode(msg string) string

txs start

func DcrmProtocol_startTest

func DcrmProtocol_startTest()

func Dcrm_callEvent

func Dcrm_callEvent(msg string)

func GetEnodes

func GetEnodes() (int, string)

func GetGroup

func GetGroup() (int, string)

func GetSelfID

func GetSelfID() discover.NodeID

func HandlePeer

func HandlePeer(peer *p2p.Peer, rw p2p.MsgReadWriter) error

func RegisterCallback

func RegisterCallback(recvFunc func(interface{}))

receive message form peers

func RegisterDcrmCallback

func RegisterDcrmCallback(dcrmcallback func(interface{}) <-chan string)

func RegisterDcrmRetCallback

func RegisterDcrmRetCallback(dcrmcallback func(interface{}))

func RegisterRecvCallback

func RegisterRecvCallback(recvPrivkeyFunc func(interface{}))

func RegisterUpdateOrderCacheCallback

func RegisterUpdateOrderCacheCallback(recvDcrmFunc func(interface{}))

func SendMsg

func SendMsg(msg string)

TODO

func SendMsgToPeer

func SendMsgToPeer(enode string, msg string) error

func SendToDcrmGroupAllNodes

func SendToDcrmGroupAllNodes(msg string) string

func SendToPeer

func SendToPeer(enode string, msg string)

func Xp_callEvent

func Xp_callEvent(msg string)

func Xprotocol_broadcastInGroup

func Xprotocol_broadcastInGroup(msg string)

broadcast to group's nodes

func Xprotocol_getEnodes

func Xprotocol_getEnodes() (int, string)

func Xprotocol_getGroup

func Xprotocol_getGroup() (int, string)

func Xprotocol_registerMsgRecvCallback

func Xprotocol_registerMsgRecvCallback(xpcallback func(interface{}) <-chan string)

receive message from xp

func Xprotocol_registerMsgRetCallback

func Xprotocol_registerMsgRetCallback(xpcallback func(interface{}))

receive message from dccp result

func Xprotocol_registerRecvCallback

func Xprotocol_registerRecvCallback(recvXpFunc func(interface{}))

receive message form peers

func Xprotocol_sendMsgToNode

func Xprotocol_sendMsgToNode(toid discover.NodeID, toaddr *net.UDPAddr, msg string) error

unicast to anyone

func Xprotocol_sendMsgToPeer

func Xprotocol_sendMsgToPeer(enode string, msg string) error

to peers

func Xprotocol_sendToGroupOneNode

func Xprotocol_sendToGroupOneNode(msg string) string

txs start

func Xprotocol_startTest

func Xprotocol_startTest()

Types

type Config

type Config struct {
	Nodes    []*discover.Node
	DataPath string
}

type Dcrm

type Dcrm struct {
	// contains filtered or unexported fields
}

func DcrmNew

func DcrmNew(cfg *Config) *Dcrm

p2p layer 2 New creates a Whisper client ready to communicate through the Ethereum P2P network.

func (*Dcrm) APIs

func (dcrm *Dcrm) APIs() []rpc.API

APIs returns the RPC descriptors the Whisper implementation offers

func (*Dcrm) Protocols

func (dcrm *Dcrm) Protocols() []p2p.Protocol

Protocols returns the whisper sub-protocols ran by this particular client.

func (*Dcrm) Start

func (dcrm *Dcrm) Start(server *p2p.Server) error

other Start implements node.Service, starting the background data propagation thread of the Whisper protocol.

func (*Dcrm) Stop

func (dcrm *Dcrm) Stop() error

Stop implements node.Service, stopping the background data propagation thread of the Whisper protocol.

type DcrmAPI

type DcrmAPI struct {
	// contains filtered or unexported fields
}

func (*DcrmAPI) Peers

func (dcrm *DcrmAPI) Peers(ctx context.Context) []*p2p.PeerInfo

func (*DcrmAPI) Version

func (dcrm *DcrmAPI) Version(ctx context.Context) (v string)

type Emitter

type Emitter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewEmitter

func NewEmitter() *Emitter

type Group

type Group struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewGroup

func NewGroup() *Group

type Transaction

type Transaction struct {
	Payload []byte
	Hash    atomic.Value
}

type Xp

type Xp struct {
	// contains filtered or unexported fields
}

func XpNew

func XpNew(cfg *Config) *Xp

p2p layer 2 New creates a Whisper client ready to communicate through the Ethereum P2P network.

func (*Xp) APIs

func (xp *Xp) APIs() []rpc.API

APIs returns the RPC descriptors the Whisper implementation offers

func (*Xp) Protocols

func (xp *Xp) Protocols() []p2p.Protocol

Protocols returns the whisper sub-protocols ran by this particular client.

func (*Xp) Start

func (xp *Xp) Start(server *p2p.Server) error

other Start implements node.Service, starting the background data propagation thread of the Whisper protocol.

func (*Xp) Stop

func (xp *Xp) Stop() error

Stop implements node.Service, stopping the background data propagation thread of the Whisper protocol.

type XpAPI

type XpAPI struct {
	// contains filtered or unexported fields
}

func (*XpAPI) Peers

func (xp *XpAPI) Peers(ctx context.Context) []*p2p.PeerInfo

func (*XpAPI) Version

func (xp *XpAPI) Version(ctx context.Context) (v string)

Jump to

Keyboard shortcuts

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