hashgraph

package
v0.8.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2021 License: MIT Imports: 18 Imported by: 3

Documentation

Overview

Package hashgraph implements the distributed consensus algorithm.

Babble is based on the Hashgraph consensus algorithm, invented by Leemon Baird:

http://www.swirlds.com/downloads/SWIRLDS-TR-2016-01.pdf

http://www.swirlds.com/downloads/SWIRLDS-TR-2016-02.pdf

Store

The hashgraph is a data structure that contains all the information about the history of the gossip and thereby continuously grows as gossip spreads. There are various strategies to keep the size of the hashgraph limited. In our implementation, the Hashgraph object has a dependency on a Store object which contains the actual data and is abstracted behind an interface.

There are currently two implementations of the Store interface. InmemStore uses a set of in-memory LRU caches which can be extended to persist stale items to disk and the size of the LRU caches is configurable. BadgerStore is a wrapper around this cache that also persists objects to a key-value store on disk. The database produced by the BadgerStore can be reused to bootstrap a node back to a specific state.

Blocks

Babble projects the hashgraph DAG onto a linear data structure composed of blocks. The consensus algorithm operates on the DAG but the consumable output is an ordered list of blocks. Each block contains an ordered list of transactions, a hash of the resulting application state, a hash of the corresponding section of the hashgraph (Frame), a hash of the current peer-set, and a collection of signatures from the set of validators. This method enables hashgraph-based systems to implement light-weight clients to audit and verify blocks without implementing the full consensus algorithm.

Index

Constants

View Source
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
	COIN_ROUND_FREQ = float64(4)
)

Variables

This section is empty.

Functions

func DummyInternalCommitCallback added in v0.4.1

func DummyInternalCommitCallback(b *Block) error

DummyInternalCommitCallback is used for testing

func IsNormalSelfParentError added in v0.5.5

func IsNormalSelfParentError(err error) bool

IsNormalSelfParentError checks that an error is of type SelfParentError and that it is normal. Because of the asynchronous nature of Babble, some routines will simultaneously try to append the same event, which is obviously not allowed and will throw a SelfParent error. But such errors are not real errors that we want to report in the logs.

Types

type BadgerStore

type BadgerStore struct {
	// contains filtered or unexported fields
}

BadgerStore contains references to the Badger database and inmem store. If maintenanceMode is activated, data is not written to the Badger database, but only to the caches.

func NewBadgerStore

func NewBadgerStore(cacheSize int, path string, maintenanceMode bool, logger *logrus.Entry) (*BadgerStore, error)

NewBadgerStore opens an existing database or creates a new one if nothing is found in path. The maintenanceMode option deactivates writing to the persistant database, but adding/updating the inmem-store is preserved.

func (*BadgerStore) AddConsensusEvent

func (s *BadgerStore) AddConsensusEvent(event *Event) error

AddConsensusEvent adds a consensus event.

func (*BadgerStore) CacheSize

func (s *BadgerStore) CacheSize() int

CacheSize gets the inmem cache size

func (*BadgerStore) Close

func (s *BadgerStore) Close() error

Close closes the InmemStore and the underlying Badger database.

func (*BadgerStore) ConsensusEvents

func (s *BadgerStore) ConsensusEvents() []string

ConsensusEvents returns the entire list of hashes of consensus-events.

func (*BadgerStore) ConsensusEventsCount

func (s *BadgerStore) ConsensusEventsCount() int

ConsensusEventsCount returns number of consensus events.

func (*BadgerStore) FirstRound added in v0.5.0

func (s *BadgerStore) FirstRound(id uint32) (int, bool)

FirstRound returns the first round in which a given participant (identified by id) was a member of the corresponding peer-set.

func (*BadgerStore) GetAllPeerSets added in v0.5.0

func (s *BadgerStore) GetAllPeerSets() (map[int][]*peers.Peer, error)

GetAllPeerSets returns the entire history of peer-sets.

func (*BadgerStore) GetBlock

func (s *BadgerStore) GetBlock(rr int) (*Block, error)

GetBlock returns a Block by index.

func (*BadgerStore) GetEvent

func (s *BadgerStore) GetEvent(key string) (*Event, error)

GetEvent returns the event identified by its hash.

func (*BadgerStore) GetFrame

func (s *BadgerStore) GetFrame(rr int) (*Frame, error)

GetFrame return the Frame corresponding to round-received rr.

func (*BadgerStore) GetMaintenanceMode added in v0.5.11

func (s *BadgerStore) GetMaintenanceMode() bool

GetMaintenanceMode is a getter

func (*BadgerStore) GetPeerSet added in v0.4.1

func (s *BadgerStore) GetPeerSet(round int) (peerSet *peers.PeerSet, err error)

GetPeerSet returns the peer-set effective at a given round.

func (*BadgerStore) GetRoot

func (s *BadgerStore) GetRoot(participant string) (*Root, error)

GetRoot returns the Root for a given participant.

func (*BadgerStore) GetRound

func (s *BadgerStore) GetRound(r int) (*RoundInfo, error)

GetRound returns the round with round-number r.

func (*BadgerStore) KnownEvents

func (s *BadgerStore) KnownEvents() map[uint32]int

KnownEvents returns a map of participant-ID to index of last known Event.

func (*BadgerStore) LastBlockIndex

func (s *BadgerStore) LastBlockIndex() int

LastBlockIndex returns the index of the last known block.

func (*BadgerStore) LastConsensusEventFrom

func (s *BadgerStore) LastConsensusEventFrom(participant string) (last string, err error)

LastConsensusEventFrom returns the hash of the last consensus-event from a given participant.

func (*BadgerStore) LastEventFrom

