Documentation
¶
Index ¶
- Variables
- func MakeLastAcceptedBlockF(blocks []*TestBlock, opts []*TestBlock) func() (string, error)
- type Block
- type CantAdd
- type CantInitialize
- type CantRecordPoll
- type Parameters
- type TestBlock
- func (b *TestBlock) Accept() error
- func (b *TestBlock) Bytes() []byte
- func (b *TestBlock) Height() uint64
- func (b *TestBlock) ID() string
- func (b *TestBlock) Parent() ids.ID
- func (b *TestBlock) Reject() error
- func (b *TestBlock) Status() choices.Status
- func (b *TestBlock) Time() uint64
- func (b *TestBlock) Verify(context.Context) error
- type TestConsensus
- func (c *TestConsensus) Add(ctx context.Context, blk Block) error
- func (c *TestConsensus) Decided(blk Block) bool
- func (c *TestConsensus) Finalized() bool
- func (c *TestConsensus) HealthCheck(ctx context.Context) (interface{}, error)
- func (c *TestConsensus) Initialize(ctx context.Context, params Parameters, lastAcceptedID string, ...) error
- func (c *TestConsensus) IsPreferred(blk Block) bool
- func (c *TestConsensus) Issued(blk Block) bool
- func (c *TestConsensus) NumProcessing() int
- func (c *TestConsensus) Parameters() Parameters
- func (c *TestConsensus) Preference() ids.ID
- func (c *TestConsensus) Processing(blkID ids.ID) bool
- func (c *TestConsensus) RecordPoll(ctx context.Context, votes []ids.ID) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // GenesisID is the ID of the genesis block GenesisID = ids.GenerateTestID() // GenesisBytes is the byte representation of genesis GenesisBytes = GenesisID[:] // GenesisTimestamp is the timestamp of genesis GenesisTimestamp = uint64(0) // Genesis is the genesis block Genesis = &TestBlock{ IDV: GenesisID, ParentV: ids.Empty, HeightV: 0, TimeV: 0, StatusV: choices.Accepted, BytesV: GenesisBytes, } )
Functions ¶
Types ¶
type Block ¶
type Block interface {
choices.Decidable
Parent() ids.ID
Height() uint64
Time() uint64
Verify(context.Context) error
Bytes() []byte
Accept() error
}
Block interface matches chain.Block to avoid import cycle
type CantInitialize ¶
type CantInitialize struct{}
func (CantInitialize) Initialize ¶
func (CantInitialize) Initialize(context.Context, Parameters, string, uint64, uint64) error
type Parameters ¶
type Parameters struct {
K int
AlphaPreference int
AlphaConfidence int
Beta int
ConcurrentRepolls int
OptimalProcessing int
MaxOutstandingItems int
MaxItemProcessingTime int64
}
Parameters matches Parameters to avoid import cycle
type TestBlock ¶
type TestBlock struct {
IDV ids.ID
AcceptV error
RejectV error
StatusV choices.Status
ParentV ids.ID
HeightV uint64
TimeV uint64
VerifyV error
BytesV []byte
}
TestBlock is a test implementation of Block
func BuildChild ¶
BuildChild builds a child block of the given parent
func BuildLinear ¶
BuildLinear builds a linear chain of blocks
type TestConsensus ¶
type TestConsensus struct {
T *testing.T
CantInitialize
CantAdd
CantRecordPoll
InitializeF func(context.Context, Parameters, string, uint64, uint64) error
ParametersF func() Parameters
AddF func(context.Context, Block) error
IssuedF func(Block) bool
ProcessingF func(ids.ID) bool
DecidedF func(Block) bool
IsPreferredF func(Block) bool
PreferenceF func() ids.ID
RecordPollF func(context.Context, []ids.ID) error
FinalizedF func() bool
HealthCheckF func(context.Context) (interface{}, error)
NumProcessingF func() int
}
TestConsensus is a test implementation of chain.Consensus
func (*TestConsensus) Decided ¶
func (c *TestConsensus) Decided(blk Block) bool
func (*TestConsensus) Finalized ¶
func (c *TestConsensus) Finalized() bool
func (*TestConsensus) HealthCheck ¶
func (c *TestConsensus) HealthCheck(ctx context.Context) (interface{}, error)
func (*TestConsensus) Initialize ¶
func (c *TestConsensus) Initialize(ctx context.Context, params Parameters, lastAcceptedID string, lastAcceptedHeight uint64, lastAcceptedTime uint64) error
func (*TestConsensus) IsPreferred ¶
func (c *TestConsensus) IsPreferred(blk Block) bool
func (*TestConsensus) Issued ¶
func (c *TestConsensus) Issued(blk Block) bool
func (*TestConsensus) NumProcessing ¶
func (c *TestConsensus) NumProcessing() int
func (*TestConsensus) Parameters ¶
func (c *TestConsensus) Parameters() Parameters
func (*TestConsensus) Preference ¶
func (c *TestConsensus) Preference() ids.ID
func (*TestConsensus) Processing ¶
func (c *TestConsensus) Processing(blkID ids.ID) bool
func (*TestConsensus) RecordPoll ¶
Click to show internal directories.
Click to hide internal directories.