backend

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2020 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxSignMsg        = 0x31
	GetCtxSyncMsg     = 0x32
	CtxSyncMsg        = 0x33
	GetPendingSyncMsg = 0x34 //TODO: sync pending-sign ctx when anchor restart
	PendingSyncMsg    = 0x35
)

Variables

View Source
var ErrVerifyCtx = errors.New("verify ctx failed")

Functions

func QueryAnchor

func QueryAnchor(config *params.ChainConfig, bc core.ChainContext, statedb *state.StateDB, header *types.Header,
	address common.Address, remoteChainId uint64) ([]common.Address, int)

Types

type Anchor

type Anchor = common.Address

type AnchorSet

type AnchorSet map[Anchor]struct{}

func NewAnchorSet

func NewAnchorSet(anchors []Anchor) *AnchorSet

func (AnchorSet) IsAnchor

func (as AnchorSet) IsAnchor(address common.Address) bool

func (AnchorSet) IsAnchorSignedCtx

func (as AnchorSet) IsAnchorSignedCtx(tx *cc.CrossTransaction, signer cc.CtxSigner) bool

type CallArgs

type CallArgs struct {
	From     common.Address  `json:"from"`
	To       *common.Address `json:"to"`
	Gas      hexutil.Uint64  `json:"gas"`
	GasPrice hexutil.Big     `json:"gasPrice"`
	Value    hexutil.Big     `json:"value"`
	Data     hexutil.Bytes   `json:"data"`
}

type ChainInvoke

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

func NewChainInvoke

func NewChainInvoke(chain cross.BlockChain) *ChainInvoke

func (ChainInvoke) GetTransactionNumberOnChain

func (c ChainInvoke) GetTransactionNumberOnChain(tx cross.Transaction) uint64

func (ChainInvoke) GetTransactionTimeOnChain

func (c ChainInvoke) GetTransactionTimeOnChain(tx cross.Transaction) uint64

func (ChainInvoke) IsTransactionInExpiredBlock

func (c ChainInvoke) IsTransactionInExpiredBlock(tx cross.Transaction, expiredHeight uint64) bool

type CrossNodeInfo

type CrossNodeInfo struct {
	Main eth.NodeInfo `json:"main"`
	Sub  eth.NodeInfo `json:"sub"`
}

type CrossPeerInfo

type CrossPeerInfo struct {
	Main eth.PeerInfo `json:"main"`
	Sub  eth.PeerInfo `json:"sub"`
}

type CrossService

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

CrossService implements node.Service

func NewCrossService

func NewCrossService(ctx *node.ServiceContext, main, sub cross.SimpleChain, config *eth.Config) (*CrossService, error)

func (*CrossService) APIs

func (srv *CrossService) APIs() []rpc.API

func (*CrossService) BroadcastCrossTx

func (srv *CrossService) BroadcastCrossTx(ctxs []*cc.CrossTransaction, local bool)

func (*CrossService) NodeInfo

func (srv *CrossService) NodeInfo() *CrossNodeInfo

func (*CrossService) Protocols

func (srv *CrossService) Protocols() []p2p.Protocol

func (*CrossService) Start

func (srv *CrossService) Start(server *p2p.Server) error

func (*CrossService) Stop

func (srv *CrossService) Stop() error

type CrossStore

type CrossStore struct {
	CrossContract common.Address
	// contains filtered or unexported fields
}

func NewCrossStore

func NewCrossStore(ctx crossdb.ServiceContext, config cross.CtxStoreConfig, chainConfig *params.ChainConfig, chain cross.BlockChain,
	makerDb string, address common.Address, signHash cc.SignHash) (*CrossStore, error)

func (*CrossStore) AddFromRemoteChain

func (store *CrossStore) AddFromRemoteChain(ctx *cc.CrossTransactionWithSignatures, callback func(*cc.CrossTransactionWithSignatures, ...int)) error

AddFromRemoteChain add remote-chain ctx with signatures

func (*CrossStore) AddLocal

func (store *CrossStore) AddLocal(ctx *cc.CrossTransaction) error

func (*CrossStore) AddRemote

func (store *CrossStore) AddRemote(ctx *cc.CrossTransaction) error

func (*CrossStore) GetSyncCrossTransactions

func (store *CrossStore) GetSyncCrossTransactions(chainID uint64, txID common.Hash, pageSize int) []*cc.CrossTransactionWithSignatures

func (*CrossStore) Height

func (store *CrossStore) Height() int

func (*CrossStore) ListLocalCrossTransactionBySender

func (store *CrossStore) ListLocalCrossTransactionBySender(from common.Address) map[uint64][]*cc.OwnerCrossTransactionWithSignatures

func (*CrossStore) MarkStatus

func (store *CrossStore) MarkStatus(rtxs []*cc.ReceptTransaction, status cc.CtxStatus)

func (*CrossStore) Query

func (*CrossStore) RegisterChain

func (store *CrossStore) RegisterChain(chainID *big.Int)

func (*CrossStore) RemoveLocals

func (store *CrossStore) RemoveLocals(finishes []common.Hash) []error

func (*CrossStore) RemoveRemotes

func (store *CrossStore) RemoveRemotes(rtxs []*cc.ReceptTransaction) []error

func (*CrossStore) Stats

func (store *CrossStore) Stats() (int, int)

func (*CrossStore) Stop

func (store *CrossStore) Stop()

func (*CrossStore) StoreStats

func (store *CrossStore) StoreStats() int

func (*CrossStore) SubscribeSignedCtxEvent

func (store *CrossStore) SubscribeSignedCtxEvent(ch chan<- cc.SignedCtxEvent) event.Subscription

func (*CrossStore) SyncCrossTransactions