func (s *BadgerStore) LastEventFrom(participant string) (last string, err error)

LastEventFrom returns the hash of the last Event from a given participant.

func (*BadgerStore) LastRound

func (s *BadgerStore) LastRound() int

LastRound returns the number of the last known round.

func (*BadgerStore) ParticipantEvent

func (s *BadgerStore) ParticipantEvent(participant string, index int) (string, error)

ParticipantEvent returns a participant's Event for a given index.

func (*BadgerStore) ParticipantEvents

func (s *BadgerStore) ParticipantEvents(participant string, skip int) ([]string, error)

ParticipantEvents returns a participant's Event hashes, ordered by index, starting at index "skip".

func (*BadgerStore) RepertoireByID added in v0.4.1

func (s *BadgerStore) RepertoireByID() map[uint32]*peers.Peer

RepertoireByID returns a map of peers by id.

func (*BadgerStore) RepertoireByPubKey added in v0.4.1

func (s *BadgerStore) RepertoireByPubKey() map[string]*peers.Peer

RepertoireByPubKey returns a map of peers by public-key.

func (*BadgerStore) Reset

func (s *BadgerStore) Reset(frame *Frame) error

Reset resets the Store from a given Frame.

func (*BadgerStore) RoundEvents

func (s *BadgerStore) RoundEvents(r int) int

RoundEvents returns the number of Events in round r.

func (*BadgerStore) RoundWitnesses

func (s *BadgerStore) RoundWitnesses(r int) []string

RoundWitnesses returns a round's witnesses.

func (*BadgerStore) SetBlock

func (s *BadgerStore) SetBlock(block *Block) error

SetBlock creates or updates a Block in the Store.

func (*BadgerStore) SetEvent

func (s *BadgerStore) SetEvent(event *Event) error

SetEvent creates or updates an Event in the store

func (*BadgerStore) SetFrame

func (s *BadgerStore) SetFrame(frame *Frame) error

SetFrame creates or updates a Frame in the Store.

func (*BadgerStore) SetMaintenanceMode added in v0.5.11

func (s *BadgerStore) SetMaintenanceMode(val bool)

SetMaintenanceMode is a setter

func (*BadgerStore) SetPeerSet added in v0.4.1

func (s *BadgerStore) SetPeerSet(round int, peerSet *peers.PeerSet) error

SetPeerSet saves a peer-set effective at a given round.

func (*BadgerStore) SetRound

func (s *BadgerStore) SetRound(r int, round *RoundInfo) error

SetRound creates or updates a round in the store.

func (*BadgerStore) StorePath

func (s *BadgerStore) StorePath() string

StorePath returns the full path of the underlying Badger database directory.

type Block

type Block struct {
	Body       BlockBody
	Signatures map[string]string // [validator hex] => signature
	// contains filtered or unexported fields
}

Block represents a section of the Hashgraph that has reached consensus. It contains an ordered list of transactions and internal transactions. When a section of the hashgraph reaches consensus, a corresponding block is assembled and committed to the application. After processing the block, the application updates the block's state-hash and internal transaction receipts. The block is then signed and the signatures are gossipped and gathered as part of the normal gossip routines. A block with enough signatures is final; it is a self-contained proof that a section of the hashgraph and the associated transactions are a result of consensus among the prevailing peer- set.

func NewBlock

func NewBlock(blockIndex,
	roundReceived int,
	frameHash []byte,
	peerSlice []*peers.Peer,
	txs [][]byte,
	itxs []InternalTransaction,
	timestamp int64) *Block

NewBlock creates a new Block.

func NewBlockFromFrame

func NewBlockFromFrame(blockIndex int, frame *Frame) (*Block, error)

NewBlockFromFrame assembles a block from a Frame.

func (*Block) AppendTransactions

func (b *Block) AppendTransactions(txs [][]byte)

AppendTransactions adds a transaction to the block.

func (*Block) FrameHash

func (b *Block) FrameHash() []byte

FrameHash returns the block's frame hash.

func (*Block) GetSignature

func (b *Block) GetSignature(validator string) (res BlockSignature, err error)

GetSignature returns a block signature from a specific validator.

func (*Block) GetSignatures

func (b *Block) GetSignatures() []BlockSignature

GetSignatures returns the block's signatures.

func (*Block) Hash

func (b *Block) Hash() ([]byte, error)

Hash returns the SHA256 encoding of a marshalled block.

func (*Block) Hex

func (b *Block) Hex() string

Hex returns the hex string representations of the block's hash.

func (*Block) Index

func (b *Block) Index() int

Index returns the block's index.

func (*Block) InternalTransactionReceipts added in v0.5.0

func (b *Block) InternalTransactionReceipts() []InternalTransactionReceipt

InternalTransactionReceipts returns the block's internal transaction receipts.

func (*Block) InternalTransactions added in v0.5.0

func (b *Block) InternalTransactions() []InternalTransaction

InternalTransactions returns the block's internal transactions.

func (*Block) Marshal

func (b *Block) Marshal() ([]byte, error)

Marshal produces a JSON encoding of the Block.

func (*Block) PeersHash added in v0.4.1

func (b *Block) PeersHash() []byte

PeersHash returns the block's peers hash.

func (*Block) RoundReceived

func (b *Block) RoundReceived() int

RoundReceived returns the block's round-received.

func (*Block) SetSignature

func (b *Block) SetSignature(bs BlockSignature) error

SetSignature appends a signature to the block.

func (*Block) Sign

func (b *Block) Sign(privKey *ecdsa.PrivateKey) (bs BlockSignature, err error)

Sign returns the signature of the hash of the block's body.

func (*Block) StateHash

func (b *Block) StateHash() []byte

StateHash returns the block's state hash.

