Documentation ¶
Index ¶
- Constants
- Variables
- type CrossNodeInfo
- type CrossPeerInfo
- type CrossPool
- func (pool *CrossPool) AddLocals(txs ...*cc.CrossTransaction) (signed []*cc.CrossTransaction, commits []*cc.CrossTransactionWithSignatures, ...)
- func (pool *CrossPool) AddRemote(ctx *cc.CrossTransaction) (signer common.Address, err error)
- func (pool *CrossPool) AddRemotes(ctxList []*cc.CrossTransaction) ([]common.Address, []error)
- func (pool *CrossPool) Commit(txs []*cc.CrossTransactionWithSignatures)
- func (pool *CrossPool) GetLocal(ctxID common.Hash) *cc.CrossTransaction
- func (pool *CrossPool) Pending(startNumber uint64, limit int) (ids []common.Hash, pending []*cc.CrossTransactionWithSignatures)
- func (pool *CrossPool) Rollback(cws *cc.CrossTransactionWithSignatures, invalidSigIndex []int)
- func (pool *CrossPool) Stats() (int, int)
- func (pool *CrossPool) Stop()
- func (pool *CrossPool) Store(cwsList []*cc.CrossTransactionWithSignatures)
- func (pool *CrossPool) SubscribeSignedCtxEvent(ch chan<- cc.SignedCtxEvent) event.Subscription
- type CrossService
- func (srv *CrossService) APIs() []rpc.API
- func (srv *CrossService) BroadcastCrossTx(ctxs []*cc.CrossTransaction, local bool)
- func (srv *CrossService) NodeInfo() *CrossNodeInfo
- func (srv *CrossService) Protocols() []p2p.Protocol
- func (srv *CrossService) Start(server *p2p.Server) error
- func (srv *CrossService) Stop() error
- type CrossStore
- func (s *CrossStore) Add(ctx *cc.CrossTransactionWithSignatures) error
- func (s *CrossStore) Adds(chainID *big.Int, ctxList []*cc.CrossTransactionWithSignatures, ...) error
- func (s *CrossStore) Close()
- func (s *CrossStore) Get(chainID *big.Int, ctxID common.Hash) *cc.CrossTransactionWithSignatures
- func (s *CrossStore) GetStore(chainID *big.Int) (cdb.CtxDB, error)
- func (s *CrossStore) Height(chainID *big.Int) uint64
- func (s *CrossStore) RegisterChain(chainID *big.Int) cdb.CtxDB
- func (s *CrossStore) Stats() map[uint64]map[cc.CtxStatus]int
- func (s *CrossStore) Updates(chainID *big.Int, txmList []*cc.CrossTransactionModifier) error
- type Handler
- func (h *Handler) AddRemoteCtx(ctx *cc.CrossTransaction) error
- func (h *Handler) FindByTxHash(hash common.Hash) *cc.CrossTransactionWithSignatures
- func (h *Handler) GetByBlockNumber(begin, end uint64) []*cc.CrossTransactionWithSignatures
- func (h *Handler) GetByCtxID(id common.Hash) *cc.CrossTransactionWithSignatures
- func (h *Handler) GetCrossTransactionByHeight(height uint64, limit int) []*cc.CrossTransactionWithSignatures
- func (h *Handler) GetPending(ids []common.Hash) []*cc.CrossTransaction
- func (h *Handler) Height() *big.Int
- func (h *Handler) LocalID() uint64
- func (h *Handler) Pending(start uint64, limit int) (ids []common.Hash)
- func (h *Handler) PoolStats() (int, int)
- func (h *Handler) QueryByPage(localSize, localPage, remoteSize, remotePage int) (locals map[uint64][]*cc.CrossTransactionWithSignatures, ...)
- func (h *Handler) QueryLocalBySenderAndPage(from common.Address, pageSize, startPage int) (locals map[uint64][]*cc.OwnerCrossTransactionWithSignatures, total int)
- func (h *Handler) QueryLocalIllegalByPage(pageSize, startPage int) []*cc.CrossTransactionWithSignatures
- func (h *Handler) QueryRemoteByDestinationValueAndPage(value *big.Int, pageSize, startPage int) (remoteID uint64, txs []*cc.CrossTransactionWithSignatures, total int)
- func (h *Handler) QueryRemoteByTakerAndPage(to common.Address, pageSize, startPage int) (remotes map[uint64][]*cc.OwnerCrossTransactionWithSignatures, total int)
- func (h *Handler) RegisterChain(chainID *big.Int)
- func (h *Handler) RemoteID() uint64
- func (h *Handler) RemoveCrossTransactionBefore(number uint64) int
- func (h *Handler) SetStoreDelay(number uint64)
- func (h *Handler) Start()
- func (h *Handler) Stop()
- func (h *Handler) StoreStats() map[uint64]map[cc.CtxStatus]int
- type MonitorInfo
- type NodeInfo
- type PrivateCrossAdminAPI
- func (s *PrivateCrossAdminAPI) Anchors() map[uint64][]common.Address
- func (s *PrivateCrossAdminAPI) Height() map[string]hexutil.Uint64
- func (s *PrivateCrossAdminAPI) ImportMainCtx(ctxWithSignsSArgs hexutil.Bytes) error
- func (s *PrivateCrossAdminAPI) ImportSubCtx(ctxWithSignsSArgs hexutil.Bytes) error
- func (s *PrivateCrossAdminAPI) Peers() (infos []*CrossPeerInfo, err error)
- func (s *PrivateCrossAdminAPI) Remove(chainID *hexutil.Big, number hexutil.Uint64) bool
- func (s *PrivateCrossAdminAPI) Repair() (bool, error)
- func (s *PrivateCrossAdminAPI) SetStoreDelay(chainID *hexutil.Big, number hexutil.Uint64) bool
- func (s *PrivateCrossAdminAPI) Stats() map[uint64]map[cc.CtxStatus]int
- func (s *PrivateCrossAdminAPI) SyncPending() (bool, error)
- func (s *PrivateCrossAdminAPI) SyncStore() (bool, error)
- type PublicCrossChainAPI
- func (s *PublicCrossChainAPI) CtxContentByPage(localSize, localPage, remoteSize, remotePage int) map[string]RPCPageCrossTransactions
- func (s *PublicCrossChainAPI) CtxGet(id common.Hash) *RPCCrossTransaction
- func (s *PublicCrossChainAPI) CtxGetByNumber(begin, end hexutil.Uint64) map[cc.CtxStatus][]common.Hash
- func (s *PublicCrossChainAPI) CtxIllegalByPage(pageSize, startPage int) *RPCPageCrossTransactions
- func (s *PublicCrossChainAPI) CtxOwner(from common.Address) map[string]map[uint64][]*RPCOwnerCrossTransaction
- func (s *PublicCrossChainAPI) CtxOwnerByPage(from common.Address, pageSize, startPage int) RPCPageOwnerCrossTransactions
- func (s *PublicCrossChainAPI) CtxQuery(hash common.Hash) *RPCCrossTransaction
- func (s *PublicCrossChainAPI) CtxQueryDestValue(value *hexutil.Big, pageSize, startPage int) *RPCPageCrossTransactions
- func (s *PublicCrossChainAPI) CtxTakerByPage(to common.Address, pageSize, startPage int) RPCPageOwnerCrossTransactions
- func (s *PublicCrossChainAPI) Monitor() MonitorInfo
- func (s *PublicCrossChainAPI) PoolStats() map[string]int
- type RPCCrossTransaction
- type RPCOwnerCrossTransaction
- type RPCPageCrossTransactions
- type RPCPageOwnerCrossTransactions
Constants ¶
const ( StatusMsg = 0x00 CtxSignMsg = 0x31 GetCtxSyncMsg = 0x32 CtxSyncMsg = 0x33 GetPendingSyncMsg = 0x34 PendingSyncMsg = 0x35 )
const ( ErrMsgTooLarge = iota ErrDecode ErrInvalidMsgCode ErrProtocolVersionMismatch ErrNetworkIDMismatch ErrGenesisMismatch ErrNoStatusMsg ErrExtraStatusMsg ErrCrossMainChainMismatch ErrCrossSubChainMismatch )
Variables ¶
var ( ErrClosed = errors.New("peer set is closed") ErrAlreadyRegistered = errors.New("peer is already registered") ErrNotRegistered = errors.New("peer is not registered") )
var ErrInvalidChainStore = errors.New("invalid chain store, chainID can not be nil")
Functions ¶
This section is empty.
Types ¶
type CrossNodeInfo ¶
type CrossPeerInfo ¶
type CrossPool ¶ added in v1.0.5
type CrossPool struct {
// contains filtered or unexported fields
}
CrossPool is used for collecting multisign signatures
func NewCrossPool ¶ added in v1.0.5
func (*CrossPool) AddLocals ¶ added in v1.0.6
func (pool *CrossPool) AddLocals(txs ...*cc.CrossTransaction) ( signed []*cc.CrossTransaction, commits []*cc.CrossTransactionWithSignatures, errs []error)
AddLocal CrossTransactions synced from blockchain subscriber @signed: ctx signed by local anchor @commits: ctx signed completely, commit to signedCtxCh @errs: errors
func (*CrossPool) AddRemotes ¶ added in v1.0.6
func (*CrossPool) Commit ¶ added in v1.0.5
func (pool *CrossPool) Commit(txs []*cc.CrossTransactionWithSignatures)
Commit signed ctx with callback
func (*CrossPool) GetLocal ¶ added in v1.0.5
func (pool *CrossPool) GetLocal(ctxID common.Hash) *cc.CrossTransaction
GetLocal get local signed CrossTransaction from pool & store
func (*CrossPool) Pending ¶ added in v1.0.5
func (pool *CrossPool) Pending(startNumber uint64, limit int) (ids []common.Hash, pending []*cc.CrossTransactionWithSignatures)
Pending return pending ctx by height
func (*CrossPool) Rollback ¶ added in v1.0.6
func (pool *CrossPool) Rollback(cws *cc.CrossTransactionWithSignatures, invalidSigIndex []int)
Rollback ctx to pending and remove its invalid signatures
func (*CrossPool) Store ¶ added in v1.0.6
func (pool *CrossPool) Store(cwsList []*cc.CrossTransactionWithSignatures)
Store ctx into CrossStore
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.ServiceContext, config cross.Config) (srv *CrossService, err 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) Stop ¶
func (srv *CrossService) Stop() error
type CrossStore ¶
type CrossStore struct {
// contains filtered or unexported fields
}
CrossStore store cross transactions into CtxDBs
func NewCrossStore ¶
func NewCrossStore(ctx cdb.ServiceContext, makerDb string) (*CrossStore, error)
func (*CrossStore) Add ¶ added in v1.0.6
func (s *CrossStore) Add(ctx *cc.CrossTransactionWithSignatures) error
func (*CrossStore) Adds ¶ added in v1.0.6
func (s *CrossStore) Adds(chainID *big.Int, ctxList []*cc.CrossTransactionWithSignatures, replaceable bool) error
func (*CrossStore) Close ¶ added in v1.0.5
func (s *CrossStore) Close()
func (*CrossStore) Get ¶ added in v1.0.6
func (s *CrossStore) Get(chainID *big.Int, ctxID common.Hash) *cc.CrossTransactionWithSignatures
func (*CrossStore) RegisterChain ¶
func (s *CrossStore) RegisterChain(chainID *big.Int) cdb.CtxDB
func (*CrossStore) Updates ¶ added in v1.0.6
func (s *CrossStore) Updates(chainID *big.Int, txmList []*cc.CrossTransactionModifier) error
Updates change tx status by block logs
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewCrossHandler ¶
func NewCrossHandler(ctx *cross.ServiceContext, service *CrossService, crossMsgReader <-chan interface{}, crossMsgWriter chan<- interface{}) (h *Handler, err error)
func (*Handler) AddRemoteCtx ¶
func (h *Handler) AddRemoteCtx(ctx *cc.CrossTransaction) error
往pool里添加从P2P网络接收的ctx与节点签名信息
func (*Handler) FindByTxHash ¶ added in v1.0.4
func (h *Handler) FindByTxHash(hash common.Hash) *cc.CrossTransactionWithSignatures
func (*Handler) GetByBlockNumber ¶ added in v1.0.6
func (h *Handler) GetByBlockNumber(begin, end uint64) []*cc.CrossTransactionWithSignatures
func (*Handler) GetByCtxID ¶ added in v1.0.6
func (h *Handler) GetByCtxID(id common.Hash) *cc.CrossTransactionWithSignatures
func (*Handler) GetCrossTransactionByHeight ¶ added in v1.0.6
func (h *Handler) GetCrossTransactionByHeight(height uint64, limit int) []*cc.CrossTransactionWithSignatures
func (*Handler) GetPending ¶ added in v1.0.6
func (h *Handler) GetPending(ids []common.Hash) []*cc.CrossTransaction
通过id获取本地pool.pending或store中的交易,并添加自己的签名
func (*Handler) QueryByPage ¶ added in v1.0.4
func (h *Handler) QueryByPage(localSize, localPage, remoteSize, remotePage int) ( locals map[uint64][]*cc.CrossTransactionWithSignatures, remotes map[uint64][]*cc.CrossTransactionWithSignatures, lt int, rt int)
func (*Handler) QueryLocalBySenderAndPage ¶ added in v1.0.4
func (*Handler) QueryLocalIllegalByPage ¶ added in v1.0.6
func (h *Handler) QueryLocalIllegalByPage(pageSize, startPage int) []*cc.CrossTransactionWithSignatures
func (*Handler) QueryRemoteByDestinationValueAndPage ¶ added in v1.0.4
func (*Handler) QueryRemoteByTakerAndPage ¶ added in v1.0.6
func (*Handler) RegisterChain ¶ added in v1.0.6
func (*Handler) RemoveCrossTransactionBefore ¶ added in v1.0.6
在store删除number区块高度之前的finished状态的跨链交易,并持久化到txLog中
func (*Handler) SetStoreDelay ¶ added in v1.0.6
设置store定期清除finished的交易 @number: 在number高度以下的交易会被定期清理
type MonitorInfo ¶ added in v1.0.6
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) Anchors ¶ added in v1.0.6
func (s *PrivateCrossAdminAPI) Anchors() map[uint64][]common.Address
func (*PrivateCrossAdminAPI) Height ¶ added in v1.0.4
func (s *PrivateCrossAdminAPI) Height() map[string]hexutil.Uint64
func (*PrivateCrossAdminAPI) ImportMainCtx ¶ added in v1.0.6
func (s *PrivateCrossAdminAPI) ImportMainCtx(ctxWithSignsSArgs hexutil.Bytes) error
func (*PrivateCrossAdminAPI) ImportSubCtx ¶ added in v1.0.6
func (s *PrivateCrossAdminAPI) ImportSubCtx(ctxWithSignsSArgs hexutil.Bytes) error
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) SetStoreDelay ¶ added in v1.0.6
func (*PrivateCrossAdminAPI) Stats ¶ added in v1.0.6
func (s *PrivateCrossAdminAPI) Stats() map[uint64]map[cc.CtxStatus]int
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
}
func NewPublicCrossChainAPI ¶
func NewPublicCrossChainAPI(handler *Handler) *PublicCrossChainAPI
func (*PublicCrossChainAPI) CtxContentByPage ¶ added in v1.0.4
func (s *PublicCrossChainAPI) CtxContentByPage(localSize, localPage, remoteSize, remotePage int) map[string]RPCPageCrossTransactions
func (*PublicCrossChainAPI) CtxGet ¶ added in v1.0.6
func (s *PublicCrossChainAPI) CtxGet(id common.Hash) *RPCCrossTransaction
func (*PublicCrossChainAPI) CtxGetByNumber ¶ added in v1.0.6
func (*PublicCrossChainAPI) CtxIllegalByPage ¶ added in v1.0.6
func (s *PublicCrossChainAPI) CtxIllegalByPage(pageSize, startPage int) *RPCPageCrossTransactions
func (*PublicCrossChainAPI) CtxOwner ¶
func (s *PublicCrossChainAPI) CtxOwner(from common.Address) map[string]map[uint64][]*RPCOwnerCrossTransaction
func (*PublicCrossChainAPI) CtxOwnerByPage ¶ added in v1.0.4
func (s *PublicCrossChainAPI) CtxOwnerByPage(from common.Address, pageSize, startPage int) RPCPageOwnerCrossTransactions
func (*PublicCrossChainAPI) CtxQuery ¶
func (s *PublicCrossChainAPI) CtxQuery(hash common.Hash) *RPCCrossTransaction
func (*PublicCrossChainAPI) CtxQueryDestValue ¶ added in v1.0.4
func (s *PublicCrossChainAPI) CtxQueryDestValue(value *hexutil.Big, pageSize, startPage int) *RPCPageCrossTransactions
func (*PublicCrossChainAPI) CtxTakerByPage ¶ added in v1.0.6
func (s *PublicCrossChainAPI) CtxTakerByPage(to common.Address, pageSize, startPage int) RPCPageOwnerCrossTransactions
func (*PublicCrossChainAPI) Monitor ¶ added in v1.0.6
func (s *PublicCrossChainAPI) Monitor() MonitorInfo
func (*PublicCrossChainAPI) PoolStats ¶ added in v1.0.4
func (s *PublicCrossChainAPI) PoolStats() map[string]int
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"` To common.Address `json:"to"` BlockHash common.Hash `json:"blockHash"` BlockNumber hexutil.Uint64 `json:"blockNumber"` 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"` To common.Address `json:"to"` BlockHash common.Hash `json:"blockHash"` BlockNumber hexutil.Uint64 `json:"blockNumber"` 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"`
}
type RPCPageOwnerCrossTransactions ¶ added in v1.0.4
type RPCPageOwnerCrossTransactions struct {
Data map[uint64][]*RPCOwnerCrossTransaction `json:"data"`
}