backend

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: GPL-3.0 Imports: 33 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 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 CrossPool added in v1.0.5

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

func NewCrossPool added in v1.0.5

func NewCrossPool(store *CrossStore, validator *CrossValidator, signHash cc.SignHash) *CrossPool

func (*CrossPool) AddLocal added in v1.0.5

func (pool *CrossPool) AddLocal(ctx *cc.CrossTransaction) error

func (*CrossPool) AddRemote added in v1.0.5

func (pool *CrossPool) AddRemote(ctx *cc.CrossTransaction) error

func (*CrossPool) Commit added in v1.0.5

func (pool *CrossPool) Commit(cws *cc.CrossTransactionWithSignatures)

func (*CrossPool) GetLocal added in v1.0.5

func (pool *CrossPool) GetLocal(ctxID common.Hash) *cc.CrossTransaction

func (*CrossPool) Pending added in v1.0.5

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

func (*CrossPool) Stats added in v1.0.5

func (pool *CrossPool) Stats() (int, int)

func (*CrossPool) Stop added in v1.0.5

func (pool *CrossPool) Stop()

func (*CrossPool) SubscribeSignedCtxEvent added in v1.0.5

func (pool *CrossPool) SubscribeSignedCtxEvent(ch chan<- cc.SignedCtxEvent) event.Subscription

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 {
	// contains filtered or unexported fields
}

func NewCrossStore

func NewCrossStore(ctx crossdb.ServiceContext, config cross.CtxStoreConfig, chainConfig *params.ChainConfig, chain cross.BlockChain, makerDb string) (*CrossStore, error)

func (*CrossStore) AddLocal

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

func (*CrossStore) AddRemote

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

func (*CrossStore) Close added in v1.0.5

func (store *CrossStore) Close()

func (*CrossStore) GetLocal added in v1.0.4

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

func (*CrossStore) GetSyncCrossTransactions

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

func (*CrossStore) HasLocal added in v1.0.5

func (store *CrossStore) HasLocal(ctxID common.Hash) bool

func (*CrossStore) Height

func (store *CrossStore) Height() uint64

func (*CrossStore) MarkStatus

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

func (*CrossStore) RegisterChain

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

func (*CrossStore) RemoveRemotes

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

func (*CrossStore) StoreStats

func (store *CrossStore) StoreStats() (map[cc.CtxStatus]int, map[cc.CtxStatus]int)

func (*CrossStore) SyncCrossTransactions

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

sync cross transactions (with signatures) from other anchor peers

type CrossValidator added in v1.0.5

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

func NewCrossValidator added in v1.0.5

func NewCrossValidator(store *CrossStore, contract common.Address) *CrossValidator

func (*CrossValidator) UpdateAnchors added in v1.0.5

func (v *CrossValidator) UpdateAnchors(info *cc.RemoteChainInfo) error

func (*CrossValidator) VerifyCtx added in v1.0.5

func (v *CrossValidator) VerifyCtx(ctx *cc.CrossTransaction) error

func (*CrossValidator) VerifyCwsInvoking added in v1.0.5

func (v *CrossValidator) VerifyCwsInvoking(cws *cc.CrossTransactionWithSignatures) error

send message to verify ctx in the cross contract (must exist makerTx in source-chain, do not took by others in destination-chain)

func (*CrossValidator) VerifySigner added in v1.0.5

func (v *CrossValidator) VerifySigner(ctx *cc.CrossTransaction, signChain, destChain *big.Int) error

validate ctx signed by anchor (fromChain:tx signed by fromChain, )

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 Handler

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

func NewCrossHandler

func NewCrossHandler(ctx *node.ServiceContext, chain cross.SimpleChain,
	service *CrossService, storeConfig cross.CtxStoreConfig, storePath string, contract common.Address,
	crossMsgReader <-chan interface{}, crossMsgWriter chan<- interface{},
	signHash cc.SignHash, anchorSigner common.Address) (*Handler, error)

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) LocalID added in v1.0.5

func (h *Handler) LocalID() uint64

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

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

func (*Handler) QueryRemoteByDestinationValueAndPage added in v1.0.4

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

func (*Handler) RemoteID added in v1.0.5

func (h *Handler) RemoteID() uint64

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() (map[cc.CtxStatus]int, map[cc.CtxStatus]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]map[cc.CtxStatus]int

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           cc.CtxStatus   `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           cc.CtxStatus   `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 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
}

Jump to

Keyboard shortcuts

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