func (store *CrossStore) SyncCrossTransactions(ctxList []*cc.CrossTransactionWithSignatures) int

sync cross transactions (with signatures) from other anchor peers

func (*CrossStore) UpdateAnchors

func (store *CrossStore) UpdateAnchors(info *cc.RemoteChainInfo) error

func (*CrossStore) VerifyCtx

func (store *CrossStore) VerifyCtx(ctx *cc.CrossTransaction) error

type EvmInvoke

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

func NewEvmInvoke

func NewEvmInvoke(bc core.ChainContext, header *types.Header, stateDB *state.StateDB, config *params.ChainConfig, vmCfg vm.Config) *EvmInvoke

func (EvmInvoke) CallContract

func (e EvmInvoke) CallContract(from common.Address, to *common.Address, function []byte, inputs ...[]byte) ([]byte, error)

type GasHelper

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

func NewGasHelper

func NewGasHelper(blockchain *core.BlockChain, chain cross.SimpleChain) *GasHelper

type Handler

type Handler struct {
	MainChainCtxAddress common.Address
	SubChainCtxAddress  common.Address
	// contains filtered or unexported fields
}

func NewCrossHandler

func NewCrossHandler(chain cross.SimpleChain, roleHandler RoleHandler, role common.ChainRole,
	service *CrossService, ctxPool *CrossStore, blockChain *core.BlockChain,
	crossMsgReader <-chan interface{}, crossMsgWriter chan<- interface{},
	mainAddr common.Address, subAddr common.Address,
	signHash cc.SignHash, anchorSigner common.Address) *Handler

func (*Handler) AddRemoteCtx

func (h *Handler) AddRemoteCtx(ctx *cc.CrossTransaction) error

func (*Handler) GetHeight

func (h *Handler) GetHeight() *big.Int

func (*Handler) GetSyncCrossTransaction

func (h *Handler) GetSyncCrossTransaction(startTxID common.Hash, syncSize int) []*cc.CrossTransactionWithSignatures

func (*Handler) ListLocalCrossTransactionBySender

func (h *Handler) ListLocalCrossTransactionBySender(from common.Address) map[uint64][]*cc.OwnerCrossTransactionWithSignatures

func (*Handler) Query

func (*Handler) Start

func (h *Handler) Start()

func (*Handler) Stats

func (h *Handler) Stats() int

func (*Handler) Status

func (h *Handler) Status() (int, int)

func (*Handler) Stop

func (h *Handler) Stop()

func (*Handler) SyncCrossTransaction

func (h *Handler) SyncCrossTransaction(ctx []*cc.CrossTransactionWithSignatures) int

type PublicCrossChainAPI

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

PublicTxPoolAPI offers and API for the transaction pool. It only operates on data that is non confidential.

func NewPublicCrossChainAPI

func NewPublicCrossChainAPI(handler *Handler) *PublicCrossChainAPI

NewPublicTxPoolAPI creates a new tx pool service that gives information about the transaction pool.

func (*PublicCrossChainAPI) CtxContent

func (s *PublicCrossChainAPI) CtxContent() map[string]map[uint64][]*RPCCrossTransaction

func (*PublicCrossChainAPI) CtxList

func (*PublicCrossChainAPI) CtxOwner

func (*PublicCrossChainAPI) CtxQuery

func (*PublicCrossChainAPI) CtxStats

func (s *PublicCrossChainAPI) CtxStats() int

func (*PublicCrossChainAPI) CtxStatus

func (s *PublicCrossChainAPI) CtxStatus() map[string]int

func (*PublicCrossChainAPI) GetLocalCtx

func (s *PublicCrossChainAPI) GetLocalCtx(count uint64) map[uint64][]*RPCCrossTransaction

func (*PublicCrossChainAPI) GetRemoteCtx

func (s *PublicCrossChainAPI) GetRemoteCtx(count uint64) map[uint64][]*RPCCrossTransaction

type RPCCrossTransaction

type RPCCrossTransaction struct {
	Value            *hexutil.Big   `json:"value"`
	CTxId            common.Hash    `json:"ctxId"`
	TxHash           common.Hash    `json:"txHash"`
	From             common.Address `json:"from"`
	BlockHash        common.Hash    `json:"blockHash"`
	DestinationId    *hexutil.Big   `json:"destinationId"`
	DestinationValue *hexutil.Big   `json:"destinationValue"`
	Input            hexutil.Bytes  `json:"input"`
	V                []*hexutil.Big `json:"v"`
	R                []*hexutil.Big `json:"r"`
	S                []*hexutil.Big `json:"s"`
}

RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction

type RPCOwnerCrossTransaction

type RPCOwnerCrossTransaction struct {
	Value            *hexutil.Big   `json:"value"`
	CTxId            common.Hash    `json:"ctxId"`
	TxHash           common.Hash    `json:"txHash"`
	From             common.Address `json:"from"`
	BlockHash        common.Hash    `json:"blockHash"`
	DestinationId    *hexutil.Big   `json:"destinationId"`
	DestinationValue *hexutil.Big   `json:"destinationValue"`
	Input            hexutil.Bytes  `json:"input"`
	Time             hexutil.Uint64 `json:"time"`
	V                []*hexutil.Big `json:"v"`
	R                []*hexutil.Big `json:"r"`
	S                []*hexutil.Big `json:"s"`
}

type RoleHandler

type RoleHandler int
const (
	RoleMainHandler RoleHandler = iota
	RoleSubHandler
)

type SyncReq

type SyncReq struct {
	Chain   uint64
	StartID common.Hash
}

type SyncResp

type SyncResp struct {
	Chain uint64
	Data  [][]byte
}

type TranParam

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

type Validator

type Validator func(cws *cc.CrossTransactionWithSignatures) error

Jump to

Keyboard shortcuts

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