Documentation
¶
Index ¶
- Variables
- func DefaultCommitmentFunc(index slot.Index) (cm *commitment.Commitment, err error)
- func NewTestStorage(t *testing.T, workers *workerpool.Group, ...) *storage.Storage
- func WithMissing(missing bool) options.Option[Block]
- func WithModelOptions(opts ...options.Option[models.Block]) options.Option[Block]
- func WithOrphaned(markedOrphaned bool) options.Option[Block]
- func WithSolid(solid bool) options.Option[Block]
- type Block
- func (b *Block) AppendChild(child *Block, childType models.ParentsType)
- func (b *Block) Children() (children []*Block)
- func (b *Block) IsFuture() (isFuture bool)
- func (b *Block) IsInvalid() (isInvalid bool)
- func (b *Block) IsMissing() (isMissing bool)
- func (b *Block) IsOrphaned() (isOrphaned bool)
- func (b *Block) IsSolid() (isSolid bool)
- func (b *Block) LikedInsteadChildren() []*Block
- func (b *Block) SetFuture() (wasUpdated bool)
- func (b *Block) SetInvalid() (wasUpdated bool)
- func (b *Block) SetOrphaned(orphaned bool) (wasUpdated bool)
- func (b *Block) SetSolid() (wasUpdated bool)
- func (b *Block) String() string
- func (b *Block) StrongChildren() []*Block
- func (b *Block) Update(data *models.Block) (wasPublished bool)
- func (b *Block) WeakChildren() []*Block
- type BlockDAG
- type BlockInvalidEvent
- type Events
- type ModelsBlock
- type ModelsTestFramework
- type TestFramework
- func (t *TestFramework) AssertBlock(alias string, callback func(block *Block))
- func (t *TestFramework) AssertInvalid(expectedValues map[string]bool)
- func (t *TestFramework) AssertInvalidCount(invalidCount int32, msgAndArgs ...interface{})
- func (t *TestFramework) AssertLikedInsteadChildren(m map[string][]string)
- func (t *TestFramework) AssertMissing(expectedValues map[string]bool)
- func (t *TestFramework) AssertMissingCount(missingCount int32, msgAndArgs ...interface{})
- func (t *TestFramework) AssertOrphanedBlocks(orphanedBlocks models.BlockIDs, msgAndArgs ...interface{})
- func (t *TestFramework) AssertOrphanedCount(storedCount int32, msgAndArgs ...interface{})
- func (t *TestFramework) AssertSolid(expectedValues map[string]bool)
- func (t *TestFramework) AssertSolidCount(solidCount int32, msgAndArgs ...interface{})
- func (t *TestFramework) AssertStoredCount(storedCount int32, msgAndArgs ...interface{})
- func (t *TestFramework) AssertStrongChildren(m map[string][]string)
- func (t *TestFramework) AssertWeakChildren(m map[string][]string)
- func (t *TestFramework) IssueBlocks(blockAliases ...string) *TestFramework
- func (t *TestFramework) SlotTimeProvider() *slot.TimeProvider
Constants ¶
This section is empty.
Variables ¶
var NewEvents = event.CreateGroupConstructor(func() (newEvents *Events) { return &Events{ BlockAttached: event.New1[*Block](), BlockSolid: event.New1[*Block](), BlockMissing: event.New1[*Block](), MissingBlockAttached: event.New1[*Block](), BlockInvalid: event.New1[*BlockInvalidEvent](), BlockOrphaned: event.New1[*Block](), BlockUnorphaned: event.New1[*Block](), } })
NewEvents contains the constructor of the Events object (it is generated by a generic factory).
Functions ¶
func DefaultCommitmentFunc ¶
func DefaultCommitmentFunc(index slot.Index) (cm *commitment.Commitment, err error)
func NewTestStorage ¶
func WithMissing ¶
WithMissing is a constructor Option for Blocks that initializes the given block with a specific missing flag.
func WithModelOptions ¶
func WithOrphaned ¶
WithOrphaned is a constructor Option for Blocks that initializes the given block with a specific orphaned flag.
Types ¶
type Block ¶
type Block struct {
*ModelsBlock
// contains filtered or unexported fields
}
Block represents a Block annotated with Mesh related metadata.
func NewRootBlock ¶
func (*Block) AppendChild ¶
func (b *Block) AppendChild(child *Block, childType models.ParentsType)
AppendChild adds a child of the corresponding type to the Block.
func (*Block) IsFuture ¶
IsFuture returns true if the Block is a future Block (we haven't committed to its commitment slot yet).
func (*Block) IsMissing ¶
IsMissing returns a flag that indicates if the underlying Block data hasn't been stored, yet.
func (*Block) IsOrphaned ¶
IsOrphaned returns true if the Block is orphaned (either due to being marked as orphaned itself or because it has orphaned Blocks in its past cone).
func (*Block) IsSolid ¶
IsSolid returns true if the Block is solid (the entire causal history is known).
func (*Block) LikedInsteadChildren ¶
func (*Block) SetInvalid ¶
SetInvalid marks the Block as invalid.
func (*Block) SetOrphaned ¶
SetOrphaned sets the orphaned flag of the Block.
func (*Block) StrongChildren ¶
func (*Block) Update ¶
Update publishes the given Block data to the underlying Block and marks it as no longer missing.
func (*Block) WeakChildren ¶
type BlockDAG ¶
type BlockDAG interface {
Events() *Events
// Attach is used to attach new Blocks to the BlockDAG. It is the main function of the BlockDAG that triggers Events.
Attach(data *models.Block) (block *Block, wasAttached bool, err error)
// Block retrieves a Block with metadata from the in-memory storage of the BlockDAG.
Block(id models.BlockID) (block *Block, exists bool)
// SetOrphaned marks a Block as orphaned and propagates it to its future cone.
SetOrphaned(block *Block, orphaned bool) (updated bool)
// SetInvalid marks a Block as invalid and propagates the invalidity to its future cone.
SetInvalid(block *Block, reason error) (wasUpdated bool)
module.Interface
}
type BlockInvalidEvent ¶
type Events ¶
type Events struct {
// BlockAttached is triggered when a previously unknown Block is attached.
BlockAttached *event.Event1[*Block]
// BlockSolid is triggered when a Block becomes solid (its entire past cone is known and solid).
BlockSolid *event.Event1[*Block]
// BlockMissing is triggered when a referenced Block was not attached, yet.
BlockMissing *event.Event1[*Block]
// MissingBlockAttached is triggered when a previously missing Block was attached.
MissingBlockAttached *event.Event1[*Block]
// BlockInvalid is triggered when a Block is found to be invalid.
BlockInvalid *event.Event1[*BlockInvalidEvent]
// BlockOrphaned is triggered when a Block becomes orphaned.
BlockOrphaned *event.Event1[*Block]
// BlockUnorphaned is triggered when a Block is no longer orphaned.
BlockUnorphaned *event.Event1[*Block]
event.Group[Events, *Events]
}
Events is a collection of Mesh related Events.
type ModelsBlock ¶
type ModelsTestFramework ¶
type ModelsTestFramework = models.TestFramework
ModelsTestFramework is an alias that it is used to be able to embed a named version of the TestFramework.
type TestFramework ¶
type TestFramework struct {
Instance BlockDAG
Test *testing.T
*ModelsTestFramework
// contains filtered or unexported fields
}
TestFramework implements a framework for conveniently issuing blocks in a BlockDAG as part of unit tests in a simplified way.
func NewTestFramework ¶
func NewTestFramework(test *testing.T, workers *workerpool.Group, blockDAG BlockDAG, slotTimeProviderFunc func() *slot.TimeProvider) *TestFramework
NewTestFramework is the constructor of the TestFramework.
func (*TestFramework) AssertBlock ¶
func (t *TestFramework) AssertBlock(alias string, callback func(block *Block))
func (*TestFramework) AssertInvalid ¶
func (t *TestFramework) AssertInvalid(expectedValues map[string]bool)
func (*TestFramework) AssertInvalidCount ¶
func (t *TestFramework) AssertInvalidCount(invalidCount int32, msgAndArgs ...interface{})
func (*TestFramework) AssertLikedInsteadChildren ¶
func (t *TestFramework) AssertLikedInsteadChildren(m map[string][]string)
func (*TestFramework) AssertMissing ¶
func (t *TestFramework) AssertMissing(expectedValues map[string]bool)
func (*TestFramework) AssertMissingCount ¶
func (t *TestFramework) AssertMissingCount(missingCount int32, msgAndArgs ...interface{})
func (*TestFramework) AssertOrphanedBlocks ¶
func (t *TestFramework) AssertOrphanedBlocks(orphanedBlocks models.BlockIDs, msgAndArgs ...interface{})
func (*TestFramework) AssertOrphanedCount ¶
func (t *TestFramework) AssertOrphanedCount(storedCount int32, msgAndArgs ...interface{})
func (*TestFramework) AssertSolid ¶
func (t *TestFramework) AssertSolid(expectedValues map[string]bool)
func (*TestFramework) AssertSolidCount ¶
func (t *TestFramework) AssertSolidCount(solidCount int32, msgAndArgs ...interface{})
func (*TestFramework) AssertStoredCount ¶
func (t *TestFramework) AssertStoredCount(storedCount int32, msgAndArgs ...interface{})
func (*TestFramework) AssertStrongChildren ¶
func (t *TestFramework) AssertStrongChildren(m map[string][]string)
func (*TestFramework) AssertWeakChildren ¶
func (t *TestFramework) AssertWeakChildren(m map[string][]string)
func (*TestFramework) IssueBlocks ¶
func (t *TestFramework) IssueBlocks(blockAliases ...string) *TestFramework
IssueBlocks stores the given Blocks in the Storage and triggers the processing by the BlockDAG.
func (*TestFramework) SlotTimeProvider ¶
func (t *TestFramework) SlotTimeProvider() *slot.TimeProvider