Documentation
¶
Overview ¶
Package mesh defines the main store point for all the persisted mesh objects such as ATXs, ballots and blocks.
Index ¶
- func LayerIDs(db database.Database, namespace string, lid types.LayerID, ...) error
- type AtxDB
- type BallotFetcherDB
- type BlockFetcherDB
- type DB
- func (m *DB) AddBallot(b *types.Ballot) error
- func (m *DB) AddBlock(b *types.Block) error
- func (m *DB) AddZeroBlockLayer(lid types.LayerID) error
- func (m *DB) Ballots() database.Getter
- func (m *DB) Blocks() database.Getter
- func (m *DB) Close()
- func (m *DB) ContextualValidity(id types.BlockID) (bool, error)
- func (m *DB) GetBallot(id types.BallotID) (*types.Ballot, error)
- func (m *DB) GetBlock(bid types.BlockID) (*types.Block, error)
- func (m *DB) GetCoinflip(_ context.Context, layerID types.LayerID) (bool, bool)
- func (m *DB) GetHareConsensusOutput(layerID types.LayerID) (types.BlockID, error)
- func (m *DB) GetLatestLayer() (types.LayerID, error)
- func (m *DB) GetProcessedLayer() (types.LayerID, error)
- func (m *DB) GetRewards(coinbase types.Address) ([]types.Reward, error)
- func (m *DB) GetRewardsBySmesherID(smesherID types.NodeID) ([]types.Reward, error)
- func (m *DB) GetVerifiedLayer() (types.LayerID, error)
- func (m *DB) HasBallot(ballot types.BallotID) bool
- func (m *DB) HasBlock(bid types.BlockID) bool
- func (m *DB) LayerBallotIDs(lid types.LayerID) ([]types.BallotID, error)
- func (m *DB) LayerBallots(lid types.LayerID) ([]*types.Ballot, error)
- func (m *DB) LayerBlockIds(lid types.LayerID) ([]types.BlockID, error)
- func (m *DB) LayerBlocks(lid types.LayerID) ([]*types.Block, error)
- func (m *DB) LayerContextuallyValidBlocks(ctx context.Context, layer types.LayerID) (map[types.BlockID]struct{}, error)
- func (m *DB) PersistentData() bool
- func (m *DB) RecordCoinflip(ctx context.Context, layerID types.LayerID, coinflip bool)
- func (m *DB) SaveContextualValidity(id types.BlockID, lid types.LayerID, valid bool) error
- func (m *DB) SaveHareConsensusOutput(ctx context.Context, id types.LayerID, blockID types.BlockID) error
- func (m *DB) SetMalicious(smesher *signing.PublicKey) error
- type Mesh
- func (msh *Mesh) AddBallot(ballot *types.Ballot) error
- func (msh *Mesh) AddBlockWithTXs(ctx context.Context, block *types.Block) error
- func (msh *Mesh) AddTXsFromProposal(ctx context.Context, layerID types.LayerID, proposalID types.ProposalID, ...) error
- func (msh *Mesh) GetATXs(ctx context.Context, atxIds []types.ATXID) (map[types.ATXID]*types.ActivationTx, []types.ATXID)
- func (msh *Mesh) GetAggregatedLayerHash(layerID types.LayerID) types.Hash32
- func (msh *Mesh) GetLayer(lid types.LayerID) (*types.Layer, error)
- func (msh *Mesh) GetLayerHash(layerID types.LayerID) types.Hash32
- func (msh *Mesh) LatestLayer() types.LayerID
- func (msh *Mesh) LatestLayerInState() types.LayerID
- func (msh *Mesh) MissingLayer() types.LayerID
- func (msh *Mesh) ProcessLayer(ctx context.Context, layerID types.LayerID) error
- func (msh *Mesh) ProcessLayerPerHareOutput(ctx context.Context, layerID types.LayerID, blockID types.BlockID) error
- func (msh *Mesh) ProcessedLayer() types.LayerID
- func (msh *Mesh) SetZeroBlockLayer(lyr types.LayerID) error
- func (msh *Mesh) UpdateBlockValidity(bid types.BlockID, lid types.LayerID, newValid bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AtxDB ¶
type AtxDB interface { GetAtxHeader(id types.ATXID) (*types.ActivationTxHeader, error) GetFullAtx(id types.ATXID) (*types.ActivationTx, error) SyntacticallyValidateAtx(ctx context.Context, atx *types.ActivationTx) error }
AtxDB holds logic for working with atxs.
type BallotFetcherDB ¶
type BallotFetcherDB struct {
// contains filtered or unexported fields
}
BallotFetcherDB implements API that allows fetcher to get a ballot from a remote database.
type BlockFetcherDB ¶
type BlockFetcherDB struct {
// contains filtered or unexported fields
}
BlockFetcherDB implements API that allows fetcher to get a block from a remote database.
type DB ¶ added in v0.1.11
DB represents a mesh database instance.
func NewPersistentMeshDB ¶
NewPersistentMeshDB creates an instance of a mesh database.
func (*DB) AddZeroBlockLayer ¶ added in v0.1.15
AddZeroBlockLayer tags lyr as a layer without blocks.
func (*DB) ContextualValidity ¶ added in v0.1.11
ContextualValidity retrieves opinion on block from the database.
func (*DB) GetBallot ¶
GetBallot returns true if the database has Ballot specified by the BallotID and false otherwise.
func (*DB) GetCoinflip ¶
GetCoinflip returns the weak coinflip result for the given layer.
func (*DB) GetHareConsensusOutput ¶
GetHareConsensusOutput gets the input vote vector for a layer (hare results).
func (*DB) GetLatestLayer ¶
GetLatestLayer loads latest layer from database.
func (*DB) GetProcessedLayer ¶
GetProcessedLayer loads processed layer from database.
func (*DB) GetRewards ¶ added in v0.1.11
GetRewards retrieves account's rewards by the coinbase address.
func (*DB) GetRewardsBySmesherID ¶ added in v0.1.28
GetRewardsBySmesherID retrieves rewards by smesherID.
func (*DB) GetVerifiedLayer ¶
GetVerifiedLayer loads verified layer from database.
func (*DB) LayerBallotIDs ¶
LayerBallotIDs returns list of the ballot ids in the layer.
func (*DB) LayerBallots ¶
LayerBallots retrieves all ballots from a layer by layer ID.
func (*DB) LayerBlockIds ¶ added in v0.1.11
LayerBlockIds retrieves all block IDs from the layer specified by layer ID.
func (*DB) LayerBlocks ¶ added in v0.1.11
LayerBlocks retrieves all blocks from the layer specified by layer ID.
func (*DB) LayerContextuallyValidBlocks ¶
func (m *DB) LayerContextuallyValidBlocks(ctx context.Context, layer types.LayerID) (map[types.BlockID]struct{}, error)
LayerContextuallyValidBlocks returns the set of contextually valid block IDs for the provided layer.
func (*DB) PersistentData ¶ added in v0.1.11
PersistentData checks to see if db is empty.
func (*DB) RecordCoinflip ¶
RecordCoinflip saves the weak coinflip result to memory for the given layer.
func (*DB) SaveContextualValidity ¶ added in v0.1.11
SaveContextualValidity persists opinion on block to the database.
type Mesh ¶
Mesh is the logic layer above our mesh.DB database.
func NewRecoveredMesh ¶
func NewRecoveredMesh(db *DB, atxDb AtxDB, trtl tortoise, state conservativeState, logger log.Log) *Mesh
NewRecoveredMesh creates new instance of mesh with recovered mesh data fom database.
func (*Mesh) AddBlockWithTXs ¶ added in v1.0.0
AddBlockWithTXs adds the block and its TXs in into the database.
func (*Mesh) AddTXsFromProposal ¶ added in v1.0.0
func (msh *Mesh) AddTXsFromProposal(ctx context.Context, layerID types.LayerID, proposalID types.ProposalID, txIDs []types.TransactionID) error
AddTXsFromProposal adds the TXs in a Proposal into the database.
func (*Mesh) GetATXs ¶
func (msh *Mesh) GetATXs(ctx context.Context, atxIds []types.ATXID) (map[types.ATXID]*types.ActivationTx, []types.ATXID)
GetATXs uses GetFullAtx to return a list of atxs corresponding to atxIds requested.
func (*Mesh) GetAggregatedLayerHash ¶
GetAggregatedLayerHash returns the aggregated layer hash up to the specified layer.
func (*Mesh) GetLayerHash ¶
GetLayerHash returns layer hash.
func (*Mesh) LatestLayer ¶
LatestLayer - returns the latest layer we saw from the network.
func (*Mesh) LatestLayerInState ¶
LatestLayerInState returns the latest layer we applied to state.
func (*Mesh) MissingLayer ¶
MissingLayer is a layer in (latestLayerInState, processLayer]. this layer is missing critical data (valid blocks or transactions) and can't be applied to the state.
First valid layer starts with 1. 0 is empty layer and can be ignored.
func (*Mesh) ProcessLayer ¶ added in v1.0.0
ProcessLayer performs fairly heavy lifting: it triggers tortoise to process the full contents of the layer (i.e., all of its blocks), then to attempt to validate all unvalidated layers up to this layer. It also applies state for newly-validated layers.
func (*Mesh) ProcessLayerPerHareOutput ¶ added in v1.0.0
func (msh *Mesh) ProcessLayerPerHareOutput(ctx context.Context, layerID types.LayerID, blockID types.BlockID) error
ProcessLayerPerHareOutput receives hare output once it finishes running for a given layer.
func (*Mesh) ProcessedLayer ¶
ProcessedLayer returns the last processed layer ID.
func (*Mesh) SetZeroBlockLayer ¶ added in v0.1.6
SetZeroBlockLayer tags lyr as a layer without blocks.