layer2

package
v0.0.0-...-eb4c3ac Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

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

	Dcrm_msgCode
	Sdk_msgCode
	Xp_msgCode

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

)

TODO

Variables

View Source
var (
	Dcrm_callback func(interface{}) <-chan string
	Sdk_callback  func(interface{}, string)
	Xp_callback   func(interface{})

	SdkGroup map[discover.NodeID]*discover.Group = make(map[discover.NodeID]*discover.Group)
)
View Source
var DefaultConfig = Config{
	Nodes: make([]*discover.Node, 0),
}

Functions

func Broadcast

func Broadcast(msg string)

func BroadcastToGroup

func BroadcastToGroup(gid discover.NodeID, msg string, p2pType int, myself bool) (string, error)

func CC_startTest

func CC_startTest()

func CheckAddPeer

func CheckAddPeer(enodes []string) error

func CreateSDKGroup

func CreateSDKGroup(mode string, enodes []string) (string, int, string)

1 + 1 + 1

func DcrmProtocol_broadcastInGroupAll

func DcrmProtocol_broadcastInGroupAll(msg string)

broadcast to group's nodes

func DcrmProtocol_broadcastInGroupOthers

func DcrmProtocol_broadcastInGroupOthers(msg string)

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, error)

txs start

func Dcrm_callEvent

func Dcrm_callEvent(msg string)

func GetEnode

func GetEnode() string

func GetEnodeStatus

func GetEnodeStatus(enode string) (string, string)

func GetEnodes

func GetEnodes() (int, string)

func GetGroup

func GetGroup() (int, string)

func GetSelfID

func GetSelfID() string

func HandlePeer

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

func InitServer

func InitServer(nodeserv interface{})

func ParseNodeID

func ParseNodeID(enode string) string

func RegisterCallback

func RegisterCallback(recvFunc func(interface{}, string))

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 RegisterSendCallback

func RegisterSendCallback(callbackfunc func(interface{}))

func RegisterUpdateOrderCacheCallback

func RegisterUpdateOrderCacheCallback(recvDcrmFunc func(interface{}))

func SdkProtocol_SendToGroupAllNodes

func SdkProtocol_SendToGroupAllNodes(gID, msg string) (string, error)

func SdkProtocol_broadcastInGroupAll

func SdkProtocol_broadcastInGroupAll(gID, msg string) (string, error)

func SdkProtocol_broadcastInGroupOthers

func SdkProtocol_broadcastInGroupOthers(gID, msg string) (string, error)

func SdkProtocol_getGroup

func SdkProtocol_getGroup(gID string) (int, string)

func SdkProtocol_registerBroadcastInGroupCallback

func SdkProtocol_registerBroadcastInGroupCallback(recvSdkFunc func(interface{}, string))
---------------------   API  callback   ----------------------

recv from broadcastInGroup...

func SdkProtocol_registerSendToGroupCallback

func SdkProtocol_registerSendToGroupCallback(sdkcallback func(interface{}, string) <-chan string)

recv from sendToGroup...

func SdkProtocol_registerSendToGroupReturnCallback

func SdkProtocol_registerSendToGroupReturnCallback(sdkcallback func(interface{}, string))

recv return from sendToGroup...

func SdkProtocol_sendToGroupOneNode

func SdkProtocol_sendToGroupOneNode(gID, msg string) (string, error)

================ API SDK =====================

func Sdk_callEvent

func Sdk_callEvent(msg string, fromID string)

func SendMsg

func SendMsg(msg string)

=============================== DCRM =================================

func SendMsgToPeer

func SendMsgToPeer(enode string, msg string) error

func SendToDcrmGroupAllNodes

func SendToDcrmGroupAllNodes(msg string) (string, error)

func SendToMyself

func SendToMyself(enode, msg string, p2pType int) error

func SendToPeer

func SendToPeer(enode string, msg string)

func Xp_callEvent

func Xp_callEvent(msg string)

func Xprotocol_broadcastInGroupAll

func Xprotocol_broadcastInGroupAll(msg string)

func Xprotocol_broadcastInGroupOthers

func Xprotocol_broadcastInGroupOthers(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, error)

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 discover.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