Documentation ¶
Index ¶
- Variables
- func ASCIIschemeForEach(scheme string, callback ForEachEvent) (nodes []idx.StakerID, events map[idx.StakerID][]*Event, ...)
- func ASCIIschemeToDAG(scheme string) (nodes []idx.StakerID, events map[idx.StakerID][]*Event, ...)
- func DAGtoASCIIscheme(events Events) (string, error)
- func FmtFrame(frame idx.Frame, isRoot bool) string
- func ForEachRandEvent(nodes []idx.StakerID, eventCount int, parentCount int, r *rand.Rand, ...) (events map[idx.StakerID][]*Event)
- func ForEachRandFork(nodes []idx.StakerID, cheatersArr []idx.StakerID, eventCount int, ...) (events map[idx.StakerID][]*Event)
- func GenNodes(nodeCount int) (nodes []idx.StakerID)
- func GenRandEvents(nodes []idx.StakerID, eventCount int, parentCount int, r *rand.Rand) (events map[idx.StakerID][]*Event)
- type Block
- type Cheaters
- type ConsensusCallbacks
- type Event
- func (e *Event) CalcSize() int
- func (e *Event) DecodeRLP(src *rlp.Stream) error
- func (e *Event) EncodeRLP(w io.Writer) error
- func (e *Event) RecacheSize() int
- func (e *Event) Sign(signer func([]byte) ([]byte, error)) error
- func (e *Event) SignBy(priv *ecdsa.PrivateKey) error
- func (e *Event) Size() int
- func (e *Event) VerifySignature(address common.Address) bool
- type EventHeader
- type EventHeaderData
- func (e *EventHeaderData) CalcHash() hash.Event
- func (e *EventHeaderData) DataToSign() []byte
- func (e *EventHeaderData) DecodeRLP(src *rlp.Stream) error
- func (e *EventHeaderData) EncodeRLP(w io.Writer) error
- func (e *EventHeaderData) Hash() hash.Event
- func (e *EventHeaderData) IsSelfParent(hash hash.Event) bool
- func (e *EventHeaderData) MarshalBinary() ([]byte, error)
- func (e *EventHeaderData) NoTransactions() bool
- func (e *EventHeaderData) RecacheHash() hash.Event
- func (e *EventHeaderData) SelfParent() *hash.Event
- func (e *EventHeaderData) String() string
- func (e *EventHeaderData) UnmarshalBinary(raw []byte) (err error)
- type Events
- type ForEachEvent
- type GasPowerLeft
- type HeadersByCreator
- type Timestamp
Constants ¶
This section is empty.
Variables ¶
var ( ErrNonCanonicalEncoding = errors.New("Non canonical encoded event") ErrInvalidEncoding = errors.New("Invalid encoded event") )
var ( // EmptyTxHash is hash of empty transactions list. Used to check that event doesn't have transactions not having full event. EmptyTxHash = types.DeriveSha(types.Transactions{}) )
Functions ¶
func ASCIIschemeForEach ¶
func ASCIIschemeForEach( scheme string, callback ForEachEvent, ) ( nodes []idx.StakerID, events map[idx.StakerID][]*Event, names map[string]*Event, )
ASCIIschemeToDAG parses events from ASCII-scheme for test purpose. Use joiners ║ ╬ ╠ ╣ ╫ ╚ ╝ ╩ and optional fillers ─ ═ to draw ASCII-scheme. Result:
- nodes is an array of node addresses;
- events maps node address to array of its events;
- names maps human readable name to the event;
func ASCIIschemeToDAG ¶
func DAGtoASCIIscheme ¶
DAGtoASCIIscheme builds ASCII-scheme of events for debug purpose.
func ForEachRandEvent ¶
func ForEachRandEvent( nodes []idx.StakerID, eventCount int, parentCount int, r *rand.Rand, callback ForEachEvent, ) ( events map[idx.StakerID][]*Event, )
ForEachRandEvent generates random events for test purpose. Result:
- callbacks are called for each new event;
- events maps node address to array of its events;
func ForEachRandFork ¶
func ForEachRandFork( nodes []idx.StakerID, cheatersArr []idx.StakerID, eventCount int, parentCount int, forksCount int, r *rand.Rand, callback ForEachEvent, ) ( events map[idx.StakerID][]*Event, )
ForEachRandFork generates random events with forks for test purpose. Result:
- callbacks are called for each new event;
- events maps node address to array of its events;
Types ¶
type Block ¶
type Block struct { Index idx.Block Time Timestamp TxHash common.Hash Events hash.Events SkippedTxs []uint // indexes of skipped txs, starting from first tx of first event, ending with last tx of last event GasUsed uint64 PrevHash hash.Event Root common.Hash Atropos hash.Event }
Block is a "chain" block.
type Cheaters ¶
Cheaters is a slice type for storing cheaters list.
type ConsensusCallbacks ¶
type ConsensusCallbacks struct { // ApplyBlock is callback type to apply the new block to the state ApplyBlock func(block *Block, decidedFrame idx.Frame, cheaters Cheaters) (newAppHash common.Hash, sealEpoch bool) // SelectValidatorsGroup is a callback type to select new validators group. SelectValidatorsGroup func(oldEpoch, newEpoch idx.Epoch) (newValidators *pos.Validators) // OnEventConfirmed is callback type to notify about event confirmation. OnEventConfirmed func(event *EventHeaderData, seqDepth idx.Event) // IsEventAllowedIntoBlock is callback type to check is event may be within block or not IsEventAllowedIntoBlock func(event *EventHeaderData, seqDepth idx.Event) bool }
ConsensusCallbacks contains callbacks called during block processing by consensus engine
type Event ¶
type Event struct { EventHeader Transactions types.Transactions // contains filtered or unexported fields }
Event is the graph vertex in the Lachesis consensus algorithm
func FakeFuzzingEvents ¶
func FakeFuzzingEvents() (res []*Event)
FakeFuzzingEvents generates random independent events with the same epoch for testing purpose.
func (*Event) DecodeRLP ¶
DecodeRLP implements rlp.Decoder interface. Its goal to override custom decoder of promoted field EventHeaderData.
func (*Event) EncodeRLP ¶
EncodeRLP implements rlp.Encoder interface. Its goal to override custom encoder of promoted field EventHeaderData.
func (*Event) RecacheSize ¶
RecacheSize re-calculates event's size and caches it
type EventHeader ¶
type EventHeader struct { EventHeaderData Sig []byte }
EventHeader is the graph vertex in the Lachesis consensus algorithm Doesn't contain transactions, only their hash
type EventHeaderData ¶
type EventHeaderData struct { Version uint32 // serialization version Epoch idx.Epoch Seq idx.Event Frame idx.Frame IsRoot bool Creator idx.StakerID PrevEpochHash common.Hash Parents hash.Events GasPowerLeft GasPowerLeft GasPowerUsed uint64 Lamport idx.Lamport ClaimedTime Timestamp MedianTime Timestamp TxHash common.Hash Extra []byte // contains filtered or unexported fields }
EventHeaderData is the graph vertex in the Lachesis consensus algorithm Doesn't contain transactions, only their hash Doesn't contain event signature
func (*EventHeaderData) CalcHash ¶
func (e *EventHeaderData) CalcHash() hash.Event
CalcHash re-calculates event's ID
func (*EventHeaderData) DataToSign ¶
func (e *EventHeaderData) DataToSign() []byte
DataToSign returns data which must be signed to sign the event
func (*EventHeaderData) DecodeRLP ¶
func (e *EventHeaderData) DecodeRLP(src *rlp.Stream) error
DecodeRLP implements rlp.Decoder interface.
func (*EventHeaderData) EncodeRLP ¶
func (e *EventHeaderData) EncodeRLP(w io.Writer) error
EncodeRLP implements rlp.Encoder interface.
func (*EventHeaderData) Hash ¶
func (e *EventHeaderData) Hash() hash.Event
Hash returns cached event ID
func (*EventHeaderData) IsSelfParent ¶
func (e *EventHeaderData) IsSelfParent(hash hash.Event) bool
IsSelfParent is true if specified ID is event's self-parent
func (*EventHeaderData) MarshalBinary ¶
func (e *EventHeaderData) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler interface.
func (*EventHeaderData) NoTransactions ¶
func (e *EventHeaderData) NoTransactions() bool
NoTransactions is used to check that event doesn't have transactions not having full event.
func (*EventHeaderData) RecacheHash ¶
func (e *EventHeaderData) RecacheHash() hash.Event
RecacheHash re-calculates event's ID and caches it
func (*EventHeaderData) SelfParent ¶
func (e *EventHeaderData) SelfParent() *hash.Event
SelfParent returns event's self-parent, if any
func (*EventHeaderData) String ¶
func (e *EventHeaderData) String() string
String returns string representation.
func (*EventHeaderData) UnmarshalBinary ¶
func (e *EventHeaderData) UnmarshalBinary(raw []byte) (err error)
UnmarshalBinary implements encoding.BinaryUnmarshaler interface.
type Events ¶
type Events []*Event
Events is a ordered slice of events.
type ForEachEvent ¶
type GasPowerLeft ¶
type GasPowerLeft struct {
Gas [2]uint64
}
GasPowerLeft is long-term gas power left and short-term gas power left
func (*GasPowerLeft) Max ¶
func (g *GasPowerLeft) Max() uint64
Max returns maximum within long-term gas power left and short-term gas power left
func (*GasPowerLeft) Min ¶
func (g *GasPowerLeft) Min() uint64
Min returns minimum within long-term gas power left and short-term gas power left
func (*GasPowerLeft) String ¶
func (g *GasPowerLeft) String() string
String returns string representation.
func (*GasPowerLeft) Sub ¶
func (g *GasPowerLeft) Sub(diff uint64) *GasPowerLeft
Sub subtracts from all gas power lefts
type HeadersByCreator ¶
type HeadersByCreator map[idx.StakerID]*EventHeaderData
HeadersByCreator is a event headers grouped by creator. ( creator --> event header )
func (HeadersByCreator) Bytes ¶
func (hh HeadersByCreator) Bytes() []byte
Bytes gets the byte representation of the headers map.