backend

package
v1.0.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CtxSignMsg        = 0x31
	GetCtxSyncMsg     = 0x32
	CtxSyncMsg        = 0x33
	GetPendingSyncMsg = 0x34
	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) GetLocal added in v1.0.4

func (store *CrossStore) GetLocal(ctxID common.Hash) *cc.CrossTransaction

func (*CrossStore) GetSyncCrossTransactions

func (store *CrossStore) GetSyncCrossTransactions(reqHeight, maxHeight uint64, pageSize int) []*cc.CrossTransactionWithSignatures

func (*CrossStore) Height

func (store *CrossStore) Height() uint64

func (*CrossStore) LocalStats added in v1.0.4

func (store *CrossStore) LocalStats() int

func (*CrossStore) MarkStatus

func (store *CrossStore) MarkStatus(txms []*cc.CrossTransactionModifier, status cc.CtxStatus)

func (*CrossStore) Pending added in v1.0.4

func (store *CrossStore) Pending(number uint64, limit int, exclude map[common.Hash]bool) (pending []common.Hash)

func (*CrossStore) PoolStats added in v1.0.4

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

for api

func (*CrossStore) Query

func (store *CrossStore) Query(localPageSize, localPage, remotePageSize, remotePage int) (map[uint64][]*cc.CrossTransactionWithSignatures, map[uint64][]*cc.CrossTransactionWithSignatures)

func (*CrossStore) QueryLocal added in v1.0.4

func (store *CrossStore) QueryLocal(localPageSize, localPage int) map[uint64][]*cc.CrossTransactionWithSignatures

func (*CrossStore) QueryLocalBySender added in v1.0.4

func (store *CrossStore) QueryLocalBySender(from common.Address, pageSize, startPage int) map[uint64][]*cc.OwnerCrossTransactionWithSignatures

func (*CrossStore) QueryRemote added in v1.0.4

func (store *CrossStore) QueryRemote(remotePageSize, remotePage int) map[uint64][]*cc.CrossTransactionWithSignatures

func (*CrossStore) RegisterChain

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

func (*CrossStore) RemoteStats added in v1.0.4

func (store *CrossStore) RemoteStats() int

func (*CrossStore) RemoveRemotes

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

func (*CrossStore) SenderStats added in v1.0.4

func (store *CrossStore) SenderStats(from common.Address) int

func (*CrossStore) Stop

func (store *CrossStore) Stop()

func (*CrossStore) StoreStats

func (store *CrossStore) StoreStats() (int, 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) FindByTxHash added in v1.0.4

func (h *Handler) FindByTxHash(hash common.Hash) *cc.CrossTransactionWithSignatures

func (*Handler) GetSyncCrossTransaction

func (h *Handler) GetSyncCrossTransaction(height uint64, syncSize int) []*cc.CrossTransactionWithSignatures

func (*Handler) GetSyncPending added in v1.0.4

func (h *Handler) GetSyncPending(ids []common.Hash) []*cc.CrossTransaction

func (*Handler) Height added in v1.0.4

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

for cross store sync

func (*Handler) Pending added in v1.0.4

func (h *Handler) Pending(limit int, exclude map[common.Hash]bool) (ids []common.Hash)

for ctx pending sync

func (*Handler) PoolStats added in v1.0.4

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

func (*Handler) Query

func (*Handler) QueryByPage added in v1.0.4

func (h *Handler) QueryByPage(localSize, localPage, remoteSize, remotePage int) (map[uint64][]*cc.CrossTransactionWithSignatures, map[uint64][]*cc.CrossTransactionWithSignatures, int, int)

func (*Handler) QueryLocal added in v1.0.4

func (h *Handler) QueryLocal() (map[uint64][]*cc.CrossTransactionWithSignatures, int)

func (*Handler) QueryLocalByPage added in v1.0.4

func (h *Handler) QueryLocalByPage(pageSize, startPage int) (map[uint64][]*cc.CrossTransactionWithSignatures, int)

func (*Handler) QueryLocalBySender added in v1.0.4

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

func (*Handler) QueryLocalBySenderAndPage added in v1.0.4

func (h *Handler) QueryLocalBySenderAndPage(from common.Address, pageSize, startPage int) (map[uint64][]*cc.OwnerCrossTransactionWithSignatures, int)

func (*Handler) QueryRemote added in v1.0.4

func (h *Handler) QueryRemote() (map[uint64][]*cc.CrossTransactionWithSignatures, int)

func (*Handler) QueryRemoteByDestinationValueAndPage added in v1.0.4

func (h *Handler) QueryRemoteByDestinationValueAndPage(value *big.Int, pageSize, startPage int) (*big.Int, []*cc.CrossTransactionWithSignatures, int)

func (*Handler) QueryRemoteByPage added in v1.0.4