func (*Block) Timestamp added in v0.8.2

func (b *Block) Timestamp() int64

Timestamp returns the block's timestamp

func (*Block) Transactions

func (b *Block) Transactions() [][]byte

Transactions return's the block's transactoins.

func (*Block) Unmarshal

func (b *Block) Unmarshal(data []byte) error

Unmarshal parses a JSON encoded Block.

func (*Block) Verify

func (b *Block) Verify(sig BlockSignature) (bool, error)

Verify verifies that a signature is valid against the block.

type BlockBody

type BlockBody struct {
	Index                       int                          // block index
	RoundReceived               int                          // round received of corresponding hashgraph frame
	Timestamp                   int64                        // unix timestamp ((median of timestamps in round-received famous witnesses))
	StateHash                   []byte                       // root hash of the application after applying block payload; to be populated by application Commit
	FrameHash                   []byte                       // hash of corresponding hashgraph frame
	PeersHash                   []byte                       // hash of peer-set
	Transactions                [][]byte                     // transaction payload
	InternalTransactions        []InternalTransaction        // internal transaction payload (add/remove peers)
	InternalTransactionReceipts []InternalTransactionReceipt // receipts for internal transactions; to be populated by application Commit
}

BlockBody is the content of a Block.

func (*BlockBody) Hash

func (bb *BlockBody) Hash() ([]byte, error)

Hash produces the SHA256 hash of the marshalled BlockBody.

func (*BlockBody) Marshal

func (bb *BlockBody) Marshal() ([]byte, error)

Marshal produces the JSON encoding of a BlockBody.

func (*BlockBody) Unmarshal

func (bb *BlockBody) Unmarshal(data []byte) error

Unmarshal parses a JSON encoded BlockBody.

type BlockSignature

type BlockSignature struct {
	// Validator is the public key of the signer.
	Validator []byte
	// Block Index
	Index int
	// String encoding of the signature
	Signature string
}

BlockSignature gathers a signature encoded as a string, along with the index of the block, and the public-key of the signer.

func (*BlockSignature) Key added in v0.4.1

func (bs *BlockSignature) Key() string

Key produces a string identifier of the signature for storage in a key-value store.

func (*BlockSignature) Marshal

func (bs *BlockSignature) Marshal() ([]byte, error)

Marshal produces the JSON encoding of the BlockSignature.

func (*BlockSignature) ToWire

func (bs *BlockSignature) ToWire() WireBlockSignature

ToWire returns the wire representation of a BlockSignature.

func (*BlockSignature) Unmarshal

func (bs *BlockSignature) Unmarshal(data []byte) error

Unmarshal parses a BlockSignature from JSON.

func (*BlockSignature) ValidatorHex

func (bs *BlockSignature) ValidatorHex() string

ValidatorHex returns the hex string representation of the signer's public key.

type ByTopologicalOrder

type ByTopologicalOrder []*Event

ByTopologicalOrder implements sort.Interface for []Event based on the private topologicalIndex field.

func (ByTopologicalOrder) Len

func (a ByTopologicalOrder) Len() int

Len implements the sort.Interface

func (ByTopologicalOrder) Less

func (a ByTopologicalOrder) Less(i, j int) bool

Less implements the sort.Interface

func (ByTopologicalOrder) Swap

func (a ByTopologicalOrder) Swap(i, j int)

Swap implements the sort.Interface

type CoordinatesMap added in v0.4.1

type CoordinatesMap map[string]EventCoordinates

CoordinatesMap is used by the Hashgraph consensus methods to efficiently calculate the StronglySee predicate.

func NewCoordinatesMap added in v0.4.1

func NewCoordinatesMap() CoordinatesMap

NewCoordinatesMap creates an empty CoordinateMap

func (CoordinatesMap) Copy added in v0.4.1

func (c CoordinatesMap) Copy() CoordinatesMap

Copy creates a clone of a CoordinateMap

type Event

type Event struct {
	Body      EventBody
	Signature string //creator's digital signature of body
	// contains filtered or unexported fields
}

Event is the fundamental unit of a Hashgraph. It contains an EventBody and a a signature of the EventBody from the Event's creator (whose public key is set in the EventBody.Creator byte slice). It also contains some private fields which are useful for local computations and ordering.

func NewEvent

func NewEvent(transactions [][]byte,
	internalTransactions []InternalTransaction,
	blockSignatures []BlockSignature,
	parents []string,
	creator []byte,
	index int) *Event

NewEvent instantiates a new Event

func (*Event) BlockSignatures

func (e *Event) BlockSignatures() []BlockSignature

BlockSignatures returns the Event's BlockSignatures

func (*Event) Creator

func (e *Event) Creator() string

Creator returns the string representation of the creator's public key.

func (*Event) GetRound added in v0.4.1

func (e *Event) GetRound() *int

GetRound gets the Event's round number

func (*Event) Hash

func (e *Event) Hash() ([]byte, error)

Hash returns the SHA256 hash of the JSON-encoded body

func (*Event) Hex

func (e *Event) Hex() string

Hex returns a hex string representation of the Event's hash

func (*Event) Index

func (e *Event) Index() int

Index returns the Event's index

func (*Event) InternalTransactions added in v0.5.0

func (e *Event) InternalTransactions() []InternalTransaction

InternalTransactions returns the Event's InternalTransactions

func (*Event) IsLoaded

func (e *Event) IsLoaded() bool

IsLoaded returns true if the Event contains a payload or is its creator's first Event.

func (*Event) MarshalDB added in v0.5.10

func (e *Event) MarshalDB() ([]byte, error)

