Documentation ¶
Index ¶
- Constants
- Variables
- type AnnounceBody
- type AnnounceQuery
- type BlockChain
- type DownloadHeader
- type DownloadHeaderQuery
- type Downloader
- type HeaderHashSync
- type HeaderHashSyncQuery
- type LightBackend
- func (l *LightBackend) ChainBackend() api.Chain
- func (l *LightBackend) GetAccountIndexDB() database.Database
- func (l *LightBackend) GetBlock(hash common.Hash, height int64) (*types.Block, error)
- func (l *LightBackend) GetBlockTotalDifficulty(hash common.Hash) (*big.Int, error)
- func (l *LightBackend) GetDebt(debtHash common.Hash) (*types.Debt, *api.BlockIndex, error)
- func (l *LightBackend) GetIndexAccountDB() database.Database
- func (l *LightBackend) GetNetVersion() string
- func (l *LightBackend) GetNetWorkID() string
- func (l *LightBackend) GetP2pServer() *p2p.Server
- func (l *LightBackend) GetReceiptByTxHash(hash common.Hash) (*types.Receipt, error)
- func (l *LightBackend) GetTransaction(pool api.PoolCore, bcStore store.BlockchainStore, txHash common.Hash) (*types.Transaction, *api.BlockIndex, error)
- func (l *LightBackend) IsSyncing() bool
- func (l *LightBackend) Log() *log.SeeleLog
- func (l *LightBackend) ProtocolBackend() api.Protocol
- func (l *LightBackend) RemoveTransaction(txHash common.Hash)
- func (l *LightBackend) TxPoolBackend() api.Pool
- type LightChain
- func (lc *LightChain) CurrentHeader() *types.BlockHeader
- func (lc *LightChain) GetBlockByHash(hash common.Hash) *types.Block
- func (lc *LightChain) GetCurrentState() (*state.Statedb, error)
- func (lc *LightChain) GetHeadRollbackEventManager() *event.EventManager
- func (lc *LightChain) GetHeaderByHash(hash common.Hash) *types.BlockHeader
- func (lc *LightChain) GetHeaderByHeight(height uint64) *types.BlockHeader
- func (lc *LightChain) GetState(root common.Hash) (*state.Statedb, error)
- func (lc *LightChain) GetStateByRootAndBlockHash(root, blockHash common.Hash) (*state.Statedb, error)
- func (lc *LightChain) GetStore() store.BlockchainStore
- func (lc *LightChain) PutCurrentHeader(header *types.BlockHeader)
- func (lc *LightChain) PutTd(td *big.Int)
- func (lc *LightChain) WriteHeader(header *types.BlockHeader) error
- type LightProtocol
- type OdrItem
- type OdrProvableResponse
- type PeerInfo
- type ServiceClient
- type ServiceServer
- type TransactionPool
Constants ¶
const ( // LightProtoName protoName of Seele service LightProtoName = "lightSeele" // LightSeeleVersion version number of Seele protocol LightSeeleVersion uint = 1 // MaxBlockHashRequest maximum hashes to request per message MaxBlockHashRequest uint64 = 1024 // MaxBlockHeaderRequest maximum headers to request per message MaxBlockHeaderRequest uint64 = 256 // MaxGapForAnnounce sends AnnounceQuery message if gap is more than this value MaxGapForAnnounce uint64 = 256 // MinHashesCached minimum items cached in peer for client mode MinHashesCached uint64 = 256 )
const ( // DiscHandShakeErr disconnect due to failed to shake hands in light mode DiscHandShakeErr = "disconnect because get error when handshaking of light mode" // DiscAnnounceErr disconnect due to failed to send announce message DiscAnnounceErr = "disconnect because send announce message err" )
Variables ¶
var ( // ErrIsSynchronising indicates the synchronising is in processing ErrIsSynchronising = errors.New("Is synchronising") )
Functions ¶
This section is empty.
Types ¶
type AnnounceBody ¶
type AnnounceBody struct { Magic uint32 TD *big.Int CurrentBlock common.Hash CurrentBlockNum uint64 BlockNumArr []uint64 HeaderArr []common.Hash }
AnnounceBody body of AnnounceQuery response
type AnnounceQuery ¶
AnnounceQuery header of AnnounceQuery request
type BlockChain ¶
type BlockChain interface { GetCurrentState() (*state.Statedb, error) GetState(root common.Hash) (*state.Statedb, error) GetStateByRootAndBlockHash(root, blockHash common.Hash) (*state.Statedb, error) GetStore() store.BlockchainStore GetHeadRollbackEventManager() *event.EventManager CurrentHeader() *types.BlockHeader WriteHeader(*types.BlockHeader) error PutCurrentHeader(*types.BlockHeader) PutTd(*big.Int) }
BlockChain define some interfaces related to underlying blockchain
type DownloadHeader ¶
type DownloadHeader struct { ReqID uint32 HasFinished bool Hearders []*types.BlockHeader }
DownloadHeader body of DownloadHeaderQuery response
type DownloadHeaderQuery ¶
DownloadHeaderQuery header of DownloadHeaderQuery request
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
Downloader sync block chain with remote peer
func (*Downloader) Terminate ¶
func (d *Downloader) Terminate()
Terminate close Downloader, cannot called anymore.
type HeaderHashSync ¶
type HeaderHashSync struct { Magic uint32 TD *big.Int CurrentBlock common.Hash CurrentBlockNum uint64 BeginNum uint64 HeaderArr []common.Hash }
HeaderHashSync body of HeaderHashSyncQuery response
type HeaderHashSyncQuery ¶
HeaderHashSyncQuery header of HeaderHashSyncQuery request
type LightBackend ¶
type LightBackend struct {
// contains filtered or unexported fields
}
LightBackend represents a channel (client) that communicate with backend node service.
func NewLightBackend ¶
func NewLightBackend(s *ServiceClient) *LightBackend
NewLightBackend creates a LightBackend
func (*LightBackend) ChainBackend ¶
func (l *LightBackend) ChainBackend() api.Chain
ChainBackend gets instance of blockchain
func (*LightBackend) GetAccountIndexDB ¶
func (l *LightBackend) GetAccountIndexDB() database.Database
func (*LightBackend) GetBlockTotalDifficulty ¶
GetBlockTotalDifficulty gets total difficulty by block hash
func (*LightBackend) GetDebt ¶
func (l *LightBackend) GetDebt(debtHash common.Hash) (*types.Debt, *api.BlockIndex, error)
GetDebt returns the debt and its index for the specified debt hash.
func (*LightBackend) GetIndexAccountDB ¶
func (l *LightBackend) GetIndexAccountDB() database.Database
func (*LightBackend) GetNetVersion ¶
func (l *LightBackend) GetNetVersion() string
GetNetVersion gets the network version
func (*LightBackend) GetNetWorkID ¶
func (l *LightBackend) GetNetWorkID() string
GetNetWorkID gets the network id
func (*LightBackend) GetP2pServer ¶
func (l *LightBackend) GetP2pServer() *p2p.Server
GetP2pServer gets instance of p2pServer
func (*LightBackend) GetReceiptByTxHash ¶
GetReceiptByTxHash gets block's receipt by tx hash
func (*LightBackend) GetTransaction ¶
func (l *LightBackend) GetTransaction(pool api.PoolCore, bcStore store.BlockchainStore, txHash common.Hash) (*types.Transaction, *api.BlockIndex, error)
GetTransaction gets tx, block index and its debt by tx hash
func (*LightBackend) IsSyncing ¶
func (l *LightBackend) IsSyncing() bool
func (*LightBackend) ProtocolBackend ¶
func (l *LightBackend) ProtocolBackend() api.Protocol
ProtocolBackend gets instance of seeleProtocol
func (*LightBackend) RemoveTransaction ¶
func (l *LightBackend) RemoveTransaction(txHash common.Hash)
RemoveTransaction removes tx of the specified tx hash from tx pool.
func (*LightBackend) TxPoolBackend ¶
func (l *LightBackend) TxPoolBackend() api.Pool
TxPoolBackend gets the instance of tx pool
type LightChain ¶
type LightChain struct {
// contains filtered or unexported fields
}
LightChain represents a canonical chain that by default only handles block headers.
func (*LightChain) CurrentHeader ¶
func (lc *LightChain) CurrentHeader() *types.BlockHeader
CurrentHeader returns the HEAD block header of the blockchain.
func (*LightChain) GetBlockByHash ¶
func (lc *LightChain) GetBlockByHash(hash common.Hash) *types.Block
GetHeaderByHash
func (*LightChain) GetCurrentState ¶
func (lc *LightChain) GetCurrentState() (*state.Statedb, error)
GetCurrentState get current state
func (*LightChain) GetHeadRollbackEventManager ¶
func (lc *LightChain) GetHeadRollbackEventManager() *event.EventManager
func (*LightChain) GetHeaderByHash ¶
func (lc *LightChain) GetHeaderByHash(hash common.Hash) *types.BlockHeader
GetHeaderByNumber retrieves a block header from the database by number.
func (*LightChain) GetHeaderByHeight ¶
func (lc *LightChain) GetHeaderByHeight(height uint64) *types.BlockHeader
GetHeader retrieves a block header from the database by hash and number.
func (*LightChain) GetStateByRootAndBlockHash ¶
func (*LightChain) GetStore ¶
func (lc *LightChain) GetStore() store.BlockchainStore
GetStore get underlying store
func (*LightChain) PutCurrentHeader ¶
func (lc *LightChain) PutCurrentHeader(header *types.BlockHeader)
func (*LightChain) PutTd ¶
func (lc *LightChain) PutTd(td *big.Int)
func (*LightChain) WriteHeader ¶
func (lc *LightChain) WriteHeader(header *types.BlockHeader) error
WriteHeader writes the specified block header to the blockchain.
type LightProtocol ¶
LightProtocol service implementation of seele
func NewLightProtocol ¶
func NewLightProtocol(networkID string, txPool TransactionPool, debtPool *core.DebtPool, chain BlockChain, serverMode bool, odrBackend *odrBackend, log *log.SeeleLog, shard uint) (s *LightProtocol, err error)
NewLightProtocol create LightProtocol
func (*LightProtocol) GetProtocolVersion ¶
func (lp *LightProtocol) GetProtocolVersion() (uint, error)
GetProtocolVersion gets protocol version
func (*LightProtocol) SendDifferentShardTx ¶
func (lp *LightProtocol) SendDifferentShardTx(tx *types.Transaction, shard uint)
SendDifferentShardTx send tx to another shard
func (*LightProtocol) Stop ¶
func (lp *LightProtocol) Stop()
Stop stops protocol, called when seeleService quits.
type OdrItem ¶
type OdrItem struct { ReqID uint32 // random request ID that generated dynamically Error string // response error }
OdrItem is base struct for ODR request and response.
type OdrProvableResponse ¶
type OdrProvableResponse struct { OdrItem BlockIndex *api.BlockIndex `rlp:"nil"` Proof []proofNode }
OdrProvableResponse represents all provable ODR response.
type PeerInfo ¶
type PeerInfo struct { Version uint `json:"version"` // Seele protocol version negotiated Difficulty *big.Int `json:"difficulty"` // Total difficulty of the peer's blockchain Head string `json:"head"` // SHA3 hash of the peer's best owned block }
PeerInfo represents a short summary of a connected peer.
type ServiceClient ¶
type ServiceClient struct {
// contains filtered or unexported fields
}
ServiceClient implements service for light mode.
func NewServiceClient ¶
func NewServiceClient(ctx context.Context, conf *node.Config, log *log.SeeleLog, dbFolder string, shard uint, engine consensus.Engine) (s *ServiceClient, err error)
NewServiceClient create ServiceClient
func (*ServiceClient) APIs ¶
func (s *ServiceClient) APIs() (apis []rpc.API)
APIs implements node.Service, returning the collection of RPC services the seele package offers.
func (*ServiceClient) Protocols ¶
func (s *ServiceClient) Protocols() (protos []p2p.Protocol)
Protocols implements node.Service, returning all the currently configured network protocols to start.
func (*ServiceClient) Start ¶
func (s *ServiceClient) Start(srvr *p2p.Server) error
Start implements node.Service, starting goroutines needed by ServiceClient.
func (*ServiceClient) Stop ¶
func (s *ServiceClient) Stop() error
Stop implements node.Service, terminating all internal goroutines.
type ServiceServer ¶
type ServiceServer struct {
// contains filtered or unexported fields
}
ServiceServer implements light server service.
func NewServiceServer ¶
func NewServiceServer(service *seele.SeeleService, conf *node.Config, log *log.SeeleLog, shard uint) (*ServiceServer, error)
NewServiceServer create ServiceServer
func (*ServiceServer) APIs ¶
func (s *ServiceServer) APIs() (apis []rpc.API)
APIs implements node.Service, returning the collection of RPC services the seele package offers.
func (*ServiceServer) Protocols ¶
func (s *ServiceServer) Protocols() (protos []p2p.Protocol)
Protocols implements node.Service, returning all the currently configured network protocols to start.
func (*ServiceServer) Start ¶
func (s *ServiceServer) Start(srvr *p2p.Server) error
Start implements node.Service, starting goroutines needed by ServiceServer.
func (*ServiceServer) Stop ¶
func (s *ServiceServer) Stop() error
Stop implements node.Service, terminating all internal goroutines.
type TransactionPool ¶
type TransactionPool interface { AddTransaction(tx *types.Transaction) error GetTransaction(txHash common.Hash) *types.Transaction }
TransactionPool define some interfaces related to add and get txs