dman

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

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 (*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 (dm *DMan) CleanCache(txn *badger.Txn, height uint32) error

func (*DMan) Close

func (dm *DMan) Close()

func (*DMan) DownloadTxs

func (dm *DMan) DownloadTxs(height, round uint32, txHshLst [][]byte)

func (*DMan) FlushCacheToDisk

func (dm *DMan) FlushCacheToDisk(txn *badger.Txn, height uint32) error

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) Start

func (dm *DMan) Start()

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

type ReqBusViewMock struct {
	mock.Mock
}

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

type RootActor struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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

func (a *RootActor) CleanCache(txn *badger.Txn, height uint32) error

CleanCache flushes all items older than 5 blocks from cache.

func (*RootActor) Close

func (a *RootActor) Close()

func (*RootActor) DownloadBlockHeader

func (a *RootActor) DownloadBlockHeader(height, round uint32)

DownloadBlockHeader downloads block headers from remote peers.

func (*RootActor) DownloadMinedTx

func (a *RootActor) DownloadMinedTx(height, round uint32, txHash []byte)

DownloadPendingTx downloads txs that are mined from remote peers.

func (*RootActor) DownloadPendingTx

func (a *RootActor) DownloadPendingTx(height, round uint32, txHash []byte)

DownloadPendingTx downloads txs that are pending from remote peers.

func (*RootActor) DownloadTx

func (a *RootActor) DownloadTx(height, round uint32, txHash []byte)

func (*RootActor) FlushCacheToDisk

func (a *RootActor) FlushCacheToDisk(txn *badger.Txn, height uint32) error

TODO verify blockheader cache is being cleaned.

func (*RootActor) Init

func (a *RootActor) Init(logger *logrus.Logger, proxy typeProxyIface) error

func (*RootActor) Start

func (a *RootActor) Start()

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 (*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

Jump to

Keyboard shortcuts

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