MarshalDB returns the JSON encoding of the Event along with some of the private fields which would not be exported by the default JSON marshalling method. These private fiels are necessary when converting to WireEvent and ordering in topological order. We use MarshalDB to save items to the database because otherwise the private fields would be lost after a write/read operation on the DB.

func (*Event) OtherParent

func (e *Event) OtherParent() string

OtherParent returns the Event's other-parent

func (*Event) SelfParent

func (e *Event) SelfParent() string

SelfParent returns the Event's self-parent

func (*Event) SetLamportTimestamp

func (e *Event) SetLamportTimestamp(t int)

SetLamportTimestamp sets the Event's Lamport Timestamp

func (*Event) SetRound

func (e *Event) SetRound(r int)

SetRound sets the Events round number

func (*Event) SetRoundReceived

func (e *Event) SetRoundReceived(rr int)

SetRoundReceived sets the Event's round-received (different from round)

func (*Event) SetWireInfo

func (e *Event) SetWireInfo(selfParentIndex int,
	otherParentCreatorID uint32,
	otherParentIndex int,
	creatorID uint32)

SetWireInfo sets the private fields in the Event's body which are used by the wire representation.

func (*Event) Sign

func (e *Event) Sign(privKey *ecdsa.PrivateKey) error

Sign signs the hash of the Event's body with an ecdsa sig

func (*Event) Timestamp added in v0.8.3

func (e *Event) Timestamp() int64

Timestamp returns the Event's Timestamp

func (*Event) ToWire

func (e *Event) ToWire() WireEvent

ToWire convert an Event to its WireEvent representation

func (*Event) Transactions

func (e *Event) Transactions() [][]byte

Transactions returns the Event's transactions

func (*Event) UnmarshalDB added in v0.5.10

func (e *Event) UnmarshalDB(data []byte) error

UnmarshalDB unmarshals a JSON encoded eventWrapper and converts it to an Event with some private fields set.

func (*Event) Verify

func (e *Event) Verify() (bool, error)

Verify verifies the Event's signature, and the signatures of the InternalTransactions in its payload.

func (*Event) WireBlockSignatures

func (e *Event) WireBlockSignatures() []WireBlockSignature

WireBlockSignatures returns the Event's BlockSignatures (from its payload) in Wire format.

type EventBody

type EventBody struct {
	Transactions         [][]byte              // application transactions
	InternalTransactions []InternalTransaction // internal transactions ( add / remove peers )
	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 Creator ONLY
	Timestamp            int64                 // Unix timestamp when Event was created (seconds since January 1st, 1970)
	// contains filtered or unexported fields
}

EventBody contains the payload of an Event as well as the information that ties it to other Events. The private fields are for local computations only.

func (*EventBody) Hash

func (e *EventBody) Hash() ([]byte, error)

Hash returns the SHA256 hash of the JSON encoded EventBody.

func (*EventBody) Marshal

func (e *EventBody) Marshal() ([]byte, error)

Marshal returns the JSON encoding of an EventBody

func (*EventBody) Unmarshal

func (e *EventBody) Unmarshal(data []byte) error

Unmarshal converts a JSON encoded EventBody to an EventBody

type EventCoordinates

type EventCoordinates struct {
	Hash  string
	Index int
}

EventCoordinates combines the index and hash of an Event

type Frame

type Frame struct {
	Round     int                   // RoundReceived
	Peers     []*peers.Peer         // the authoritative peer-set at Round
	Roots     map[string]*Root      // Roots on top of which Frame Events can be inserted
	Events    []*FrameEvent         // Events with RoundReceived = Round
	PeerSets  map[int][]*peers.Peer // full peer-set history ([round] => Peers)
	Timestamp int64                 // unix timestamp (median of round-received famous witnesses)
}

Frame represents a section of the hashgraph.

func (*Frame) Hash

func (f *Frame) Hash() ([]byte, error)

Hash returns the SHA256 hash of the marshalled Frame.

func (*Frame) Marshal

func (f *Frame) Marshal() ([]byte, error)

Marshal returns the JSON encoding of Frame.

func (*Frame) SortedFrameEvents added in v0.5.0

func (f *Frame) SortedFrameEvents() []*FrameEvent

SortedFrameEvents returns all the events in the Frame, including event is roots, sorted by LAMPORT timestamp

func (*Frame) Unmarshal

func (f *Frame) Unmarshal(data []byte) error

Unmarshal parses a JSON encoded Frame.

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

func (h *Hashgraph) Bootstrap() error

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. During the bootstrap process, the badger store is put in maintenance-mode to avoid reinserting items in the database.

func (*Hashgraph) CheckBlock

func (h *Hashgraph) CheckBlock(block *Block, peerSet *peers.PeerSet) error

CheckBlock returns an error if the Block does not contain valid signatures from MORE than 1/3 of participants

func (*Hashgraph) DecideFame

func (h *Hashgraph) DecideFame() error

DecideFame decides if witnesses are famous

func (*Hashgraph) DecideRoundReceived

func (h *Hashgraph) DecideRoundReceived() error

DecideRoundReceived assigns a RoundReceived to undetermined events when they reach consensus

func (*Hashgraph) DivideRounds

func (h *Hashgraph) DivideRounds() error

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

func (h *Hashgraph) GetAnchorBlockWithFrame() (*Block, *Frame, error)

GetAnchorBlockWithFrame returns the AnchorBlock and the corresponding Frame. This can be used as a base to Reset a Hashgraph

func (*Hashgraph) GetFrame

func (h *Hashgraph) GetFrame(roundReceived int) (*Frame, error)

GetFrame computes the Frame corresponding to a RoundReceived.

func (*Hashgraph) Init added in v0.4.1

func (h *Hashgraph) Init(peerSet *peers.PeerSet) error

