Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateLayerReward(id types.LayerID, params Config) *big.Int
- func GenesisLayer() *types.Layer
- func NewSignedTx(nonce uint64, rec types.Address, amount, gas, fee uint64, ...) (*types.Transaction, error)
- 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(atx *types.ActivationTx) error
- type AtxMemPoolInValidator
- type BlockBuilder
- type BlockCache
- type Config
- type DbTransaction
- type Mesh
- func (m *Mesh) AccumulateRewards(l *types.Layer, params Config)
- func (m *Mesh) AddBlock(blk *types.Block) error
- func (m *Mesh) AddBlockWithTxs(blk *types.Block, txs []*types.Transaction, atxs []*types.ActivationTx) error
- func (m *Mesh) ExtractUniqueOrderedTransactions(l *types.Layer) (validBlockTxs, invalidBlockTxs []*types.Transaction)
- func (m *Mesh) GetATXs(atxIds []types.AtxId) (map[types.AtxId]*types.ActivationTx, []types.AtxId)
- func (m *Mesh) GetLatestView() []types.BlockID
- func (m *Mesh) GetLayer(index types.LayerID) (*types.Layer, error)
- func (m *Mesh) GetOrphanBlocksBefore(l types.LayerID) ([]types.BlockID, error)
- func (m *Mesh) GetUnverifiedLayerBlocks(l types.LayerID) ([]types.BlockID, error)
- func (m *Mesh) GetVerifiedLayer(i types.LayerID) (*types.Layer, error)
- func (m *Mesh) HandleLateBlock(b *types.Block)
- func (m *Mesh) LatestLayer() types.LayerID
- func (m *Mesh) LatestLayerInState() types.LayerID
- func (m *Mesh) ProcessedLayer() types.LayerID
- func (m *Mesh) PushTransactions(l *types.Layer)
- func (m *Mesh) SetBlockBuilder(blockBuilder BlockBuilder)
- func (m *Mesh) SetLatestLayer(idx types.LayerID)
- func (m *Mesh) ValidateLayer(lyr *types.Layer)
- type MeshDB
- func (m *MeshDB) AddBlock(bl *types.Block) error
- func (m *MeshDB) BlocksByValidity(blocks []*types.Block) (validBlocks, invalidBlocks []*types.Block)
- func (m *MeshDB) Close()
- func (m *MeshDB) ContextualValidity(id types.BlockID) (bool, error)
- func (m *MeshDB) ContextuallyValidBlock(layer types.LayerID) (map[types.BlockID]struct{}, error)
- func (m *MeshDB) ForBlockInView(view map[types.BlockID]struct{}, layer types.LayerID, ...) error
- func (m *MeshDB) GetBlock(id types.BlockID) (*types.Block, error)
- func (m *MeshDB) GetProjection(addr types.Address, prevNonce, prevBalance uint64) (nonce, balance uint64, err error)
- func (m *MeshDB) GetRewards(account types.Address) (rewards []types.Reward, err error)
- func (m *MeshDB) GetTransaction(id types.TransactionId) (*types.Transaction, error)
- func (m *MeshDB) GetTransactions(transactions []types.TransactionId) ([]*types.Transaction, map[types.TransactionId]struct{})
- func (m *MeshDB) GetTransactionsByDestination(l types.LayerID, account types.Address) (txs []types.TransactionId)
- func (m *MeshDB) GetTransactionsByOrigin(l types.LayerID, account types.Address) (txs []types.TransactionId)
- func (m *MeshDB) LayerBlockIds(index types.LayerID) ([]types.BlockID, error)
- func (m *MeshDB) LayerBlocks(index types.LayerID) ([]*types.Block, error)
- func (m *MeshDB) Persist(key []byte, v interface{}) error
- func (m *MeshDB) PersistentData() bool
- func (m *MeshDB) Retrieve(key []byte, v interface{}) (interface{}, error)
- func (m *MeshDB) SaveContextualValidity(id types.BlockID, valid bool) error
- type MeshValidator
- type StateObj
- type TxMemPoolInValidator
- type TxProcessor
Constants ¶
View Source
const (
Genesis = types.LayerID(0)
)
Variables ¶
View Source
var ErrAlreadyExist = errors.New("block already exist in database")
View Source
var FALSE = []byte{0}
View Source
var GenesisBlock = types.NewExistingBlock(0, []byte("genesis"))
View Source
var LATEST = []byte("latest")
View Source
var LAYERHASH = []byte("layer hash")
View Source
var PROCESSED = []byte("proccessed")
View Source
var TORTOISE = []byte("tortoise")
View Source
var TRUE = []byte{1}
View Source
var VERIFIED = []byte("verified") //refers to layers we pushed into the state
Functions ¶
func GenesisLayer ¶
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 }
type AtxDbMock ¶
type AtxDbMock struct { ProcCnt int // contains filtered or unexported fields }
func NewAtxDbMock ¶
func NewAtxDbMock() *AtxDbMock
func (*AtxDbMock) GetAtxHeader ¶
func (*AtxDbMock) GetFullAtx ¶
func (*AtxDbMock) ProcessAtxs ¶
func (t *AtxDbMock) ProcessAtxs(atxs []*types.ActivationTx) error
func (AtxDbMock) SyntacticallyValidateAtx ¶
func (AtxDbMock) SyntacticallyValidateAtx(atx *types.ActivationTx) error
type AtxMemPoolInValidator ¶
type BlockBuilder ¶
type BlockBuilder interface {
ValidateAndAddTxToPool(tx *types.Transaction) error
}
type BlockCache ¶
type BlockCache struct { *lru.Cache // contains filtered or unexported fields }
func NewBlockCache ¶
func NewBlockCache(size int) BlockCache
type Config ¶
func DefaultMeshConfig ¶
func DefaultMeshConfig() Config
type DbTransaction ¶
type DbTransaction struct { *types.Transaction Origin types.Address }
func NewDbTransaction ¶
func NewDbTransaction(tx *types.Transaction) *DbTransaction
func (DbTransaction) GetTransaction ¶
func (t DbTransaction) GetTransaction() *types.Transaction
type Mesh ¶
type Mesh struct { log.Log *MeshDB AtxDB TxProcessor MeshValidator // contains filtered or unexported fields }
func NewMesh ¶
func NewMesh(db *MeshDB, atxDb AtxDB, rewardConfig Config, mesh MeshValidator, txInvalidator TxMemPoolInValidator, atxInvalidator AtxMemPoolInValidator, pr TxProcessor, logger log.Log) *Mesh
func NewRecoveredMesh ¶
func NewRecoveredMesh(db *MeshDB, atxDb AtxDB, rewardConfig Config, mesh MeshValidator, txInvalidator TxMemPoolInValidator, atxInvalidator AtxMemPoolInValidator, pr TxProcessor, logger log.Log) *Mesh
func (*Mesh) AddBlockWithTxs ¶
func (m *Mesh) AddBlockWithTxs(blk *types.Block, txs []*types.Transaction, atxs []*types.ActivationTx) error
func (*Mesh) ExtractUniqueOrderedTransactions ¶
func (m *Mesh) ExtractUniqueOrderedTransactions(l *types.Layer) (validBlockTxs, invalidBlockTxs []*types.Transaction)
func (*Mesh) GetLatestView ¶
func (*Mesh) GetOrphanBlocksBefore ¶
func (*Mesh) GetUnverifiedLayerBlocks ¶
func (*Mesh) GetVerifiedLayer ¶
todo consider adding a boolean for layer validity instead error
func (*Mesh) HandleLateBlock ¶
func (*Mesh) LatestLayer ¶
LatestLayer - returns the latest layer we saw from the network
func (*Mesh) LatestLayerInState ¶
func (*Mesh) ProcessedLayer ¶
func (*Mesh) PushTransactions ¶
func (*Mesh) SetBlockBuilder ¶
func (m *Mesh) SetBlockBuilder(blockBuilder BlockBuilder)
func (*Mesh) SetLatestLayer ¶
func (*Mesh) ValidateLayer ¶
type MeshDB ¶
func NewMemMeshDB ¶
func NewPersistentMeshDB ¶
func (*MeshDB) BlocksByValidity ¶
func (*MeshDB) ContextualValidity ¶
func (*MeshDB) ContextuallyValidBlock ¶
ContextuallyValidBlock - returns the contextually valid blocks for the provided layer
func (*MeshDB) ForBlockInView ¶
func (m *MeshDB) ForBlockInView(view map[types.BlockID]struct{}, layer types.LayerID, blockHandler func(block *types.Block) (bool, error)) error
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 (*MeshDB) GetProjection ¶
func (*MeshDB) GetRewards ¶
func (*MeshDB) GetTransaction ¶
func (m *MeshDB) GetTransaction(id types.TransactionId) (*types.Transaction, error)
func (*MeshDB) GetTransactions ¶
func (m *MeshDB) GetTransactions(transactions []types.TransactionId) ([]*types.Transaction, map[types.TransactionId]struct{})
func (*MeshDB) GetTransactionsByDestination ¶
func (*MeshDB) GetTransactionsByOrigin ¶
func (*MeshDB) LayerBlockIds ¶
func (*MeshDB) LayerBlocks ¶
func (*MeshDB) PersistentData ¶
type MeshValidator ¶
type TxMemPoolInValidator ¶
type TxMemPoolInValidator interface {
Invalidate(id types.TransactionId)
}
type TxProcessor ¶
type TxProcessor interface { ApplyTransactions(layer types.LayerID, txs []*types.Transaction) (int, error) ApplyRewards(layer types.LayerID, miners []types.Address, reward *big.Int) ValidateSignature(s types.Signed) (types.Address, error) AddressExists(addr types.Address) bool ValidateNonceAndBalance(transaction *types.Transaction) error GetLayerApplied(txId types.TransactionId) *types.LayerID GetStateRoot() types.Hash32 LoadState(layer types.LayerID) error }
Click to show internal directories.
Click to hide internal directories.