Documentation
¶
Index ¶
- Constants
- func DummyInternalCommitCallback(b *Block) error
- type BadgerStore
- func (s *BadgerStore) AddConsensusEvent(event *Event) error
- func (s *BadgerStore) CacheSize() int
- func (s *BadgerStore) Close() error
- func (s *BadgerStore) ConsensusEvents() []string
- func (s *BadgerStore) ConsensusEventsCount() int
- func (s *BadgerStore) FirstRound(id uint32) (int, bool)
- func (s *BadgerStore) GetAllPeerSets() (map[int][]*peers.Peer, error)
- func (s *BadgerStore) GetBlock(rr int) (*Block, error)
- func (s *BadgerStore) GetEvent(key string) (*Event, error)
- func (s *BadgerStore) GetFrame(rr int) (*Frame, error)
- func (s *BadgerStore) GetPeerSet(round int) (peerSet *peers.PeerSet, err error)
- func (s *BadgerStore) GetRoot(participant string) (*Root, error)
- func (s *BadgerStore) GetRound(r int) (*RoundInfo, error)
- func (s *BadgerStore) KnownEvents() map[uint32]int
- func (s *BadgerStore) LastBlockIndex() int
- func (s *BadgerStore) LastConsensusEventFrom(participant string) (last string, err error)
- func (s *BadgerStore) LastEventFrom(participant string) (last string, err error)
- func (s *BadgerStore) LastRound() int
- func (s *BadgerStore) ParticipantEvent(participant string, index int) (string, error)
- func (s *BadgerStore) ParticipantEvents(participant string, skip int) ([]string, error)
- func (s *BadgerStore) RepertoireByID() map[uint32]*peers.Peer
- func (s *BadgerStore) RepertoireByPubKey() map[string]*peers.Peer
- func (s *BadgerStore) Reset(frame *Frame) error
- func (s *BadgerStore) RoundEvents(r int) int
- func (s *BadgerStore) RoundWitnesses(r int) []string
- func (s *BadgerStore) SetBlock(block *Block) error
- func (s *BadgerStore) SetEvent(event *Event) error
- func (s *BadgerStore) SetFrame(frame *Frame) error
- func (s *BadgerStore) SetPeerSet(round int, peerSet *peers.PeerSet) error
- func (s *BadgerStore) SetRound(r int, round *RoundInfo) error
- func (s *BadgerStore) StorePath() string
- type Block
- func (b *Block) AppendTransactions(txs [][]byte)
- func (b *Block) FrameHash() []byte
- func (b *Block) GetSignature(validator string) (res BlockSignature, err error)
- func (b *Block) GetSignatures() []BlockSignature
- func (b *Block) Hash() ([]byte, error)
- func (b *Block) Hex() string
- func (b *Block) Index() int
- func (b *Block) InternalTransactionReceipts() []InternalTransactionReceipt
- func (b *Block) InternalTransactions() []InternalTransaction
- func (b *Block) Marshal() ([]byte, error)
- func (b *Block) PeersHash() []byte
- func (b *Block) RoundReceived() int
- func (b *Block) SetSignature(bs BlockSignature) error
- func (b *Block) Sign(privKey *ecdsa.PrivateKey) (bs BlockSignature, err error)
- func (b *Block) StateHash() []byte
- func (b *Block) Transactions() [][]byte
- func (b *Block) Unmarshal(data []byte) error
- func (b *Block) Verify(sig BlockSignature) (bool, error)
- type BlockBody
- type BlockSignature
- type ByLamportTimestamp
- type ByTopologicalOrder
- type CoordinatesMap
- type Event
- func (e *Event) BlockSignatures() []BlockSignature
- func (e *Event) Creator() string
- func (e *Event) GetRound() *int
- func (e *Event) Hash() ([]byte, error)
- func (e *Event) Hex() string
- func (e *Event) Index() int
- func (e *Event) InternalTransactions() []InternalTransaction
- func (e *Event) IsLoaded() bool
- func (e *Event) Marshal() ([]byte, error)
- func (e *Event) OtherParent() string
- func (e *Event) SelfParent() string
- func (e *Event) SetLamportTimestamp(t int)
- func (e *Event) SetRound(r int)
- func (e *Event) SetRoundReceived(rr int)
- func (e *Event) SetWireInfo(selfParentIndex int, otherParentCreatorID uint32, otherParentIndex int, ...)
- func (e *Event) Sign(privKey *ecdsa.PrivateKey) error
- func (e *Event) ToWire() WireEvent
- func (e *Event) Transactions() [][]byte
- func (e *Event) Unmarshal(data []byte) error
- func (e *Event) Verify() (bool, error)
- func (e *Event) WireBlockSignatures() []WireBlockSignature
- type EventBody
- type EventCoordinates
- type Frame
- type FrameEvent
- type Hashgraph
- func (h *Hashgraph) Bootstrap() error
- func (h *Hashgraph) CheckBlock(block *Block, peerSet *peers.PeerSet) error
- func (h *Hashgraph) DecideFame() error
- func (h *Hashgraph) DecideRoundReceived() error
- func (h *Hashgraph) DivideRounds() error
- func (h *Hashgraph) GetAnchorBlockWithFrame() (*Block, *Frame, error)
- func (h *Hashgraph) GetFrame(roundReceived int) (*Frame, error)
- func (h *Hashgraph) Init(peerSet *peers.PeerSet) error
- func (h *Hashgraph) InsertEvent(event *Event, setWireInfo bool) error
- func (h *Hashgraph) InsertEventAndRunConsensus(event *Event, setWireInfo bool) error
- func (h *Hashgraph) InsertFrameEvent(frameEvent *FrameEvent) error
- func (h *Hashgraph) ProcessDecidedRounds() error
- func (h *Hashgraph) ProcessSigPool() error
- func (h *Hashgraph) ReadWireInfo(wevent WireEvent) (*Event, error)
- func (h *Hashgraph) Reset(block *Block, frame *Frame) error
- func (h *Hashgraph) SetAnchorBlock(block *Block) error
- type InmemStore
- func (s *InmemStore) AddConsensusEvent(event *Event) error
- func (s *InmemStore) CacheSize() int
- func (s *InmemStore) Close() error
- func (s *InmemStore) ConsensusEvents() []string
- func (s *InmemStore) ConsensusEventsCount() int
- func (s *InmemStore) FirstRound(id uint32) (int, bool)
- func (s *InmemStore) GetAllPeerSets() (map[int][]*peers.Peer, error)
- func (s *InmemStore) GetBlock(index int) (*Block, error)
- func (s *InmemStore) GetEvent(key string) (*Event, error)
- func (s *InmemStore) GetFrame(index int) (*Frame, error)
- func (s *InmemStore) GetPeerSet(round int) (*peers.PeerSet, error)
- func (s *InmemStore) GetRoot(participant string) (*Root, error)
- func (s *InmemStore) GetRound(r int) (*RoundInfo, error)
- func (s *InmemStore) KnownEvents() map[uint32]int
- func (s *InmemStore) LastBlockIndex() int
- func (s *InmemStore) LastConsensusEventFrom(participant string) (last string, err error)
- func (s *InmemStore) LastEventFrom(participant string) (last string, err error)
- func (s *InmemStore) LastRound() int
- func (s *InmemStore) ParticipantEvent(participant string, index int) (string, error)
- func (s *InmemStore) ParticipantEvents(participant string, skip int) ([]string, error)
- func (s *InmemStore) RepertoireByID() map[uint32]*peers.Peer
- func (s *InmemStore) RepertoireByPubKey() map[string]*peers.Peer
- func (s *InmemStore) Reset(frame *Frame) error
- func (s *InmemStore) RoundEvents(r int) int
- func (s *InmemStore) RoundWitnesses(r int) []string
- func (s *InmemStore) SetBlock(block *Block) error
- func (s *InmemStore) SetEvent(event *Event) error
- func (s *InmemStore) SetFrame(frame *Frame) error
- func (s *InmemStore) SetPeerSet(round int, peerSet *peers.PeerSet) error
- func (s *InmemStore) SetRound(r int, round *RoundInfo) error
- func (s *InmemStore) StorePath() string
- type InternalCommitCallback
- type InternalTransaction
- func (t *InternalTransaction) AsAccepted() InternalTransactionReceipt
- func (t *InternalTransaction) AsRefused() InternalTransactionReceipt
- func (t *InternalTransaction) HashString() string
- func (t *InternalTransaction) Marshal() ([]byte, error)
- func (t *InternalTransaction) Sign(privKey *ecdsa.PrivateKey) error
- func (t *InternalTransaction) Unmarshal(data []byte) error
- func (t *InternalTransaction) Verify() (bool, error)
- type InternalTransactionBody
- type InternalTransactionReceipt
- type Key
- type OrderedPendingRounds
- type ParticipantEventsCache
- func (pec *ParticipantEventsCache) AddPeer(peer *peers.Peer) error
- func (pec *ParticipantEventsCache) Get(participant string, skipIndex int) ([]string, error)
- func (pec *ParticipantEventsCache) GetItem(participant string, index int) (string, error)
- func (pec *ParticipantEventsCache) GetLast(participant string) (string, error)
- func (pec *ParticipantEventsCache) Known() map[uint32]int
- func (pec *ParticipantEventsCache) Set(participant string, hash string, index int) error
- type PeerSetCache
- func (c *PeerSetCache) FirstRound(id uint32) (int, bool)
- func (c *PeerSetCache) Get(round int) (*peers.PeerSet, error)
- func (c *PeerSetCache) GetAll() (map[int][]*peers.Peer, error)
- func (c *PeerSetCache) RepertoireByID() map[uint32]*peers.Peer
- func (c *PeerSetCache) RepertoireByPubKey() map[string]*peers.Peer
- func (c *PeerSetCache) Set(round int, peerSet *peers.PeerSet) error
- type PendingRound
- type PendingRoundsCache
- func (c *PendingRoundsCache) Clean(processedRounds []int)
- func (c *PendingRoundsCache) GetOrderedPendingRounds() OrderedPendingRounds
- func (c *PendingRoundsCache) Queued(round int) bool
- func (c *PendingRoundsCache) Set(pendingRound *PendingRound)
- func (c *PendingRoundsCache) Update(decidedRounds []int)
- type Root
- type RoundEvent
- type RoundInfo
- func (r *RoundInfo) AddCreatedEvent(x string, witness bool)
- func (r *RoundInfo) AddReceivedEvent(x string)
- func (r *RoundInfo) FamousWitnesses() []string
- func (r *RoundInfo) IsDecided(witness string) bool
- func (r *RoundInfo) IsQueued() bool
- func (r *RoundInfo) Marshal() ([]byte, error)
- func (r *RoundInfo) SetFame(x string, f bool)
- func (r *RoundInfo) Unmarshal(data []byte) error
- func (r *RoundInfo) Witnesses() []string
- func (r *RoundInfo) WitnessesDecided(peerSet *peers.PeerSet) bool
- type SigPool
- type SortedFrameEvents
- type Store
- type TransactionType
- type TreKey
- type WireBlockSignature
- type WireBody
- type WireEvent
Constants ¶
const ( /* ROOT_DEPTH determines how many FrameEvents are included in the Root. It is preferable not to make ROOT_DEPTH configurable because if peers use diffent values, they will produce different Roots, different Frames, and different Blocks. Perhaps this parameter should be tied to the number of Peers rather than hard-coded. */ ROOT_DEPTH = 10 /* COIN_ROUND_FREQ defines the frequency of coin rounds. The value is arbitrary. Do something smarter. */ COIN_ROUND_FREQ = float64(4) )
Variables ¶
This section is empty.
Functions ¶
func DummyInternalCommitCallback ¶ added in v0.4.1
DummyInternalCommitCallback is used for testing
Types ¶
type BadgerStore ¶
type BadgerStore struct {
// contains filtered or unexported fields
}
func NewBadgerStore ¶
func NewBadgerStore(cacheSize int, path string) (*BadgerStore, error)
NewBadgerStore opens an existing database or creates a new one if nothing is found in path.
func (*BadgerStore) AddConsensusEvent ¶
func (s *BadgerStore) AddConsensusEvent(event *Event) error
func (*BadgerStore) CacheSize ¶
func (s *BadgerStore) CacheSize() int
func (*BadgerStore) Close ¶
func (s *BadgerStore) Close() error
func (*BadgerStore) ConsensusEvents ¶
func (s *BadgerStore) ConsensusEvents() []string
func (*BadgerStore) ConsensusEventsCount ¶
func (s *BadgerStore) ConsensusEventsCount() int
func (*BadgerStore) FirstRound ¶ added in v0.5.0
func (s *BadgerStore) FirstRound(id uint32) (int, bool)
func (*BadgerStore) GetAllPeerSets ¶ added in v0.5.0
func (s *BadgerStore) GetAllPeerSets() (map[int][]*peers.Peer, error)
func (*BadgerStore) GetPeerSet ¶ added in v0.4.1
func (s *BadgerStore) GetPeerSet(round int) (peerSet *peers.PeerSet, err error)
func (*BadgerStore) KnownEvents ¶
func (s *BadgerStore) KnownEvents() map[uint32]int
func (*BadgerStore) LastBlockIndex ¶
func (s *BadgerStore) LastBlockIndex() int
func (*BadgerStore) LastConsensusEventFrom ¶
func (s *BadgerStore) LastConsensusEventFrom(participant string) (last string, err error)
func (*BadgerStore) LastEventFrom ¶
func (s *BadgerStore) LastEventFrom(participant string) (last string, err error)
func (*BadgerStore) LastRound ¶
func (s *BadgerStore) LastRound() int
func (*BadgerStore) ParticipantEvent ¶
func (s *BadgerStore) ParticipantEvent(participant string, index int) (string, error)
func (*BadgerStore) ParticipantEvents ¶
func (s *BadgerStore) ParticipantEvents(participant string, skip int) ([]string, error)
func (*BadgerStore) RepertoireByID ¶ added in v0.4.1
func (s *BadgerStore) RepertoireByID() map[uint32]*peers.Peer
func (*BadgerStore) RepertoireByPubKey ¶ added in v0.4.1
func (s *BadgerStore) RepertoireByPubKey() map[string]*peers.Peer
func (*BadgerStore) Reset ¶
func (s *BadgerStore) Reset(frame *Frame) error
func (*BadgerStore) RoundEvents ¶
func (s *BadgerStore) RoundEvents(r int) int
func (*BadgerStore) RoundWitnesses ¶
func (s *BadgerStore) RoundWitnesses(r int) []string
func (*BadgerStore) SetBlock ¶
func (s *BadgerStore) SetBlock(block *Block) error
func (*BadgerStore) SetEvent ¶
func (s *BadgerStore) SetEvent(event *Event) error
func (*BadgerStore) SetFrame ¶
func (s *BadgerStore) SetFrame(frame *Frame) error
func (*BadgerStore) SetPeerSet ¶ added in v0.4.1
func (s *BadgerStore) SetPeerSet(round int, peerSet *peers.PeerSet) error
func (*BadgerStore) StorePath ¶
func (s *BadgerStore) StorePath() string
type Block ¶
type Block struct {
Body BlockBody
Signatures map[string]string // [validator hex] => signature
// contains filtered or unexported fields
}
func (*Block) AppendTransactions ¶
func (*Block) GetSignature ¶
func (b *Block) GetSignature(validator string) (res BlockSignature, err error)
func (*Block) GetSignatures ¶
func (b *Block) GetSignatures() []BlockSignature
func (*Block) InternalTransactionReceipts ¶ added in v0.5.0
func (b *Block) InternalTransactionReceipts() []InternalTransactionReceipt
func (*Block) InternalTransactions ¶ added in v0.5.0
func (b *Block) InternalTransactions() []InternalTransaction
func (*Block) RoundReceived ¶
func (*Block) SetSignature ¶
func (b *Block) SetSignature(bs BlockSignature) error
func (*Block) Sign ¶
func (b *Block) Sign(privKey *ecdsa.PrivateKey) (bs BlockSignature, err error)
func (*Block) Transactions ¶
type BlockBody ¶
type BlockBody struct {
Index int
RoundReceived int
StateHash []byte
FrameHash []byte
PeersHash []byte
Transactions [][]byte
InternalTransactions []InternalTransaction
InternalTransactionReceipts []InternalTransactionReceipt
}
type BlockSignature ¶
func (*BlockSignature) Key ¶ added in v0.4.1
func (bs *BlockSignature) Key() string
func (*BlockSignature) Marshal ¶
func (bs *BlockSignature) Marshal() ([]byte, error)
func (*BlockSignature) ToWire ¶
func (bs *BlockSignature) ToWire() WireBlockSignature
func (*BlockSignature) Unmarshal ¶
func (bs *BlockSignature) Unmarshal(data []byte) error
func (*BlockSignature) ValidatorHex ¶
func (bs *BlockSignature) ValidatorHex() string
type ByLamportTimestamp ¶
type ByLamportTimestamp []*Event
ByLamportTimestamp implements sort.Interface for []Event based on the lamportTimestamp field. THIS IS A TOTAL ORDER
func (ByLamportTimestamp) Len ¶
func (a ByLamportTimestamp) Len() int
func (ByLamportTimestamp) Less ¶
func (a ByLamportTimestamp) Less(i, j int) bool
func (ByLamportTimestamp) Swap ¶
func (a ByLamportTimestamp) Swap(i, j int)
type ByTopologicalOrder ¶
type ByTopologicalOrder []*Event
ByTopologicalOrder implements sort.Interface for []Event based on the topologicalIndex field. THIS IS A PARTIAL ORDER
func (ByTopologicalOrder) Len ¶
func (a ByTopologicalOrder) Len() int
func (ByTopologicalOrder) Less ¶
func (a ByTopologicalOrder) Less(i, j int) bool
func (ByTopologicalOrder) Swap ¶
func (a ByTopologicalOrder) Swap(i, j int)
type CoordinatesMap ¶ added in v0.4.1
type CoordinatesMap map[string]EventCoordinates
func NewCoordinatesMap ¶ added in v0.4.1
func NewCoordinatesMap() CoordinatesMap
func (CoordinatesMap) Copy ¶ added in v0.4.1
func (c CoordinatesMap) Copy() CoordinatesMap
type Event ¶
type Event struct {
Body EventBody
Signature string //creator's digital signature of body
// contains filtered or unexported fields
}
func NewEvent ¶
func NewEvent(transactions [][]byte, internalTransactions []InternalTransaction, blockSignatures []BlockSignature, parents []string, creator []byte, index int) *Event
func (*Event) BlockSignatures ¶
func (e *Event) BlockSignatures() []BlockSignature
func (*Event) InternalTransactions ¶ added in v0.5.0
func (e *Event) InternalTransactions() []InternalTransaction
func (*Event) OtherParent ¶
func (*Event) SelfParent ¶
func (*Event) SetLamportTimestamp ¶
func (*Event) SetRoundReceived ¶
func (*Event) SetWireInfo ¶
func (*Event) Transactions ¶
func (*Event) WireBlockSignatures ¶
func (e *Event) WireBlockSignatures() []WireBlockSignature
type EventBody ¶
type EventBody struct {
Transactions [][]byte //the payload
InternalTransactions []InternalTransaction //peers add and removal internal consensus
Parents []string //hashes of the event's parents, self-parent first
Creator []byte //creator's public key
Index int //index in the sequence of events created by Creator
BlockSignatures []BlockSignature //list of Block signatures signed by the Event's Creator ONLY
// contains filtered or unexported fields
}
type EventCoordinates ¶
type EventCoordinates struct {
// contains filtered or unexported fields
}
type Frame ¶
type Frame struct {
Round int //RoundReceived
Peers []*peers.Peer
Roots map[string]*Root
Events []*FrameEvent //Events with RoundReceived = Round
PeerSets map[int][]*peers.Peer //[round] => Peers
}
func (*Frame) SortedFrameEvents ¶ added in v0.5.0
func (f *Frame) SortedFrameEvents() []*FrameEvent
type FrameEvent ¶ added in v0.5.0
type FrameEvent struct {
Core *Event //EventBody + Signature
Round int
LamportTimestamp int
Witness bool
}
FrameEvent is a wrapper around a regular Event. It contains exported fields Round, Witness, and LamportTimestamp.
type Hashgraph ¶
type Hashgraph struct {
Store Store //store of Events, Rounds, and Blocks
UndeterminedEvents []string //[index] => hash . FIFO queue of Events whose consensus order is not yet determined
PendingRounds *PendingRoundsCache //FIFO queue of Rounds which have not attained consensus yet
PendingSignatures *SigPool //Pool of Block signatures that need to be processed (matched with Blocks)
LastConsensusRound *int //index of last consensus round
FirstConsensusRound *int //index of first consensus round (only used in tests)
AnchorBlock *int //index of last block with enough signatures
LastCommitedRoundEvents int //number of events in round before LastConsensusRound
ConsensusTransactions int //number of consensus transactions
PendingLoadedEvents int //number of loaded events that are not yet committed
// contains filtered or unexported fields
}
Hashgraph is a DAG of Events. It also contains methods to extract a consensus order of Events and map them onto a blockchain.
func NewHashgraph ¶
func NewHashgraph(store Store, commitCallback InternalCommitCallback, logger *logrus.Entry) *Hashgraph
NewHashgraph instantiates a Hashgraph with an underlying data store and a commit callback
func (*Hashgraph) Bootstrap ¶
Bootstrap loads all Events from the Store's DB (if there is one) and feeds them to the Hashgraph consensus methods in topological order. It is assumed that no events are skipped/lost when loading from the database - WE CAN ONLY BOOTSTRAP FROM 0. As Events are inserted and processed, Blocks will be created and committed to the App layer (via the commit callback), so it is also assumed that the application state was reset.
func (*Hashgraph) CheckBlock ¶
CheckBlock returns an error if the Block does not contain valid signatures from MORE than 1/3 of participants
func (*Hashgraph) DecideFame ¶
DecideFame decides if witnesses are famous
func (*Hashgraph) DecideRoundReceived ¶
DecideRoundReceived assigns a RoundReceived to undetermined events when they reach consensus
func (*Hashgraph) DivideRounds ¶
DivideRounds assigns a Round and LamportTimestamp to Events, and flags them as witnesses if necessary. Pushes Rounds in the PendingRounds queue if necessary.
func (*Hashgraph) GetAnchorBlockWithFrame ¶
GetAnchorBlockWithFrame returns the AnchorBlock and the corresponding Frame. This can be used as a base to Reset a Hashgraph
func (*Hashgraph) Init ¶ added in v0.4.1
Init sets the initial PeerSet, which also creates the corresponding Roots and updates the Repertoire.
func (*Hashgraph) InsertEvent ¶
InsertEvent attempts to insert an Event in the DAG. It verifies the signature, checks the ancestors are known, and prevents the introduction of forks.
func (*Hashgraph) InsertEventAndRunConsensus ¶ added in v0.4.1
InsertEventAndRunConsensus inserts an Event in the Hashgraph and call the consensus methods.
func (*Hashgraph) InsertFrameEvent ¶ added in v0.5.0
func (h *Hashgraph) InsertFrameEvent(frameEvent *FrameEvent) error
InsertFrameEvent inserts the FrameEvent's core Event, without checking its parents or signature. It doesnt add the Event to UndeterminedEvents either.
func (*Hashgraph) ProcessDecidedRounds ¶
ProcessDecidedRounds takes Rounds whose witnesses are decided, computes the corresponding Frames, maps them into Blocks, and commits the Blocks via the commit channel
func (*Hashgraph) ProcessSigPool ¶
ProcessSigPool runs through the SignaturePool and tries to map a Signature to a known Block. If a Signature is valid, it is appended to the block and removed from the SignaturePool. The function also updates the AnchorBlock if necessary.
func (*Hashgraph) ReadWireInfo ¶
ReadWireInfo converts a WireEvent to an Event by replacing int IDs with the corresponding public keys.
func (*Hashgraph) SetAnchorBlock ¶ added in v0.4.1
SetAnchorBlock sets the AnchorBlock index if the proposed block has collected enough signatures (+1/3) and is above the current AnchorBlock. The AnchorBlock is the latest Block that collected +1/3 signatures from validators. It is used in FastForward responses when a node wants to sync to the top of the hashgraph.
type InmemStore ¶
type InmemStore struct {
// contains filtered or unexported fields
}
func NewInmemStore ¶
func NewInmemStore(cacheSize int) *InmemStore
func (*InmemStore) AddConsensusEvent ¶
func (s *InmemStore) AddConsensusEvent(event *Event) error
func (*InmemStore) CacheSize ¶
func (s *InmemStore) CacheSize() int
func (*InmemStore) Close ¶
func (s *InmemStore) Close() error
func (*InmemStore) ConsensusEvents ¶
func (s *InmemStore) ConsensusEvents() []string
func (*InmemStore) ConsensusEventsCount ¶
func (s *InmemStore) ConsensusEventsCount() int
func (*InmemStore) FirstRound ¶ added in v0.5.0
func (s *InmemStore) FirstRound(id uint32) (int, bool)
func (*InmemStore) GetAllPeerSets ¶ added in v0.5.0
func (s *InmemStore) GetAllPeerSets() (map[int][]*peers.Peer, error)
func (*InmemStore) GetPeerSet ¶ added in v0.4.1
func (s *InmemStore) GetPeerSet(round int) (*peers.PeerSet, error)
func (*InmemStore) KnownEvents ¶
func (s *InmemStore) KnownEvents() map[uint32]int
func (*InmemStore) LastBlockIndex ¶
func (s *InmemStore) LastBlockIndex() int
func (*InmemStore) LastConsensusEventFrom ¶
func (s *InmemStore) LastConsensusEventFrom(participant string) (last string, err error)
func (*InmemStore) LastEventFrom ¶
func (s *InmemStore) LastEventFrom(participant string) (last string, err error)
func (*InmemStore) LastRound ¶
func (s *InmemStore) LastRound() int
func (*InmemStore) ParticipantEvent ¶
func (s *InmemStore) ParticipantEvent(participant string, index int) (string, error)
func (*InmemStore) ParticipantEvents ¶
func (s *InmemStore) ParticipantEvents(participant string, skip int) ([]string, error)
func (*InmemStore) RepertoireByID ¶ added in v0.4.1
func (s *InmemStore) RepertoireByID() map[uint32]*peers.Peer
func (*InmemStore) RepertoireByPubKey ¶ added in v0.4.1
func (s *InmemStore) RepertoireByPubKey() map[string]*peers.Peer
func (*InmemStore) Reset ¶
func (s *InmemStore) Reset(frame *Frame) error
func (*InmemStore) RoundEvents ¶
func (s *InmemStore) RoundEvents(r int) int
func (*InmemStore) RoundWitnesses ¶
func (s *InmemStore) RoundWitnesses(r int) []string
func (*InmemStore) SetBlock ¶
func (s *InmemStore) SetBlock(block *Block) error
func (*InmemStore) SetEvent ¶
func (s *InmemStore) SetEvent(event *Event) error
func (*InmemStore) SetFrame ¶
func (s *InmemStore) SetFrame(frame *Frame) error
func (*InmemStore) SetPeerSet ¶ added in v0.4.1
func (s *InmemStore) SetPeerSet(round int, peerSet *peers.PeerSet) error
SetPeerSet updates the peerSetCache and participantEventsCache
func (*InmemStore) StorePath ¶
func (s *InmemStore) StorePath() string
type InternalCommitCallback ¶ added in v0.4.1
InternalCommitCallback is called by the Hashgraph to commit a Block. The InternalCommitCallback will likely itself call the ProxyCommitCallback. We add a layer of indirection because processing the CommitResponse should be handled by the Core object, not the hashgraph; the hashgraph only knows if there was an error or not.
type InternalTransaction ¶ added in v0.5.0
type InternalTransaction struct {
Body InternalTransactionBody
Signature string
}
func NewInternalTransaction ¶ added in v0.5.0
func NewInternalTransaction(tType TransactionType, peer peers.Peer) InternalTransaction
func NewInternalTransactionJoin ¶ added in v0.5.0
func NewInternalTransactionJoin(peer peers.Peer) InternalTransaction
func NewInternalTransactionLeave ¶ added in v0.5.0
func NewInternalTransactionLeave(peer peers.Peer) InternalTransaction
func (*InternalTransaction) AsAccepted ¶ added in v0.5.0
func (t *InternalTransaction) AsAccepted() InternalTransactionReceipt
AsAccepted returns a receipt to accept an InternalTransaction
func (*InternalTransaction) AsRefused ¶ added in v0.5.0
func (t *InternalTransaction) AsRefused() InternalTransactionReceipt
AsRefused return a receipt to refuse an InternalTransaction
func (*InternalTransaction) HashString ¶ added in v0.5.0
func (t *InternalTransaction) HashString() string
HashString returns a string representation of the body's hash. It is used in node/core as a key in a map to keep track of InternalTransactions as they are being processed asynchronously by the consensus and application.
func (*InternalTransaction) Marshal ¶ added in v0.5.0
func (t *InternalTransaction) Marshal() ([]byte, error)
func (*InternalTransaction) Sign ¶ added in v0.5.0
func (t *InternalTransaction) Sign(privKey *ecdsa.PrivateKey) error
Sign returns the ecdsa signature of the SHA256 hash of the transaction's body
func (*InternalTransaction) Unmarshal ¶ added in v0.5.0
func (t *InternalTransaction) Unmarshal(data []byte) error
func (*InternalTransaction) Verify ¶ added in v0.5.0
func (t *InternalTransaction) Verify() (bool, error)
type InternalTransactionBody ¶ added in v0.5.0
type InternalTransactionBody struct {
Type TransactionType
Peer peers.Peer
}
func (*InternalTransactionBody) Hash ¶ added in v0.5.0
func (i *InternalTransactionBody) Hash() ([]byte, error)
Hash returns the SHA256 hash of the InternalTransactionBody,
func (*InternalTransactionBody) Marshal ¶ added in v0.5.0
func (i *InternalTransactionBody) Marshal() ([]byte, error)
json encoding of body
type InternalTransactionReceipt ¶ added in v0.5.0
type InternalTransactionReceipt struct {
InternalTransaction InternalTransaction
Accepted bool
}
InternalTransactionReceipt records the decision by the application to accept or refuse and InternalTransaction
type OrderedPendingRounds ¶ added in v0.4.1
type OrderedPendingRounds []*PendingRound
func (OrderedPendingRounds) Len ¶ added in v0.4.1
func (a OrderedPendingRounds) Len() int
func (OrderedPendingRounds) Less ¶ added in v0.4.1
func (a OrderedPendingRounds) Less(i, j int) bool
func (OrderedPendingRounds) Swap ¶ added in v0.4.1
func (a OrderedPendingRounds) Swap(i, j int)
type ParticipantEventsCache ¶
type ParticipantEventsCache struct {
// contains filtered or unexported fields
}
func NewParticipantEventsCache ¶
func NewParticipantEventsCache(size int) *ParticipantEventsCache
func (*ParticipantEventsCache) AddPeer ¶ added in v0.4.1
func (pec *ParticipantEventsCache) AddPeer(peer *peers.Peer) error
func (*ParticipantEventsCache) Get ¶
func (pec *ParticipantEventsCache) Get(participant string, skipIndex int) ([]string, error)
Get returns participant events with index > skip
func (*ParticipantEventsCache) GetItem ¶
func (pec *ParticipantEventsCache) GetItem(participant string, index int) (string, error)
func (*ParticipantEventsCache) GetLast ¶
func (pec *ParticipantEventsCache) GetLast(participant string) (string, error)
func (*ParticipantEventsCache) Known ¶
func (pec *ParticipantEventsCache) Known() map[uint32]int
returns [participant id] => lastKnownIndex
type PeerSetCache ¶ added in v0.4.1
type PeerSetCache struct {
// contains filtered or unexported fields
}
func NewPeerSetCache ¶ added in v0.4.1
func NewPeerSetCache() *PeerSetCache
func (*PeerSetCache) FirstRound ¶ added in v0.5.0
func (c *PeerSetCache) FirstRound(id uint32) (int, bool)
func (*PeerSetCache) Get ¶ added in v0.4.1
func (c *PeerSetCache) Get(round int) (*peers.PeerSet, error)
func (*PeerSetCache) GetAll ¶ added in v0.5.0
func (c *PeerSetCache) GetAll() (map[int][]*peers.Peer, error)
func (*PeerSetCache) RepertoireByID ¶ added in v0.5.0
func (c *PeerSetCache) RepertoireByID() map[uint32]*peers.Peer
func (*PeerSetCache) RepertoireByPubKey ¶ added in v0.5.0
func (c *PeerSetCache) RepertoireByPubKey() map[string]*peers.Peer
type PendingRound ¶ added in v0.4.1
type PendingRoundsCache ¶ added in v0.4.1
type PendingRoundsCache struct {
// contains filtered or unexported fields
}
func NewPendingRoundsCache ¶ added in v0.4.1
func NewPendingRoundsCache() *PendingRoundsCache
func (*PendingRoundsCache) Clean ¶ added in v0.4.1
func (c *PendingRoundsCache) Clean(processedRounds []int)
func (*PendingRoundsCache) GetOrderedPendingRounds ¶ added in v0.4.1
func (c *PendingRoundsCache) GetOrderedPendingRounds() OrderedPendingRounds
func (*PendingRoundsCache) Queued ¶ added in v0.4.1
func (c *PendingRoundsCache) Queued(round int) bool
func (*PendingRoundsCache) Set ¶ added in v0.4.1
func (c *PendingRoundsCache) Set(pendingRound *PendingRound)
func (*PendingRoundsCache) Update ¶ added in v0.4.1
func (c *PendingRoundsCache) Update(decidedRounds []int)
type Root ¶
type Root struct {
Events []*FrameEvent
}
Root forms a base on top of which a participant's Events can be inserted. It contains FrameEvents sorted by Lamport timestamp.
func (*Root) Insert ¶ added in v0.4.1
func (r *Root) Insert(frameEvent *FrameEvent)
Insert appends a FrameEvent to the root's Event slice. It is assumend that items are inserted in topological order.
type RoundEvent ¶
type RoundInfo ¶
type RoundInfo struct {
CreatedEvents map[string]RoundEvent
ReceivedEvents []string
// contains filtered or unexported fields
}
func NewRoundInfo ¶
func NewRoundInfo() *RoundInfo
func (*RoundInfo) AddCreatedEvent ¶ added in v0.4.1
func (*RoundInfo) AddReceivedEvent ¶ added in v0.4.1
func (*RoundInfo) FamousWitnesses ¶
return famous witnesses
func (*RoundInfo) WitnessesDecided ¶
WitnessesDecided returns true if a super-majority of witnesses are decided, and there are no undecided witnesses. Our algorithm relies on the fact that a witness that is not yet known when a super-majority of witnesses are already decided, has no chance of ever being famous. Once a Round is decided it stays decided, even if new witnesses are added after it was first decided.
type SigPool ¶ added in v0.4.1
type SigPool struct {
// contains filtered or unexported fields
}
func NewSigPool ¶ added in v0.4.1
func NewSigPool() *SigPool
func (*SigPool) Add ¶ added in v0.4.1
func (sp *SigPool) Add(blockSignature BlockSignature)
func (*SigPool) Items ¶ added in v0.4.1
func (sp *SigPool) Items() map[string]BlockSignature
func (*SigPool) RemoveSlice ¶ added in v0.4.1
func (sp *SigPool) RemoveSlice(sigs []BlockSignature)
func (*SigPool) Slice ¶ added in v0.4.1
func (sp *SigPool) Slice() []BlockSignature
type SortedFrameEvents ¶ added in v0.5.0
type SortedFrameEvents []*FrameEvent
SortedFrameEvents implements sort.Interface for []FameEvent based on the lamportTimestamp field. THIS IS A TOTAL ORDER
func (SortedFrameEvents) Len ¶ added in v0.5.0
func (a SortedFrameEvents) Len() int
func (SortedFrameEvents) Less ¶ added in v0.5.0
func (a SortedFrameEvents) Less(i, j int) bool
func (SortedFrameEvents) Swap ¶ added in v0.5.0
func (a SortedFrameEvents) Swap(i, j int)
type Store ¶
type Store interface {
CacheSize() int
GetPeerSet(int) (*peers.PeerSet, error)
SetPeerSet(int, *peers.PeerSet) error
GetAllPeerSets() (map[int][]*peers.Peer, error)
FirstRound(uint32) (int, bool)
RepertoireByPubKey() map[string]*peers.Peer
RepertoireByID() map[uint32]*peers.Peer
GetEvent(string) (*Event, error)
SetEvent(*Event) error
ParticipantEvents(string, int) ([]string, error)
ParticipantEvent(string, int) (string, error)
LastEventFrom(string) (string, error)
LastConsensusEventFrom(string) (string, error)
KnownEvents() map[uint32]int
ConsensusEvents() []string
ConsensusEventsCount() int
AddConsensusEvent(*Event) error
GetRound(int) (*RoundInfo, error)
SetRound(int, *RoundInfo) error
LastRound() int
RoundWitnesses(int) []string
RoundEvents(int) int
GetRoot(string) (*Root, error)
GetBlock(int) (*Block, error)
SetBlock(*Block) error
LastBlockIndex() int
GetFrame(int) (*Frame, error)
SetFrame(*Frame) error
Reset(*Frame) error
Close() error
StorePath() string
}
type TransactionType ¶ added in v0.5.0
type TransactionType uint8
const ( PEER_ADD TransactionType = iota PEER_REMOVE )
func (TransactionType) String ¶ added in v0.5.0
func (t TransactionType) String() string
type WireBlockSignature ¶
type WireBody ¶
type WireBody struct {
Transactions [][]byte
InternalTransactions []InternalTransaction
BlockSignatures []WireBlockSignature
CreatorID uint32
OtherParentCreatorID uint32
Index int
SelfParentIndex int
OtherParentIndex int
}
type WireEvent ¶
func (*WireEvent) BlockSignatures ¶
func (we *WireEvent) BlockSignatures(validator []byte) []BlockSignature