Init sets the initial PeerSet, which also creates the corresponding Roots and updates the Repertoire.

func (*Hashgraph) InsertEvent

func (h *Hashgraph) InsertEvent(event *Event, setWireInfo bool) error

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

func (h *Hashgraph) InsertEventAndRunConsensus(event *Event, setWireInfo bool) error

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

func (h *Hashgraph) ProcessDecidedRounds() error

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

func (h *Hashgraph) ProcessSigPool() error

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

func (h *Hashgraph) ReadWireInfo(wevent WireEvent) (*Event, error)

ReadWireInfo converts a WireEvent to an Event by replacing int IDs with the corresponding public keys.

func (*Hashgraph) Reset

func (h *Hashgraph) Reset(block *Block, frame *Frame) error

Reset clears the Hashgraph and resets it from a new base.

func (*Hashgraph) SetAnchorBlock added in v0.4.1

func (h *Hashgraph) SetAnchorBlock(block *Block) error

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.

func (*Hashgraph) SetWireInfo added in v0.5.10

func (h *Hashgraph) SetWireInfo(event *Event) error

type InmemStore

type InmemStore struct {
	// contains filtered or unexported fields
}

InmemStore implements the Store interface with inmemory caches. When the caches are full, older items are evicted, so InmemStore is not suitable for long running deployments where joining nodes expect to sync from the beginning of a hashgraph.

func NewInmemStore

func NewInmemStore(cacheSize int) *InmemStore

NewInmemStore creates a new InmemStore where all caches are limited by cacheSize items.

func (*InmemStore) AddConsensusEvent

func (s *InmemStore) AddConsensusEvent(event *Event) error

AddConsensusEvent implements the Store interface.

func (*InmemStore) CacheSize

func (s *InmemStore) CacheSize() int

CacheSize returns the size limit that was provided to all the caches that make up the InmemStore. This does not correspond to the total number of items in the store or the total number of items allowed in the store.

func (*InmemStore) Close

func (s *InmemStore) Close() error

Close implements the Store interface.

func (*InmemStore) ConsensusEvents

func (s *InmemStore) ConsensusEvents() []string

ConsensusEvents implements the Store interface.

func (*InmemStore) ConsensusEventsCount

func (s *InmemStore) ConsensusEventsCount() int

ConsensusEventsCount implements the Store interface.

func (*InmemStore) FirstRound added in v0.5.0

func (s *InmemStore) FirstRound(id uint32) (int, bool)

FirstRound implements the Store interface.

func (*InmemStore) GetAllPeerSets added in v0.5.0

func (s *InmemStore) GetAllPeerSets() (map[int][]*peers.Peer, error)

GetAllPeerSets implements the Store interface.

func (*InmemStore) GetBlock

func (s *InmemStore) GetBlock(index int) (*Block, error)

GetBlock implements the Store interface.

func (*InmemStore) GetEvent

func (s *InmemStore) GetEvent(key string) (*Event, error)

GetEvent implements the Store interface.

func (*InmemStore) GetFrame

func (s *InmemStore) GetFrame(index int) (*Frame, error)

GetFrame implements the Store interface.

func (*InmemStore) GetPeerSet added in v0.4.1

func (s *InmemStore) GetPeerSet(round int) (*peers.PeerSet, error)

GetPeerSet implements the Store interface.

func (*InmemStore) GetRoot

func (s *InmemStore) GetRoot(participant string) (*Root, error)

GetRoot implements the Store interface.

func (*InmemStore) GetRound

func (s *InmemStore) GetRound(r int) (*RoundInfo, error)

GetRound implements the Store interface.

func (*InmemStore) KnownEvents

func (s *InmemStore) KnownEvents() map[uint32]int

KnownEvents implements the Store interface.

func (*InmemStore) LastBlockIndex

func (s *InmemStore) LastBlockIndex() int

LastBlockIndex implements the Store interface.

func (*InmemStore) LastConsensusEventFrom

func (s *InmemStore) LastConsensusEventFrom(participant string) (last string, err error)

LastConsensusEventFrom implements the Store interface.

func (*InmemStore) LastEventFrom

func (s *InmemStore) LastEventFrom(participant string) (last string, err error)

LastEventFrom implements the Store interface.

func (*InmemStore) LastRound

func (s *InmemStore) LastRound() int

LastRound implements the Store interface.

func (*InmemStore) ParticipantEvent

func (s *InmemStore) ParticipantEvent(participant string, index int) (string, error)

ParticipantEvent implements the Store interface.

func (*InmemStore) ParticipantEvents

func (s *InmemStore) ParticipantEvents(participant string, skip int) ([]string, error)

ParticipantEvents implements the Store interface.

func (*InmemStore) RepertoireByID added in v0.4.1

func (s *InmemStore) RepertoireByID() map[uint32]*peers.Peer

RepertoireByID implements the Store interface.

func (*InmemStore) RepertoireByPubKey added in v0.4.1

func (s *InmemStore) RepertoireByPubKey() map[string]*peers.Peer

RepertoireByPubKey implements the Store interface.

func (*InmemStore) Reset

func (s *InmemStore) Reset(frame *Frame) error

Reset implements the Store interface.

func (*InmemStore) RoundEvents

func (s *InmemStore) RoundEvents(r int) int

RoundEvents implements the Store interface.

func (*InmemStore) RoundWitnesses

func (s *InmemStore) RoundWitnesses(r int) []string

RoundWitnesses implements the Store interface.

func (*InmemStore) SetBlock

func (s *InmemStore) SetBlock(block *Block) error

SetBlock implements the Store interface.

func (*InmemStore) SetEvent

func (s *InmemStore) SetEvent(event *Event) error

SetEvent implements the Store interface.

func (*InmemStore) SetFrame