func (h *Handler) QueryRemoteByPage(pageSize, startPage int) (map[uint64][]*cc.CrossTransactionWithSignatures, int)

func (*Handler) Start

func (h *Handler) Start()

func (*Handler) Stop

func (h *Handler) Stop()

func (*Handler) StoreStats added in v1.0.4

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

func (*Handler) SyncCrossTransaction

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

func (*Handler) SyncPending added in v1.0.4

func (h *Handler) SyncPending(ctxs []*cc.CrossTransaction) map[common.Hash]bool

type PrivateCrossAdminAPI added in v1.0.4

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

func NewPrivateCrossAdminAPI added in v1.0.4

func NewPrivateCrossAdminAPI(service *CrossService) *PrivateCrossAdminAPI

func (*PrivateCrossAdminAPI) Height added in v1.0.4

func (s *PrivateCrossAdminAPI) Height() map[string]hexutil.Uint64

func (*PrivateCrossAdminAPI) Peers added in v1.0.4

func (s *PrivateCrossAdminAPI) Peers() (infos []*CrossPeerInfo, err error)

func (*PrivateCrossAdminAPI) Repair added in v1.0.4

func (s *PrivateCrossAdminAPI) Repair() (bool, error)

func (*PrivateCrossAdminAPI) SyncPending added in v1.0.4

func (s *PrivateCrossAdminAPI) SyncPending() (bool, error)

func (*PrivateCrossAdminAPI) SyncStore added in v1.0.4

func (s *PrivateCrossAdminAPI) SyncStore() (bool, error)

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) CtxContentByPage added in v1.0.4

func (s *PublicCrossChainAPI) CtxContentByPage(localSize, localPage, remoteSize, remotePage int) map[string]RPCPageCrossTransactions

func (*PublicCrossChainAPI) CtxOwner

func (*PublicCrossChainAPI) CtxOwnerByPage added in v1.0.4

func (s *PublicCrossChainAPI) CtxOwnerByPage(ctx context.Context, from common.Address, pageSize, startPage int) RPCPageOwnerCrossTransactions

func (*PublicCrossChainAPI) CtxQuery

func (*PublicCrossChainAPI) CtxQueryDestValue added in v1.0.4

func (s *PublicCrossChainAPI) CtxQueryDestValue(ctx context.Context, value *hexutil.Big, pageSize, startPage int) *RPCPageCrossTransactions

func (*PublicCrossChainAPI) CtxStats

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

func (*PublicCrossChainAPI) GetLocalCtx

func (s *PublicCrossChainAPI) GetLocalCtx(pageSize, startPage int) RPCPageCrossTransactions

func (*PublicCrossChainAPI) GetRemoteCtx

func (s *PublicCrossChainAPI) GetRemoteCtx(pageSize, startPage int) RPCPageCrossTransactions

func (*PublicCrossChainAPI) PoolStats added in v1.0.4

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

type PublicCrossManualAPI added in v1.0.4

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

func NewPublicCrossManualAPI added in v1.0.4

func NewPublicCrossManualAPI(mainHandler, subHandler *Handler) *PublicCrossManualAPI

func (*PublicCrossManualAPI) ImportMainCtx added in v1.0.4

func (s *PublicCrossManualAPI) ImportMainCtx(ctxWithSignsSArgs hexutil.Bytes) error

func (*PublicCrossManualAPI) ImportSubCtx added in v1.0.4

func (s *PublicCrossManualAPI) ImportSubCtx(ctxWithSignsSArgs hexutil.Bytes) error

type RPCCrossTransaction

type RPCCrossTransaction struct {
	Value            *hexutil.Big   `json:"value"`
	CTxId            common.Hash    `json:"ctxId"`
	Status           string         `json:"status"`
	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"`
}

type RPCOwnerCrossTransaction

type RPCOwnerCrossTransaction struct {
	Value            *hexutil.Big   `json:"value"`
	Status           string         `json:"status"`
	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 RPCPageCrossTransactions added in v1.0.4

type RPCPageCrossTransactions struct {
	Data  map[uint64][]*RPCCrossTransaction `json:"data"`
	Total int                               `json:"total"`
}

type RPCPageOwnerCrossTransactions added in v1.0.4

type RPCPageOwnerCrossTransactions struct {
	Data  map[uint64][]*RPCOwnerCrossTransaction `json:"data"`
	Total int                                    `json:"total"`
}

type RoleHandler

type RoleHandler int
const (
	RoleMainHandler RoleHandler = iota
	RoleSubHandler
)

type SyncPendingReq added in v1.0.4

type SyncPendingReq struct {
	Chain uint64
	Ids   []common.Hash
}

type SyncPendingResp added in v1.0.4

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

type SyncReq

type SyncReq struct {
	Chain  uint64
	Height uint64
}

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