Documentation ¶
Index ¶
- type BlockHeaderDownloadRequest
- func (r *BlockHeaderDownloadRequest) DownloadType() DownloadType
- func (r *BlockHeaderDownloadRequest) Identifier() string
- func (r *BlockHeaderDownloadRequest) IsRequest() bool
- func (r *BlockHeaderDownloadRequest) RequestHeight() uint32
- func (r *BlockHeaderDownloadRequest) RequestRound() uint32
- func (r *BlockHeaderDownloadRequest) ResponseChan() chan DownloadResponse
- type BlockHeaderDownloadResponse
- type DMan
- func (dm *DMan) AddTxs(txn *badger.Txn, height uint32, txs []interfaces.Transaction) error
- func (dm *DMan) CleanCache(txn *badger.Txn, height uint32) error
- func (dm *DMan) Close()
- func (dm *DMan) DownloadTxs(height, round uint32, txHshLst [][]byte)
- func (dm *DMan) FlushCacheToDisk(txn *badger.Txn, height uint32) error
- func (dm *DMan) GetTxs(txn *badger.Txn, height, round uint32, txLst [][]byte) ([]interfaces.Transaction, [][]byte, error)
- func (dm *DMan) Init(database databaseView, app interfaces.Application, reqBus reqBusView)
- func (dm *DMan) Start()
- func (dm *DMan) SyncOneBH(txn *badger.Txn, syncToBH, maxBHSeen *objs.BlockHeader, ...) ([]interfaces.Transaction, *objs.BlockHeader, bool, error)
- type DownloadRequest
- type DownloadResponse
- type DownloadType
- type ReqBusViewMock
- func (r *ReqBusViewMock) RequestP2PGetBlockHeaders(ctx context.Context, blockNums []uint32, opts ...grpc.CallOption) ([]*objs.BlockHeader, error)
- func (r *ReqBusViewMock) RequestP2PGetMinedTxs(ctx context.Context, txHashes [][]byte, opts ...grpc.CallOption) ([][]byte, error)
- func (r *ReqBusViewMock) RequestP2PGetPendingTx(ctx context.Context, txHashes [][]byte, opts ...grpc.CallOption) ([][]byte, error)
- type RootActor
- func (a *RootActor) CleanCache(txn *badger.Txn, height uint32) error
- func (a *RootActor) Close()
- func (a *RootActor) DownloadBlockHeader(height, round uint32)
- func (a *RootActor) DownloadMinedTx(height, round uint32, txHash []byte)
- func (a *RootActor) DownloadPendingTx(height, round uint32, txHash []byte)
- func (a *RootActor) DownloadTx(height, round uint32, txHash []byte)
- func (a *RootActor) FlushCacheToDisk(txn *badger.Txn, height uint32) error
- func (a *RootActor) Init(logger *logrus.Logger, proxy typeProxyIface) error
- func (a *RootActor) Start()
- type TxDownloadRequest
- func (r *TxDownloadRequest) DownloadType() DownloadType
- func (r *TxDownloadRequest) Identifier() string
- func (r *TxDownloadRequest) IsRequest() bool
- func (r *TxDownloadRequest) RequestHeight() uint32
- func (r *TxDownloadRequest) RequestRound() uint32
- func (r *TxDownloadRequest) ResponseChan() chan DownloadResponse
- type TxDownloadResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockHeaderDownloadRequest ¶
type BlockHeaderDownloadRequest struct { Height uint32 `json:"height,omitempty"` Dtype DownloadType `json:"dtype,omitempty"` Round uint32 `json:"round,omitempty"` // contains filtered or unexported fields }
func NewBlockHeaderDownloadRequest ¶
func NewBlockHeaderDownloadRequest(height, round uint32, downloadType DownloadType) *BlockHeaderDownloadRequest
func (*BlockHeaderDownloadRequest) DownloadType ¶
func (r *BlockHeaderDownloadRequest) DownloadType() DownloadType
func (*BlockHeaderDownloadRequest) Identifier ¶
func (r *BlockHeaderDownloadRequest) Identifier() string
func (*BlockHeaderDownloadRequest) IsRequest ¶
func (r *BlockHeaderDownloadRequest) IsRequest() bool
func (*BlockHeaderDownloadRequest) RequestHeight ¶
func (r *BlockHeaderDownloadRequest) RequestHeight() uint32
func (*BlockHeaderDownloadRequest) RequestRound ¶
func (r *BlockHeaderDownloadRequest) RequestRound() uint32
func (*BlockHeaderDownloadRequest) ResponseChan ¶
func (r *BlockHeaderDownloadRequest) ResponseChan() chan DownloadResponse
type BlockHeaderDownloadResponse ¶
type BlockHeaderDownloadResponse struct { Height uint32 `json:"height,omitempty"` Dtype DownloadType `json:"dtype,omitempty"` BH *objs.BlockHeader Err error `json:"err,omitempty"` Round uint32 `json:"round,omitempty"` }
func NewBlockHeaderDownloadResponse ¶
func NewBlockHeaderDownloadResponse(req *BlockHeaderDownloadRequest, bh *objs.BlockHeader, dlt DownloadType, err error) *BlockHeaderDownloadResponse
func (*BlockHeaderDownloadResponse) DownloadType ¶
func (r *BlockHeaderDownloadResponse) DownloadType() DownloadType
func (*BlockHeaderDownloadResponse) IsResponse ¶
func (r *BlockHeaderDownloadResponse) IsResponse() bool
func (*BlockHeaderDownloadResponse) RequestHeight ¶
func (r *BlockHeaderDownloadResponse) RequestHeight() uint32
func (*BlockHeaderDownloadResponse) RequestRound ¶
func (r *BlockHeaderDownloadResponse) RequestRound() uint32
type DMan ¶
type DMan struct {
// contains filtered or unexported fields
}
func (*DMan) AddTxs ¶
func (dm *DMan) AddTxs(txn *badger.Txn, height uint32, txs []interfaces.Transaction) error
func (*DMan) CleanCache ¶
func (*DMan) DownloadTxs ¶
func (*DMan) FlushCacheToDisk ¶
func (*DMan) GetTxs ¶
func (dm *DMan) GetTxs(txn *badger.Txn, height, round uint32, txLst [][]byte) ([]interfaces.Transaction, [][]byte, error)
func (*DMan) Init ¶
func (dm *DMan) Init(database databaseView, app interfaces.Application, reqBus reqBusView)
func (*DMan) SyncOneBH ¶
func (dm *DMan) SyncOneBH(txn *badger.Txn, syncToBH, maxBHSeen *objs.BlockHeader, validatorSet *objs.ValidatorSet) ([]interfaces.Transaction, *objs.BlockHeader, bool, error)
SyncOneBH syncs one blockheader and its transactions the initialization of prevBH from SyncToBH implies SyncToBH must be updated to the canonical bh before we begin unless we are syncing from a height gt the canonical bh.
type DownloadRequest ¶
type DownloadRequest interface { DownloadType() DownloadType IsRequest() bool RequestHeight() uint32 RequestRound() uint32 ResponseChan() chan DownloadResponse Identifier() string }
type DownloadResponse ¶
type DownloadResponse interface { DownloadType() DownloadType IsResponse() bool RequestHeight() uint32 RequestRound() uint32 }
type DownloadType ¶
type DownloadType int
const ( PendingTxRequest DownloadType = iota + 1 MinedTxRequest PendingAndMinedTxRequest BlockHeaderRequest )
type ReqBusViewMock ¶
func (*ReqBusViewMock) RequestP2PGetBlockHeaders ¶
func (r *ReqBusViewMock) RequestP2PGetBlockHeaders(ctx context.Context, blockNums []uint32, opts ...grpc.CallOption) ([]*objs.BlockHeader, error)
func (*ReqBusViewMock) RequestP2PGetMinedTxs ¶
func (r *ReqBusViewMock) RequestP2PGetMinedTxs(ctx context.Context, txHashes [][]byte, opts ...grpc.CallOption) ([][]byte, error)
func (*ReqBusViewMock) RequestP2PGetPendingTx ¶
func (r *ReqBusViewMock) RequestP2PGetPendingTx(ctx context.Context, txHashes [][]byte, opts ...grpc.CallOption) ([][]byte, error)
type RootActor ¶
RootActor spawns top level actor types for download manager. This system allows the synchronously run consensus algorithm to request the download of tx state and blocks from remote peers as a background task. The system keeps a record of all pending downloads to prevent double entry and stores all state requested into a hot cache that is flushed to disk by the synchronous code. This system will retry failed requests until the height lag is raised to a point that invalidates the given request.
func (*RootActor) CleanCache ¶
CleanCache flushes all items older than 5 blocks from cache.
func (*RootActor) DownloadBlockHeader ¶
DownloadBlockHeader downloads block headers from remote peers.
func (*RootActor) DownloadMinedTx ¶
DownloadPendingTx downloads txs that are mined from remote peers.
func (*RootActor) DownloadPendingTx ¶
DownloadPendingTx downloads txs that are pending from remote peers.
func (*RootActor) DownloadTx ¶
func (*RootActor) FlushCacheToDisk ¶
TODO verify blockheader cache is being cleaned.
type TxDownloadRequest ¶
type TxDownloadRequest struct { TxHash []byte `json:"tx_hash,omitempty"` Dtype DownloadType `json:"dtype,omitempty"` Height uint32 `json:"height,omitempty"` Round uint32 `json:"round,omitempty"` // contains filtered or unexported fields }
func NewTxDownloadRequest ¶
func NewTxDownloadRequest(txHash []byte, downloadType DownloadType, height, round uint32) *TxDownloadRequest
func (*TxDownloadRequest) DownloadType ¶
func (r *TxDownloadRequest) DownloadType() DownloadType
func (*TxDownloadRequest) Identifier ¶
func (r *TxDownloadRequest) Identifier() string
func (*TxDownloadRequest) IsRequest ¶
func (r *TxDownloadRequest) IsRequest() bool
func (*TxDownloadRequest) RequestHeight ¶
func (r *TxDownloadRequest) RequestHeight() uint32
func (*TxDownloadRequest) RequestRound ¶
func (r *TxDownloadRequest) RequestRound() uint32
func (*TxDownloadRequest) ResponseChan ¶
func (r *TxDownloadRequest) ResponseChan() chan DownloadResponse
type TxDownloadResponse ¶
type TxDownloadResponse struct { TxHash []byte `json:"tx_hash,omitempty"` Dtype DownloadType `json:"dtype,omitempty"` Tx interfaces.Transaction Err error `json:"err,omitempty"` Height uint32 `json:"height,omitempty"` Round uint32 `json:"round,omitempty"` }
func NewTxDownloadResponse ¶
func NewTxDownloadResponse(req *TxDownloadRequest, tx interfaces.Transaction, dlt DownloadType, err error) *TxDownloadResponse
func (*TxDownloadResponse) DownloadType ¶
func (r *TxDownloadResponse) DownloadType() DownloadType
func (*TxDownloadResponse) IsResponse ¶
func (r *TxDownloadResponse) IsResponse() bool
func (*TxDownloadResponse) RequestHeight ¶
func (r *TxDownloadResponse) RequestHeight() uint32
func (*TxDownloadResponse) RequestRound ¶
func (r *TxDownloadResponse) RequestRound() uint32