func (s *InmemStore) SetFrame(frame *Frame) error

SetFrame implements the Store interface.

func (*InmemStore) SetPeerSet added in v0.4.1

func (s *InmemStore) SetPeerSet(round int, peerSet *peers.PeerSet) error

SetPeerSet implements the Store interface.

func (*InmemStore) SetRound

func (s *InmemStore) SetRound(r int, round *RoundInfo) error

SetRound implements the Store interface.

func (*InmemStore) StorePath

func (s *InmemStore) StorePath() string

StorePath implements the Store interface.

type InternalCommitCallback added in v0.4.1

type InternalCommitCallback func(*Block) error

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
}

InternalTransaction represents a special type of transaction that is actually interpreted by Babble to act on its own internal state, whereas regular transactions are app-specific and are never interpreted by Babble. In particular, InternalTransactions are used to add or remove validators. InternalTransactions also go through consensus.

func NewInternalTransaction added in v0.5.0

func NewInternalTransaction(tType TransactionType, peer peers.Peer) InternalTransaction

NewInternalTransaction creates a new InternalTransaction.

func NewInternalTransactionJoin added in v0.5.0

func NewInternalTransactionJoin(peer peers.Peer) InternalTransaction

NewInternalTransactionJoin creates a new InternalTransaction to add a peer.

func NewInternalTransactionLeave added in v0.5.0

func NewInternalTransactionLeave(peer peers.Peer) InternalTransaction

NewInternalTransactionLeave creates a new InternalTransaction to remove a peer.

func (*InternalTransaction) AsAccepted added in v0.5.0

AsAccepted returns a receipt to accept an InternalTransaction.

func (*InternalTransaction) AsRefused added in v0.5.0

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 go through consensus.

func (*InternalTransaction) Marshal added in v0.5.0

func (t *InternalTransaction) Marshal() ([]byte, error)

Marshal returns the JSON encoding of an InternalTransaction.

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

Unmarshal parses an InternalTransaction from JSON.

func (*InternalTransaction) Verify added in v0.5.0

func (t *InternalTransaction) Verify() (bool, error)

Verify verifies the transaction's signature.

type InternalTransactionBody added in v0.5.0

type InternalTransactionBody struct {
	Type TransactionType // Add or Remove
	Peer peers.Peer      // Targeted Peer
}

InternalTransactionBody contains the payload of an InternalTransaction.

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)

Marshal returns the JSON encoding of an InternalTransaction.

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 an InternalTransaction.

type OrderedPendingRounds added in v0.4.1

type OrderedPendingRounds []*PendingRound

OrderedPendingRounds is an ordered list of PendingRounds.

func (OrderedPendingRounds) Len added in v0.4.1

func (a OrderedPendingRounds) Len() int

Len returns the length

func (OrderedPendingRounds) Less added in v0.4.1

func (a OrderedPendingRounds) Less(i, j int) bool

Less returns true if element i is less than element j.

func (OrderedPendingRounds) Swap added in v0.4.1

func (a OrderedPendingRounds) Swap(i, j int)

Swap swaps 2 elements

type ParticipantEventsCache

type ParticipantEventsCache struct {
	// contains filtered or unexported fields
}

ParticipantEventsCache is a cache associated with a peer-set that keeps a a RollingIndex of events for every peer.

func NewParticipantEventsCache

func NewParticipantEventsCache(size int) *ParticipantEventsCache

NewParticipantEventsCache instantiates a new ParticipantEventsCache. The size parameter controls the size of each RollingIndex within the cache.

func (*ParticipantEventsCache) AddPeer added in v0.4.1

func (pec *ParticipantEventsCache) AddPeer(peer *peers.Peer) error

AddPeer adds a peer to the cache.

func (*ParticipantEventsCache) Get

func (pec *ParticipantEventsCache) Get(participant string, skipIndex int) ([]string, error)

Get returns a participant's events with index > skip

func (*ParticipantEventsCache) GetItem

func (pec *ParticipantEventsCache) GetItem(participant string, index int) (string, error)

GetItem returns a specific event for a specific peer.

func (*ParticipantEventsCache) GetLast

func (pec *ParticipantEventsCache) GetLast(participant string) (string, error)

GetLast returns the index of a participant's last event.

func (*ParticipantEventsCache) Known

func (pec *ParticipantEventsCache) Known() map[uint32]int

Known returns [participant id] => lastKnownIndex

func (*ParticipantEventsCache) Set

func (pec *ParticipantEventsCache) Set(participant string, hash string, index int) error

Set attemps to set an event to a participant's events.

type PeerSetCache added in v0.4.1

type PeerSetCache struct {
	// contains filtered or unexported fields
}

PeerSetCache is a cache that keeps track of peer-sets.

func NewPeerSetCache added in v0.4.1

func NewPeerSetCache() *PeerSetCache

NewPeerSetCache creates a new PeerSetCache.

func (*PeerSetCache) FirstRound added in v0.5.0

func (c *PeerSetCache) FirstRound(id uint32) (int, bool)

FirstRound returns the index of the first round where a peer appeared.

func (*PeerSetCache) Get added in v0.4.1

func (c *PeerSetCache) Get(round int) (*peers.PeerSet, error)

Get returns the peer-set corresponding to a given round.

func (*PeerSetCache) GetAll added in v0.5.0

func (c *PeerSetCache) GetAll() (map[int][]*peers.Peer, error)

GetAll returns all peer-sets in a map of round to peer-set.

func (*PeerSetCache) RepertoireByID added in v0.5.0

func (c *PeerSetCache) RepertoireByID() map[uint32]*peers.Peer

RepertoireByID returns all the known peers indexed by ID. This includes peers that are no longer in the active peer-set.

