networkrelay

package
v0.0.0-...-1df7544 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountRef

type AccountRef common.Address

func (AccountRef) Address

func (ar AccountRef) Address() common.Address

Address casts AccountRef to a Address

type ContractRef

type ContractRef interface {
	Address() common.Address
}

type DecodedPayload

type DecodedPayload struct {
	Addr      common.Address
	TimeStamp int64
	MsgHash   []byte
}

type DecodedScsPushMsg

type DecodedScsPushMsg struct {
	ScsId      []byte
	RequestId  []byte
	Sender     common.Address
	Receiver   common.Address
	MsgType    []byte
	SubChainId []byte
	Status     []byte
	MsgHash    []byte
}

type DecodedScsRegisterMsg

type DecodedScsRegisterMsg struct {
	ScsId      string
	RequestId  string
	Operation  string
	PublicKey  string
	Capability uint32
}

type DecodedVnodePushMsg

type DecodedVnodePushMsg struct {
	RequestId  uint32
	Sender     common.Address
	Receiver   common.Address
	Status     string
	SubChainId string
	TypeRaw    string
	Payload    DecodedPayload
}

type NetworkRelay

type NetworkRelay struct {
	ChainId uint64

	ScsServers map[string]*ScsServerConfig

	NotifyScsCache map[string]*NotifyScsMsg
	ScsServerList  *map[string]*libtypes.ScsServerConnection

	ScsRoleCache map[common.Address]map[common.Address]*RoleCache

	WhiteFlag uint64
	WhiteList []common.Hash
	WhiteFunc []common.Hash
	// contains filtered or unexported fields
}

func GetInstance

func GetInstance() *NetworkRelay

func NewNetworkRelay

func NewNetworkRelay(
	scsMsgChan chan *pb.ScsPushMsg,
	scsResChan chan *pb.ScsPushMsg,
	scsMsgChanMainnet chan *pb.ScsPushMsg,
	scsResChanMainnet chan *pb.ScsPushMsg,
	scsHandler VnodeServerInterface,
	chainId uint64,
) *NetworkRelay

func (*NetworkRelay) BroadcastMsg

func (self *NetworkRelay) BroadcastMsg(scsmsg *pb.ScsPushMsg, forceToMainnet bool)

BroadcastMsg will 1) forward the msg to other vnode 2) forward the msg to local scs node

func (*NetworkRelay) BroadcastRes

func (self *NetworkRelay) BroadcastRes(msg *pb.ScsPushMsg, forceToMainnet bool)

func (*NetworkRelay) DelScsRoleCache

func (self *NetworkRelay) DelScsRoleCache(scsId common.Address, subchainId common.Address)

func (*NetworkRelay) GetBlockNumber

func (self *NetworkRelay) GetBlockNumber() uint64

func (*NetworkRelay) GetNewRequestId

func (self *NetworkRelay) GetNewRequestId() uint32

func (*NetworkRelay) GetSCSRole

func (self *NetworkRelay) GetSCSRole(subchainId, scsId common.Address) params.ScsKind

func (*NetworkRelay) GetScsRoleCache

func (self *NetworkRelay) GetScsRoleCache(scsId common.Address, subchainId common.Address) *RoleCache

func (*NetworkRelay) MarkMsg

func (self *NetworkRelay) MarkMsg(scsId string, msg *pb.ScsPushMsg)

func (*NetworkRelay) NotifyMsgRunState

func (self *NetworkRelay) NotifyMsgRunState(hash common.Hash) bool

func (*NetworkRelay) NotifyScs

func (self *NetworkRelay) NotifyScs(address common.Address, msg []byte, hash common.Hash, blocknumber *big.Int)

func (*NetworkRelay) NotifyScsFinalize

func (self *NetworkRelay) NotifyScsFinalize(curblock *big.Int, liveFlag bool)

func (*NetworkRelay) OnReceiveMsg

func (self *NetworkRelay) OnReceiveMsg(msg *pb.ScsPushMsg)

func (*NetworkRelay) OnReceiveRegisterMsg

func (self *NetworkRelay) OnReceiveRegisterMsg(msg *pb.ScsPushMsg)

func (*NetworkRelay) OnReceiveRes

func (self *NetworkRelay) OnReceiveRes(res *pb.ScsPushMsg)

func (*NetworkRelay) Priority

func (self *NetworkRelay) Priority(contractAddr, scsId common.Address, code []byte) bool

func (*NetworkRelay) ScsMsgCheck

func (self *NetworkRelay) ScsMsgCheck(role params.ScsKind, scs common.Address, conReq *pb.ScsPushMsg) bool

func (*NetworkRelay) ServerWithoutMsg

func (self *NetworkRelay) ServerWithoutMsg(msg *pb.ScsPushMsg) []*libtypes.ScsServerConnection

func (*NetworkRelay) SetBlockNumber

func (self *NetworkRelay) SetBlockNumber(bn uint64)

func (*NetworkRelay) SetScsRoleCacheOld

func (self *NetworkRelay) SetScsRoleCacheOld(subchainId common.Address)

func (*NetworkRelay) SetScsServerList

func (self *NetworkRelay) SetScsServerList(scsServerList *map[string]*libtypes.ScsServerConnection)

func (*NetworkRelay) SetupMsgSender

func (self *NetworkRelay) SetupMsgSender(scsId string)

func (*NetworkRelay) ShouldBroadcast

func (self *NetworkRelay) ShouldBroadcast(msg *pb.ScsPushMsg) bool

func (*NetworkRelay) UpdateScsRoleCache

func (self *NetworkRelay) UpdateScsRoleCache(scsId common.Address, subchainId common.Address, role params.ScsKind)

func (*NetworkRelay) UpdateWhiteState

func (self *NetworkRelay) UpdateWhiteState(bn uint64)

func (*NetworkRelay) VnodePushMsg

func (self *NetworkRelay) VnodePushMsg(conReq *pb.ScsPushMsg) (map[int]*pb.ScsPushMsg, error)

send push msg to all connected scs servers

type NotifyScsMsg

type NotifyScsMsg struct {
	Address   *common.Address
	Msg       *[]byte
	MsgHash   *common.Hash
	Block     *big.Int
	TimeStamp time.Time
}

type RoleCache

type RoleCache struct {
	//SubchainId common.Address
	Role   params.ScsKind
	Number uint64
}

type ScsServerConfig

type ScsServerConfig struct {
	Stream    pb.Vnode_ScsPushServer
	PublicKey string
	ScsId     string
}

type VmInterface

type VmInterface interface {
	StaticCall(caller ContractRef, addr common.Address, input []byte, gas uint64) (ret []byte, leftOverGas uint64, err error)
}

type VnodeServerInterface

type VnodeServerInterface interface {
	ScsPush(stream pb.Vnode_ScsPushServer) error
	AccountInfo(ctx context.Context, in *pb.AccountInfoRequest) (*pb.AccountInfoReply, error)
	ChainInfo(ctx context.Context, in *pb.ChainInfoRequest) (*pb.ChainInfoReply, error)
	RemoteCall(ctx context.Context, in *pb.RemoteCallRequest) (*pb.RemoteCallReply, error)
	GetBlockNumber() uint64
	NotifyMsgRunState(hash common.Hash) bool
	GetSCSRole(contractAddress common.Address, nodeAddress common.Address) params.ScsKind
	GetScsPushMsgChan() chan pb.ScsPushMsg
	GetScsRegChan() chan pb.ScsPushMsg
	GetScsPushResChan() chan pb.ScsPushMsg
}

Jump to

Keyboard shortcuts

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