layer2

package
v0.0.0-...-4c49fd5 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: GPL-2.0, GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SmpcProtocol_type = discover.Smpcprotocol_type
	Xprotocol_type    = discover.Xprotocol_type
	Sdkprotocol_type  = discover.Sdkprotocol_type
	ProtocolName      = "smpc"
	Xp_ProtocolName   = "xp"

	Smpc_msgCode
	Sdk_msgCode
	Xp_msgCode

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

)

TODO

Variables

View Source
var (
	Smpc_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(threshold string, enodes []string, subGroup bool) (bool, error)

func CreateSDKGroup

func CreateSDKGroup(threshold string, enodes []string, subGroup bool) (string, int, string)

1 + 1 + 1

func GetEnode

func GetEnode() string

func GetEnodeStatus

func GetEnodeStatus(enode string) (string, error)

func GetEnodes

func GetEnodes() (int, string)

func GetGIDFromEnodes

func GetGIDFromEnodes(enodes []string) (string, error)

func GetGroup

func GetGroup() (int, string)

func GetGroupList

func GetGroupList() map[discover.NodeID]*discover.Group

func GetGroupSDKAll

func GetGroupSDKAll() []*discover.Group

func GetSelfDir

func GetSelfDir() string

func GetSelfID

func GetSelfID() string

func HandlePeer

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

func HexID

func HexID(gID string) (discover.NodeID, error)

func InitIPPort

func InitIPPort(port int)

func InitP2pDir

func InitP2pDir()

func InitSelfNodeID

func InitSelfNodeID(nodeid string)

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 RegisterRecvCallback

func RegisterRecvCallback(recvPrivkeyFunc func(interface{}))

func RegisterSendCallback

func RegisterSendCallback(callbackfunc func(interface{}))

func RegisterSmpcCallback

func RegisterSmpcCallback(smpccallback func(interface{}) <-chan string)

func RegisterSmpcRetCallback

func RegisterSmpcRetCallback(smpccallback 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)

=============================== SMPC =================================

func SendMsgToPeer

func SendMsgToPeer(enode string, msg string) error

func SendToMyself

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

func SendToPeer

func SendToPeer(enode string, msg string)

func SendToSmpcGroupAllNodes

func SendToSmpcGroupAllNodes(msg string) (string, error)

func SmpcProtocol_broadcastInGroupAll

func SmpcProtocol_broadcastInGroupAll(msg string)

broadcast to group's nodes

func SmpcProtocol_broadcastInGroupOthers

func SmpcProtocol_broadcastInGroupOthers(msg string)

func SmpcProtocol_getEnodes

func SmpcProtocol_getEnodes() (int, string)

func SmpcProtocol_getGroup

func SmpcProtocol_getGroup() (int, string)

get info

func SmpcProtocol_registerMsgRecvCallback

func SmpcProtocol_registerMsgRecvCallback(smpccallback func(interface{}) <-chan string)

receive message from dccp

func SmpcProtocol_registerMsgRetCallback

func SmpcProtocol_registerMsgRetCallback(smpccallback func(interface{}))

receive message from dccp result

func SmpcProtocol_registerPriKeyCallback

func SmpcProtocol_registerPriKeyCallback(recvPrivkeyFunc func(interface{}))

callback receive private key

func SmpcProtocol_registerRecvCallback

func SmpcProtocol_registerRecvCallback(recvSmpcFunc func(interface{}) <-chan string)

receive message form peers

func SmpcProtocol_sendMsgToNode

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

unicast to anyone

func SmpcProtocol_sendMsgToPeer

func SmpcProtocol_sendMsgToPeer(enode string, msg string) error

to peers

func SmpcProtocol_sendToGroupOneNode

func SmpcProtocol_sendToGroupOneNode(msg string) (string, error)

txs start

func Smpc_callEvent

func Smpc_callEvent(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 Emitter

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

func NewEmitter

func NewEmitter() *Emitter

type Group

type Group discover.Group

type Smpc

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

func SmpcNew

func SmpcNew(cfg *Config) *Smpc

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

func (*Smpc) APIs

func (smpc *Smpc) APIs() []rpc.API

APIs returns the RPC descriptors the Whisper implementation offers

func (*Smpc) Protocols

func (smpc *Smpc) Protocols() []p2p.Protocol

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

func (*Smpc) Start

func (smpc *Smpc) Start(server *p2p.Server) error

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

func (*Smpc) Stop

func (smpc *Smpc) Stop() error

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

type SmpcAPI

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

func (*SmpcAPI) Peers

func (smpc *SmpcAPI) Peers(ctx context.Context) []*p2p.PeerInfo

func (*SmpcAPI) Version

func (smpc *SmpcAPI) Version(ctx context.Context) (v string)

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