func (*PeerSetCache) RepertoireByPubKey added in v0.5.0

func (c *PeerSetCache) RepertoireByPubKey() map[string]*peers.Peer

RepertoireByPubKey returns all the known peers indexed by public key.

func (*PeerSetCache) Set added in v0.4.1

func (c *PeerSetCache) Set(round int, peerSet *peers.PeerSet) error

Set adds a peer-set at a given round and updates internal information.

type PendingRound added in v0.4.1

type PendingRound struct {
	Index   int
	Decided bool
}

PendingRound represents a round as it goes through consensus.

type PendingRoundsCache added in v0.4.1

type PendingRoundsCache struct {
	// contains filtered or unexported fields
}

PendingRoundsCache is a cache for PendingRounds.

func NewPendingRoundsCache added in v0.4.1

func NewPendingRoundsCache() *PendingRoundsCache

NewPendingRoundsCache creates a new PendingRoundsCache.

func (*PendingRoundsCache) Clean added in v0.4.1

func (c *PendingRoundsCache) Clean(processedRounds []int)

Clean removes a list of rounds from the cache and preserves the sorted order.

func (*PendingRoundsCache) GetOrderedPendingRounds added in v0.4.1

func (c *PendingRoundsCache) GetOrderedPendingRounds() OrderedPendingRounds

GetOrderedPendingRounds returns the ordered list of PendingRounds.

func (*PendingRoundsCache) Queued added in v0.4.1

func (c *PendingRoundsCache) Queued(round int) bool

Queued indicates whether a round is already part of the PendingRoundsCache.

func (*PendingRoundsCache) Set added in v0.4.1

func (c *PendingRoundsCache) Set(pendingRound *PendingRound)

Set adds an item to the PendingRoundCache and preserves the order.

func (*PendingRoundsCache) Update added in v0.4.1

func (c *PendingRoundsCache) Update(decidedRounds []int)

Update takes a list of indexes of rounds that have been decided and updates the PendingRoundsCache accordingly.

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 NewRoot added in v0.4.1

func NewRoot() *Root

NewRoot instantiantes an new empty root.

func (*Root) Hash added in v0.5.0

func (r *Root) Hash() (string, error)

Hash returns the SHA256 hash or the marshalled Root.

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.

func (*Root) Marshal

func (r *Root) Marshal() ([]byte, error)

Marshal returns the JSON encoding of a Root.

func (*Root) Unmarshal

func (r *Root) Unmarshal(data []byte) error

Unmarshal parses a JSON encoded Root.

type RoundInfo

type RoundInfo struct {
	// CreatedEvents collects the events that were "created" in this round.
	CreatedEvents map[string]roundEvent
	// ReceivedEvents collects the events that were "received" in this round.
	ReceivedEvents []string
	// contains filtered or unexported fields
}

RoundInfo encapsulates information about a round.

func NewRoundInfo

func NewRoundInfo() *RoundInfo

NewRoundInfo creates a new RoundInfo.

func (*RoundInfo) AddCreatedEvent added in v0.4.1

func (r *RoundInfo) AddCreatedEvent(x string, witness bool)

AddCreatedEvent adds an event to the CreatedEvents map.

func (*RoundInfo) AddReceivedEvent added in v0.4.1

func (r *RoundInfo) AddReceivedEvent(x string)

AddReceivedEvent adds an event to the ReceivedEvents list.

func (*RoundInfo) FamousWitnesses

func (r *RoundInfo) FamousWitnesses() []string

FamousWitnesses returns famous witnesses.

func (*RoundInfo) IsDecided

func (r *RoundInfo) IsDecided(witness string) bool

IsDecided returns true unless the famous status is undecided.

func (*RoundInfo) IsQueued added in v0.4.1

func (r *RoundInfo) IsQueued() bool

IsQueued returns true if the RoundInfo is marked as queued.

func (*RoundInfo) Marshal

func (r *RoundInfo) Marshal() ([]byte, error)

Marshal returns the JSON encoding of a RoundInfo.

func (*RoundInfo) SetFame

func (r *RoundInfo) SetFame(x string, f bool)

SetFame sets the famous status of an event.

func (*RoundInfo) Unmarshal

func (r *RoundInfo) Unmarshal(data []byte) error

Unmarshal marshalls a JSON encoded RoundInfo.

func (*RoundInfo) Witnesses

func (r *RoundInfo) Witnesses() []string

Witnesses return witnesses.

func (*RoundInfo) WitnessesDecided

func (r *RoundInfo) WitnessesDecided(peerSet *peers.PeerSet) bool

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 SelfParentError added in v0.5.5

type SelfParentError struct {
	// contains filtered or unexported fields
}

SelfParentError is used to differentiate errors that are normal when the hashgraph is being used corrently by multiple go-routines, from errors that should not be occuring event in a concurrent context.

func NewSelfParentError added in v0.5.5

func NewSelfParentError(msg string, normal bool) SelfParentError

NewSelfParentError creates a new SelfParentError

func (SelfParentError) Error added in v0.5.5

func (e SelfParentError) Error() string

Error implements the Error interface

type SigPool added in v0.4.1

type SigPool struct {
	// contains filtered or unexported fields
}

SigPool holds a collection of BlockSignatures.

func NewSigPool added in v0.4.1

func NewSigPool() *SigPool

NewSigPool creates a new SigPool.

func (*SigPool) Add added in v0.4.1

func (sp *SigPool) Add(blockSignature BlockSignature)

Add adds an item to SigPool.

func (*SigPool) Items added in v0.4.1

func (sp *SigPool) Items() map[string]BlockSignature

Items returns the contents of the SigPool as a map.

