Documentation ¶
Overview ¶
Package mesh defines the main store point for all the block-mesh objects such as blocks, transactions and global state
Index ¶
- Variables
- func GenesisBlock() *types.Block
- func GenesisLayer() *types.Layer
- type AtxDB
- type AtxDbMock
- func (t *AtxDbMock) AddAtx(id types.ATXID, atx *types.ActivationTx)
- func (t *AtxDbMock) GetAtxHeader(id types.ATXID) (*types.ActivationTxHeader, error)
- func (t *AtxDbMock) GetFullAtx(id types.ATXID) (*types.ActivationTx, error)
- func (t *AtxDbMock) ProcessAtxs(atxs []*types.ActivationTx) error
- func (AtxDbMock) SyntacticallyValidateAtx(*types.ActivationTx) error
- type Config
- type DB
- func (m *DB) AddBlock(bl *types.Block) error
- func (m *DB) AddZeroBlockLayer(index types.LayerID) error
- func (m *DB) BlocksByValidity(blocks []*types.Block) (validBlocks, invalidBlocks []*types.Block)
- func (m *DB) Close()
- func (m *DB) ContextualValidity(id types.BlockID) (bool, error)
- func (m *DB) ContextuallyValidBlock(layer types.LayerID) (map[types.BlockID]struct{}, error)
- func (m *DB) ForBlockInView(view map[types.BlockID]struct{}, layer types.LayerID, ...) error
- func (m *DB) GetBlock(id types.BlockID) (*types.Block, error)
- func (m *DB) GetProjection(addr types.Address, prevNonce, prevBalance uint64) (nonce, balance uint64, err error)
- func (m *DB) GetRewards(account types.Address) (rewards []types.Reward, err error)
- func (m *DB) GetTransaction(id types.TransactionID) (*types.Transaction, error)
- func (m *DB) GetTransactions(transactions []types.TransactionID) ([]*types.Transaction, map[types.TransactionID]struct{})
- func (m *DB) GetTransactionsByDestination(l types.LayerID, account types.Address) (txs []types.TransactionID)
- func (m *DB) GetTransactionsByOrigin(l types.LayerID, account types.Address) (txs []types.TransactionID)
- func (m *DB) LayerBlockIds(index types.LayerID) ([]types.BlockID, error)
- func (m *DB) LayerBlocks(index types.LayerID) ([]*types.Block, error)
- func (m *DB) Persist(key []byte, v interface{}) error
- func (m *DB) PersistentData() bool
- func (m *DB) Retrieve(key []byte, v interface{}) (interface{}, error)
- func (m *DB) SaveContextualValidity(id types.BlockID, valid bool) error
- func (m *DB) WriteTransaction(l types.LayerID, t *types.Transaction) error
- type Mesh
- func (msh *Mesh) AddBlock(blk *types.Block) error
- func (msh *Mesh) AddBlockWithTxs(blk *types.Block) error
- func (msh *Mesh) CacheWarmUp(layerSize int)
- func (msh *Mesh) GetATXs(atxIds []types.ATXID) (map[types.ATXID]*types.ActivationTx, []types.ATXID)
- func (msh *Mesh) GetLayer(i types.LayerID) (*types.Layer, error)
- func (msh *Mesh) GetOrphanBlocksBefore(l types.LayerID) ([]types.BlockID, error)
- func (msh *Mesh) GetProcessedLayer(i types.LayerID) (*types.Layer, error)
- func (msh *Mesh) HandleValidatedLayer(validatedLayer types.LayerID, layer []types.BlockID)
- func (msh *Mesh) LatestLayer() types.LayerID
- func (msh *Mesh) LatestLayerInState() types.LayerID
- func (msh *Mesh) SetLatestLayer(idx types.LayerID)
- func (msh *Mesh) SetZeroBlockLayer(lyr types.LayerID) error
- func (msh *Mesh) StoreTransactionsFromPool(blk *types.Block) error
- type Validator
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyExist = errors.New("block already exists in database")
ErrAlreadyExist error returned when adding an existing value to the database
var TORTOISE = []byte("tortoise")
TORTOISE key for tortoise persistence in database
var VERIFIED = []byte("verified")
VERIFIED refers to layers we pushed into the state
Functions ¶
func GenesisBlock ¶
GenesisBlock is a is the first static block that xists at the beginning of each network. it exist one layer before actual blocks could be created
func GenesisLayer ¶
GenesisLayer generates layer 0 should be removed after the genesis flow is implemented
Types ¶
type AtxDB ¶
type AtxDB interface { ProcessAtxs(atxs []*types.ActivationTx) error GetAtxHeader(id types.ATXID) (*types.ActivationTxHeader, error) GetFullAtx(id types.ATXID) (*types.ActivationTx, error) SyntacticallyValidateAtx(atx *types.ActivationTx) error }
AtxDB holds logic for working with atxs
type AtxDbMock ¶
type AtxDbMock struct { ProcCnt int // contains filtered or unexported fields }
AtxDbMock is a mock of an activation DB
func (*AtxDbMock) AddAtx ¶
func (t *AtxDbMock) AddAtx(id types.ATXID, atx *types.ActivationTx)
AddAtx stores an ATX for later retrieval
func (*AtxDbMock) GetAtxHeader ¶
GetAtxHeader returns a new ActivationTxHeader
func (*AtxDbMock) GetFullAtx ¶
GetFullAtx returns a full ATX
func (*AtxDbMock) ProcessAtxs ¶
func (t *AtxDbMock) ProcessAtxs(atxs []*types.ActivationTx) error
ProcessAtxs counts how many ATXs were processed
func (AtxDbMock) SyntacticallyValidateAtx ¶
func (AtxDbMock) SyntacticallyValidateAtx(*types.ActivationTx) error
SyntacticallyValidateAtx always returns no error
type Config ¶
Config defines the configuration options for Spacemesh rewards.
func DefaultMeshConfig ¶
func DefaultMeshConfig() Config
DefaultMeshConfig returns the default Config.
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) BlocksByValidity ¶ added in v0.1.11
BlocksByValidity classifies a slice of blocks by validity
func (*DB) ContextualValidity ¶ added in v0.1.11
ContextualValidity retrieves opinion on block from the database
func (*DB) ContextuallyValidBlock ¶ added in v0.1.11
ContextuallyValidBlock - returns the contextually valid blocks for the provided layer
func (*DB) ForBlockInView ¶ added in v0.1.11
func (m *DB) ForBlockInView(view map[types.BlockID]struct{}, layer types.LayerID, blockHandler func(block *types.Block) (bool, error)) error
ForBlockInView traverses all blocks in a view and uses blockHandler func on each block The block handler func should return two values - a bool indicating whether or not we should stop traversing after the current block (happy flow) and an error indicating that an error occurred while handling the block, the traversing will stop in that case as well (error flow)
func (*DB) GetProjection ¶ added in v0.1.11
func (m *DB) GetProjection(addr types.Address, prevNonce, prevBalance uint64) (nonce, balance uint64, err error)
GetProjection returns projection of address
func (*DB) GetRewards ¶ added in v0.1.11
GetRewards retrieves account's rewards by address
func (*DB) GetTransaction ¶ added in v0.1.11
func (m *DB) GetTransaction(id types.TransactionID) (*types.Transaction, error)
GetTransaction retrieves a tx by its id
func (*DB) GetTransactions ¶ added in v0.1.11
func (m *DB) GetTransactions(transactions []types.TransactionID) ([]*types.Transaction, map[types.TransactionID]struct{})
GetTransactions retrieves a list of txs by their id's
func (*DB) GetTransactionsByDestination ¶ added in v0.1.11
func (m *DB) GetTransactionsByDestination(l types.LayerID, account types.Address) (txs []types.TransactionID)
GetTransactionsByDestination retrieves txs by destination and layer
func (*DB) GetTransactionsByOrigin ¶ added in v0.1.11
func (m *DB) GetTransactionsByOrigin(l types.LayerID, account types.Address) (txs []types.TransactionID)
GetTransactionsByOrigin retrieves txs by origin and layer
func (*DB) LayerBlockIds ¶ added in v0.1.11
LayerBlockIds retrieves all block ids from a layer by layer index
func (*DB) LayerBlocks ¶ added in v0.1.11
LayerBlocks retrieves all blocks from a layer by layer index
func (*DB) Persist ¶ added in v0.1.11
Persist persists an item v into the database using key as its id
func (*DB) PersistentData ¶ added in v0.1.11
PersistentData checks to see if db is empty
func (*DB) SaveContextualValidity ¶ added in v0.1.11
SaveContextualValidity persists opinion on block to the database
func (*DB) WriteTransaction ¶ added in v0.1.16
WriteTransaction writes a single transaction to the db
type Mesh ¶
Mesh is the logic layer above our mesh.DB database
func NewMesh ¶
func NewMesh(db *DB, atxDb AtxDB, rewardConfig Config, mesh tortoise, txInvalidator txMemPool, pr txProcessor, logger log.Log) *Mesh
NewMesh creates a new instant of a mesh
func NewRecoveredMesh ¶
func NewRecoveredMesh(db *DB, atxDb AtxDB, rewardConfig Config, mesh tortoise, txInvalidator txMemPool, pr txProcessor, logger log.Log) *Mesh
NewRecoveredMesh creates new instance of mesh with recovered mesh data fom database
func (*Mesh) AddBlock ¶
AddBlock adds a block to the database ignoring the block txs/atxs ***USED ONLY FOR TESTS***
func (*Mesh) AddBlockWithTxs ¶
AddBlockWithTxs adds a block to the database blk - the block to add txs - block txs that we dont have in our tx database yet
func (*Mesh) CacheWarmUp ¶ added in v0.1.4
CacheWarmUp warms up cache with latest blocks
func (*Mesh) GetATXs ¶
GetATXs uses GetFullAtx to return a list of atxs corresponding to atxIds requested
func (*Mesh) GetOrphanBlocksBefore ¶
GetOrphanBlocksBefore returns all known orphan blocks with layerID < l
func (*Mesh) GetProcessedLayer ¶ added in v0.1.11
GetProcessedLayer returns a layer only if it has already been processed
func (*Mesh) HandleValidatedLayer ¶ added in v0.1.11
HandleValidatedLayer handles layer valid blocks as decided by hare
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) SetLatestLayer ¶
SetLatestLayer sets the latest layer we saw from the network
func (*Mesh) SetZeroBlockLayer ¶ added in v0.1.6
SetZeroBlockLayer tags lyr as a layer without blocks