func (*SigPool) Len added in v0.4.1

func (sp *SigPool) Len() int

Len returns the number of items in the SigPool.

func (*SigPool) Remove added in v0.4.1

func (sp *SigPool) Remove(key string)

Remove removes an item from SigPool.

func (*SigPool) RemoveSlice added in v0.4.1

func (sp *SigPool) RemoveSlice(sigs []BlockSignature)

RemoveSlice removes multiple items from SigPool.

func (*SigPool) Slice added in v0.4.1

func (sp *SigPool) Slice() []BlockSignature

Slice returns the contents of the SigPool as a slice in no particular order.

type SortedFrameEvents added in v0.5.0

type SortedFrameEvents []*FrameEvent

SortedFrameEvents implements sort.Interface for []FrameEvent based on the lamportTimestamp field.

func (SortedFrameEvents) Len added in v0.5.0

func (a SortedFrameEvents) Len() int

Len implements the sort.Interface

func (SortedFrameEvents) Less added in v0.5.0

func (a SortedFrameEvents) Less(i, j int) bool

Less implements the sort.Interface

func (SortedFrameEvents) Swap added in v0.5.0

func (a SortedFrameEvents) Swap(i, j int)

Swap implements the sort.Interface

type Store

type Store interface {
	// CacheSize retrieves the cacheSize setting that determines the maximum
	// number of items that caches can contain.
	CacheSize() int
	// GetPeerSet returns the peer-set effective at a given round.
	GetPeerSet(round int) (*peers.PeerSet, error)
	// SetPeerSet sets the peer-set effective at a given round.
	SetPeerSet(round int, peers *peers.PeerSet) error
	// GetAllPeerSets returns the entire history of peer-sets.
	GetAllPeerSets() (map[int][]*peers.Peer, error)
	// FirstRound returns the index of the first round to which a participant
	// belonged.
	FirstRound(participantID uint32) (int, bool)
	// RepertoireByPubKey returns all the known peers by public key.
	RepertoireByPubKey() map[string]*peers.Peer
	// RepertoireByID returns all the known peers by ID.
	RepertoireByID() map[uint32]*peers.Peer
	// GetEvent returns an evnet by hash.
	GetEvent(hash string) (*Event, error)
	// SetEvent inserts an envent in the store.
	SetEvent(event *Event) error
	// ParticipantEvents returns all the sorted event hashes of a participant
	// starting at index skip+1.
	ParticipantEvents(participant string, skip int) ([]string, error)
	// ParticipantEvent returns a participant's event with a given index.
	ParticipantEvent(participant string, index int) (string, error)
	// LastEventFrom returns the last event of a participant.
	LastEventFrom(participant string) (string, error)
	// LastConsensusEventFrom returns the last consensus event produced by a
	// participant.
	LastConsensusEventFrom(string) (string, error)
	// KnownEvents returns the map of participant ID to last known index.
	KnownEvents() map[uint32]int
	// ConsensusEvents returns the hashes of consensus events.
	ConsensusEvents() []string
	// ConsensusEventsCount returns the number of consensus events.
	ConsensusEventsCount() int
	// AddConsensusEvent adds a consensus event.
	AddConsensusEvent(*Event) error
	// GetRound retrieves a round by index.
	GetRound(roundIndex int) (*RoundInfo, error)
	// SetRound stores a round.
	SetRound(roundIndex int, roundInfo *RoundInfo) error
	// LastRound returns the index of the last created round.
	LastRound() int
	// RoundWitnesses returns the hashes of a round's witnesses.
	RoundWitnesses(roundIndex int) []string
	// RoundEvents returns the number of events in a round.
	RoundEvents(roundIndex int) int
	// GetRoot returns a participant's root.
	GetRoot(participant string) (*Root, error)
	// GetBlock returns a block by index.
	GetBlock(int) (*Block, error)
	// SetBlock store a block.
	SetBlock(*Block) error
	// LastBlockIndex returns the last block index.
	LastBlockIndex() int
	// GetFrame retrieves the frame associated to a round received.
	GetFrame(roundReceived int) (*Frame, error)
	// SetFrame stores a frame.
	SetFrame(*Frame) error
	// Reset resets a store from a frame.
	Reset(*Frame) error
	// Close closes the underlying database.
	Close() error
	// StorePath returns the filepath of the underlying database.
	StorePath() string
}

Store is an interface for backend stores.

type TransactionType added in v0.5.0

type TransactionType uint8

TransactionType denotes the nature of an InternalTransaction

const (
	// PEER_ADD is used to add a peer.
	PEER_ADD TransactionType = iota
	// PEER_REMOVE is used to remove a peer.
	PEER_REMOVE
)

func (TransactionType) String added in v0.5.0

func (t TransactionType) String() string

String returns the string representation of a TransactionType.

type WireBlockSignature

type WireBlockSignature struct {
	Index     int
	Signature string
}

WireBlockSignature is a light-weight representation of a signature to travel over the wire.

type WireBody

type WireBody struct {
	Transactions         [][]byte
	InternalTransactions []InternalTransaction
	BlockSignatures      []WireBlockSignature
	CreatorID            uint32
	OtherParentCreatorID uint32
	Index                int
	SelfParentIndex      int
	OtherParentIndex     int
	Timestamp            int64
}

WireBody is a light-weight representation of an EventBody where hashes are replaced by ints.

type WireEvent

type WireEvent struct {
	Body      WireBody
	Signature string
}

WireEvent is a light-weight representation of an Event that is used to send Events over the wire because they take less space.

func (*WireEvent) BlockSignatures

func (we *WireEvent) BlockSignatures(validator []byte) []BlockSignature

BlockSignatures unpacks BlockSignatures from a WireEvent.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL