poset

package
v0.0.0-...-168a2c3 Latest Latest
Warning

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

Go to latest
Published: May 30, 2019 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const LamportTimestampNIL int64 = -1

LamportTimestampNIL nil value for lamport

View Source
const RoundNIL int64 = -1

RoundNIL nil value for round

Variables

View Source
var Trilean_name = map[int32]string{
	0: "UNDEFINED",
	1: "TRUE",
	2: "FALSE",
}
View Source
var Trilean_value = map[string]int32{
	"UNDEFINED": 0,
	"TRUE":      1,
	"FALSE":     2,
}

Functions

func BlockSignatureListEquals

func BlockSignatureListEquals(this []*BlockSignature, that []*BlockSignature) bool

BlockSignatureListEquals block signature list equality check

func EqualsMapStringRootEvent

func EqualsMapStringRootEvent(this map[string]*RootEvent, that map[string]*RootEvent) bool

EqualsMapStringRootEvent compares the equality of two string maps of root events

func EqualsMapStringRoundEvent

func EqualsMapStringRoundEvent(this map[string]*RoundEvent, that map[string]*RoundEvent) bool

EqualsMapStringRoundEvent compares a map string of round events for equality

func EventListEquals

func EventListEquals(this []*EventMessage, that []*EventMessage) bool

EventListEquals compares the equality of two event lists

func InternalTransactionListEquals

func InternalTransactionListEquals(this []*wire.InternalTransaction, that []*wire.InternalTransaction) bool

InternalTransactionListEquals list equality check

func ListBytesEquals

func ListBytesEquals(this [][]byte, that [][]byte) bool

ListBytesEquals compares the equality of two lists

func MapStringsEquals

func MapStringsEquals(this map[string]string, that map[string]string) bool

MapStringsEquals compares the equality of two string maps

func RootListEquals

func RootListEquals(this []*Root, that []*Root) bool

RootListEquals compares the equality of two root lists

Types

type BadgerStore

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

BadgerStore struct for badger config data

func LoadBadgerStore

func LoadBadgerStore(cacheSize int, path string) (*BadgerStore, error)

LoadBadgerStore creates a Store from an existing database

func LoadOrCreateBadgerStore

func LoadOrCreateBadgerStore(participants *peers.Peers, cacheSize int, path string, posConf *pos.Config) (*BadgerStore, error)

LoadOrCreateBadgerStore load or create a new badger store

func NewBadgerStore

func NewBadgerStore(participants *peers.Peers, cacheSize int, path string, posConf *pos.Config) (*BadgerStore, error)

NewBadgerStore creates a brand new Store with a new database

func (*BadgerStore) AddConsensusEvent

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

AddConsensusEvent adds a consensus event to the store

func (*BadgerStore) CacheSize

func (s *BadgerStore) CacheSize() int

CacheSize returns the cache size for the store

func (*BadgerStore) Close

func (s *BadgerStore) Close() error

Close badger

func (*BadgerStore) ConsensusEvents

func (s *BadgerStore) ConsensusEvents() EventHashes

ConsensusEvents returns all consensus events

func (*BadgerStore) ConsensusEventsCount

func (s *BadgerStore) ConsensusEventsCount() int64

ConsensusEventsCount returns the count for all known consensus events

func (*BadgerStore) GetBlock

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

GetBlock returns the block for a given index

func (*BadgerStore) GetEventBlock

func (s *BadgerStore) GetEventBlock(hash EventHash) (event Event, err error)

GetEventBlock get specific event block by hash

func (*BadgerStore) GetFrame

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

GetFrame returns a specific frame for the index

func (*BadgerStore) GetRoot

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

GetRoot returns the root for a participant

func (*BadgerStore) GetRoundCreated

func (s *BadgerStore) GetRoundCreated(r int64) (RoundCreated, error)

GetRoundCreated gets the created round info for a given index

func (*BadgerStore) GetRoundReceived

func (s *BadgerStore) GetRoundReceived(r int64) (RoundReceived, error)

GetRoundReceived gets the received round for a given index

func (*BadgerStore) LastBlockIndex

func (s *BadgerStore) LastBlockIndex() int64

LastBlockIndex returns the last block index (height)

func (*BadgerStore) LastConsensusEventFrom

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

LastConsensusEventFrom returns the last consensus events for a participant

func (*BadgerStore) LastEventFrom

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

LastEventFrom returns the last event for a participant

func (*BadgerStore) LastRound

func (s *BadgerStore) LastRound() int64

LastRound returns the last round for the store

func (*BadgerStore) NeedBootstrap

func (s *BadgerStore) NeedBootstrap() bool

NeedBootstrap checks if bootstrapping is required

func (*BadgerStore) ParticipantEvent

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

ParticipantEvent get specific participant event

func (*BadgerStore) ParticipantEvents

func (s *BadgerStore) ParticipantEvents(participant string, skip int64) (EventHashes, error)

ParticipantEvents return all participant events

func (*BadgerStore) Participants

func (s *BadgerStore) Participants() (*peers.Peers, error)

Participants returns all participants in the store

func (*BadgerStore) Reset

func (s *BadgerStore) Reset(roots map[string]Root) error

Reset all roots

func (*BadgerStore) RootsByParticipant

func (s *BadgerStore) RootsByParticipant() map[string]Root

RootsByParticipant returns PubKeyHex map of the roots

func (*BadgerStore) RootsBySelfParent

func (s *BadgerStore) RootsBySelfParent() map[EventHash]Root

RootsBySelfParent returns Self Parent's EventHash map of the roots

func (*BadgerStore) RoundClothos

func (s *BadgerStore) RoundClothos(r int64) EventHashes

RoundClothos returns all clothos for a round

func (*BadgerStore) RoundEvents

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

RoundEvents returns all events for a round

func (*BadgerStore) SetBlock

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

SetBlock add a block

func (*BadgerStore) SetEvent

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

SetEvent set a specific event

func (*BadgerStore) SetFrame

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

SetFrame add a frame

func (*BadgerStore) SetRoundCreated

func (s *BadgerStore) SetRoundCreated(r int64, round RoundCreated) error

SetRoundCreated sets the created round info for a given index

func (*BadgerStore) SetRoundReceived

func (s *BadgerStore) SetRoundReceived(r int64, round RoundReceived) error

SetRoundReceived sets the received round info for a given index

func (*BadgerStore) StateDB

func (s *BadgerStore) StateDB() state.Database

StateDB returns state database

func (*BadgerStore) StateRoot

func (s *BadgerStore) StateRoot() hash.Hash

StateRoot returns genesis state hash.

func (*BadgerStore) StorePath

func (s *BadgerStore) StorePath() string

StorePath returns the path to the file on disk

func (*BadgerStore) TopologicalEvents

func (s *BadgerStore) TopologicalEvents() ([]Event, error)

TopologicalEvents returns event in topological order.

type Block

type Block struct {
	Body                 *BlockBody        `protobuf:"bytes,1,opt,name=Body,proto3" json:"Body,omitempty"`
	Signatures           map[string]string `` /* 161-byte string literal not displayed */
	Hash                 []byte            `protobuf:"bytes,3,opt,name=hash,proto3" json:"hash,omitempty"`
	Hex                  string            `protobuf:"bytes,4,opt,name=hex,proto3" json:"hex,omitempty"`
	StateHash            []byte            `protobuf:"bytes,5,opt,name=StateHash,proto3" json:"StateHash,omitempty"`
	FrameHash            []byte            `protobuf:"bytes,6,opt,name=FrameHash,proto3" json:"FrameHash,omitempty"`
	CreatedTime          int64             `protobuf:"varint,7,opt,name=CreatedTime,proto3" json:"CreatedTime,omitempty"`
	XXX_NoUnkeyedLiteral struct{}          `json:"-"`
	XXX_unrecognized     []byte            `json:"-"`
	XXX_sizecache        int32             `json:"-"`
}

func NewBlock

func NewBlock(blockIndex, roundReceived int64, frameHash []byte, txs [][]byte) Block

NewBlock creates a new empty block with current time

func NewBlockFromFrame

func NewBlockFromFrame(blockIndex int64, frame Frame) (Block, error)

NewBlockFromFrame creates a new block from the given frame

func (*Block) AppendTransactions

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

AppendTransactions appends the transactions to the block body

func (*Block) BlockHash

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

BlockHash returns the Hash of the block (used for API)

func (*Block) BlockHex

func (b *Block) BlockHex() string

BlockHex returns the Hex of the block (used for API)

func (*Block) Descriptor

func (*Block) Descriptor() ([]byte, []int)

func (*Block) Equals

func (b *Block) Equals(that *Block) bool

Equals compares the equality of two blocks

func (*Block) GetBlockSignatures

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

GetBlockSignatures returns the block signatures for the block

func (*Block) GetBody

func (m *Block) GetBody() *BlockBody

func (*Block) GetCreatedTime

func (m *Block) GetCreatedTime() int64

func (*Block) GetFrameHash

func (m *Block) GetFrameHash() []byte

func (*Block) GetHash

func (m *Block) GetHash() []byte

func (*Block) GetHex

func (m *Block) GetHex() string

func (*Block) GetSignature

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

GetSignature returns all validator signatures for the block

func (*Block) GetSignatures

func (m *Block) GetSignatures() map[string]string

func (*Block) GetStateHash

func (m *Block) GetStateHash() []byte

func (*Block) Index

func (b *Block) Index() int64

Index returns the index (height) of the block

func (*Block) ProtoMarshal

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

ProtoMarshal marshals the block into protobuff

func (*Block) ProtoMessage

func (*Block) ProtoMessage()

func (*Block) ProtoUnmarshal

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

ProtoUnmarshal marshals protobuf into a block

func (*Block) Reset

func (m *Block) Reset()

func (*Block) RoundReceived

func (b *Block) RoundReceived() int64

RoundReceived returns the round in which the block was received

func (*Block) SetSignature

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

SetSignature sets the known blocksignatures for the block

func (*Block) Sign

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

Sign the block for this node

func (*Block) String

func (m *Block) String() string

func (*Block) Transactions

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

Transactions returns the transactions in a block

func (*Block) Verify

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

Verify verifies a blocksignature is from the node that signed

func (*Block) XXX_DiscardUnknown

func (m *Block) XXX_DiscardUnknown()

func (*Block) XXX_Marshal

func (m *Block) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Block) XXX_Merge

func (m *Block) XXX_Merge(src proto.Message)

func (*Block) XXX_Size

func (m *Block) XXX_Size() int

func (*Block) XXX_Unmarshal

func (m *Block) XXX_Unmarshal(b []byte) error

type BlockBody

type BlockBody struct {
	Index                int64    `protobuf:"varint,1,opt,name=Index,proto3" json:"Index,omitempty"`
	RoundReceived        int64    `protobuf:"varint,2,opt,name=RoundReceived,proto3" json:"RoundReceived,omitempty"`
	Transactions         [][]byte `protobuf:"bytes,5,rep,name=Transactions,proto3" json:"Transactions,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*BlockBody) Descriptor

func (*BlockBody) Descriptor() ([]byte, []int)

func (*BlockBody) Equals

func (bb *BlockBody) Equals(that *BlockBody) bool

Equals compares the equality of a block body

func (*BlockBody) GetIndex

func (m *BlockBody) GetIndex() int64

func (*BlockBody) GetRoundReceived

func (m *BlockBody) GetRoundReceived() int64

func (*BlockBody) GetTransactions

func (m *BlockBody) GetTransactions() [][]byte

func (*BlockBody) Hash

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

Hash returns the block body hash

func (*BlockBody) ProtoMarshal

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

ProtoMarshal json encoding of body only

func (*BlockBody) ProtoMessage

func (*BlockBody) ProtoMessage()

func (*BlockBody) ProtoUnmarshal

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

ProtoUnmarshal unmarshal the protobuff for the block body

func (*BlockBody) Reset

func (m *BlockBody) Reset()

func (*BlockBody) String

func (m *BlockBody) String() string

func (*BlockBody) XXX_DiscardUnknown

func (m *BlockBody) XXX_DiscardUnknown()

func (*BlockBody) XXX_Marshal

func (m *BlockBody) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*BlockBody) XXX_Merge

func (m *BlockBody) XXX_Merge(src proto.Message)

func (*BlockBody) XXX_Size

func (m *BlockBody) XXX_Size() int

func (*BlockBody) XXX_Unmarshal

func (m *BlockBody) XXX_Unmarshal(b []byte) error

type BlockSignature

type BlockSignature struct {
	Validator            []byte   `protobuf:"bytes,1,opt,name=Validator,proto3" json:"Validator,omitempty"`
	Index                int64    `protobuf:"varint,2,opt,name=Index,proto3" json:"Index,omitempty"`
	Signature            string   `protobuf:"bytes,3,opt,name=Signature,proto3" json:"Signature,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*BlockSignature) Descriptor

func (*BlockSignature) Descriptor() ([]byte, []int)

func (*BlockSignature) Equals

func (bs *BlockSignature) Equals(that *BlockSignature) bool

Equals checks blocksignature equality

func (*BlockSignature) GetIndex

func (m *BlockSignature) GetIndex() int64

func (*BlockSignature) GetSignature

func (m *BlockSignature) GetSignature() string

func (*BlockSignature) GetValidator

func (m *BlockSignature) GetValidator() []byte

func (*BlockSignature) ProtoMarshal

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

ProtoMarshal marshal the block signatures to protobuff

func (*BlockSignature) ProtoMessage

func (*BlockSignature) ProtoMessage()

func (*BlockSignature) ProtoUnmarshal

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

ProtoUnmarshal unmarshals the blocksignature from protobuff

func (*BlockSignature) Reset

func (m *BlockSignature) Reset()

func (*BlockSignature) String

func (m *BlockSignature) String() string

func (*BlockSignature) ToWire

func (bs *BlockSignature) ToWire() WireBlockSignature

ToWire converts block signatures to wire (transport)

func (*BlockSignature) ValidatorHex

func (bs *BlockSignature) ValidatorHex() string

ValidatorHex returns the Hex ID of a validator for this block

func (*BlockSignature) XXX_DiscardUnknown

func (m *BlockSignature) XXX_DiscardUnknown()

func (*BlockSignature) XXX_Marshal

func (m *BlockSignature) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*BlockSignature) XXX_Merge

func (m *BlockSignature) XXX_Merge(src proto.Message)

func (*BlockSignature) XXX_Size

func (m *BlockSignature) XXX_Size() int

func (*BlockSignature) XXX_Unmarshal

func (m *BlockSignature) XXX_Unmarshal(b []byte) error

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 Core

type Core interface {
	Head() EventHash
	HexID() string
}

Core is an interface for interacting with a core.

type Event

type Event struct {
	Message *EventMessage
	// contains filtered or unexported fields
}

Event struct

func NewEvent

func NewEvent(
	transactions [][]byte,
	internalTransactions []*wire.InternalTransaction,
	blockSignatures []BlockSignature,
	parents EventHashes, creator []byte, index int64,
	ft FlagTable) Event

NewEvent creates new block event.

func (*Event) BlockSignatures

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

BlockSignatures returns all block signatures for this event

func (*Event) CreatorID

func (e *Event) CreatorID() uint64

CreatorID returns the creator ID for an event

func (*Event) GetCreator

func (e *Event) GetCreator() string

GetCreator returns the creator for the event

func (*Event) GetFlagTable

func (e *Event) GetFlagTable() (FlagTable, error)

GetFlagTable returns the flag table.

func (*Event) GetLamportTimestamp

func (e *Event) GetLamportTimestamp() int64

GetLamportTimestamp returns the lamport timestamp

func (*Event) GetRound

func (e *Event) GetRound() int64

GetRound Round returns round of event.

func (*Event) GetRoundReceived

func (e *Event) GetRoundReceived() int64

GetRoundReceived Round returns round in which the event is received.

func (*Event) Hash

func (e *Event) Hash() (hash EventHash)

Hash sha256 hash of body

func (*Event) Index

func (e *Event) Index() int64

Index returns the index (height) of this event

func (*Event) InternalTransactions

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

InternalTransactions returns all internal transactions in the event

func (*Event) IsLoaded

func (e *Event) IsLoaded() bool

IsLoaded True if Event contains a payload or is the initial Event of its creator

func (*Event) MergeFlagTable

func (e *Event) MergeFlagTable(dst FlagTable) (FlagTable, error)

MergeFlagTable returns merged flag table object.

func (*Event) OtherParent

func (e *Event) OtherParent() (hash EventHash)

OtherParent returns the other (not creators) parent(s) hash(es)

func (*Event) OtherParentCreatorID

func (e *Event) OtherParentCreatorID() uint64

OtherParentCreatorID ID of other parent(s)

func (*Event) ProtoMarshal

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

ProtoMarshal event to protobuff

func (*Event) ProtoUnmarshal

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

ProtoUnmarshal profotbuff to event

func (*Event) ReplaceFlagTable

func (e *Event) ReplaceFlagTable(flagTable FlagTable) (err error)

ReplaceFlagTable replaces flag table.

func (*Event) SelfParent

func (e *Event) SelfParent() (hash EventHash)

SelfParent returns the previous event block hash in this creator DAG

func (*Event) SetLamportTimestamp

func (e *Event) SetLamportTimestamp(t int64)

SetLamportTimestamp for event

func (*Event) SetRound

func (e *Event) SetRound(r int64)

SetRound for event

func (*Event) SetRoundReceived

func (e *Event) SetRoundReceived(rr int64)

SetRoundReceived for event

func (*Event) SetWireInfo

func (e *Event) SetWireInfo(selfParentIndex int64, otherParentCreatorID uint64, otherParentIndex int64, creatorID uint64)

SetWireInfo for event

func (*Event) Sign

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

Sign ecdsa sig

func (*Event) ToWire

func (e *Event) ToWire() WireEvent

ToWire converts event to wire event

func (*Event) Transactions

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

Transactions returns all transactions in the event

func (*Event) Verify

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

Verify ecdsa sig

func (*Event) WireBlockSignatures

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

WireBlockSignatures returns the wire block signatures for the event

type EventBody

type EventBody struct {
	Transactions         [][]byte                    `protobuf:"bytes,1,rep,name=Transactions,proto3" json:"Transactions,omitempty"`
	InternalTransactions []*wire.InternalTransaction `protobuf:"bytes,2,rep,name=InternalTransactions,proto3" json:"InternalTransactions,omitempty"`
	Parents              [][]byte                    `protobuf:"bytes,3,rep,name=Parents,proto3" json:"Parents,omitempty"`
	Creator              []byte                      `protobuf:"bytes,4,opt,name=Creator,proto3" json:"Creator,omitempty"`
	Index                int64                       `protobuf:"varint,5,opt,name=Index,proto3" json:"Index,omitempty"`
	BlockSignatures      []*BlockSignature           `protobuf:"bytes,6,rep,name=BlockSignatures,proto3" json:"BlockSignatures,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                    `json:"-"`
	XXX_unrecognized     []byte                      `json:"-"`
	XXX_sizecache        int32                       `json:"-"`
}

func (*EventBody) Descriptor

func (*EventBody) Descriptor() ([]byte, []int)

func (*EventBody) Equals

func (e *EventBody) Equals(that *EventBody) bool

Equals event body equality check

func (*EventBody) GetBlockSignatures

func (m *EventBody) GetBlockSignatures() []*BlockSignature

func (*EventBody) GetCreator

func (m *EventBody) GetCreator() []byte

func (*EventBody) GetIndex

func (m *EventBody) GetIndex() int64

func (*EventBody) GetInternalTransactions

func (m *EventBody) GetInternalTransactions() []*wire.InternalTransaction

func (*EventBody) GetParents

func (m *EventBody) GetParents() [][]byte

func (*EventBody) GetTransactions

func (m *EventBody) GetTransactions() [][]byte

func (*EventBody) Hash

func (e *EventBody) Hash() (hash EventHash, err error)

Hash returns hash of event body

func (*EventBody) ProtoMarshal

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

ProtoMarshal marshal event body to protobuff

func (*EventBody) ProtoMessage

func (*EventBody) ProtoMessage()

func (*EventBody) ProtoUnmarshal

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

ProtoUnmarshal unmarshal protobuff to event body

func (*EventBody) Reset

func (m *EventBody) Reset()

func (*EventBody) String

func (m *EventBody) String() string

func (*EventBody) XXX_DiscardUnknown

func (m *EventBody) XXX_DiscardUnknown()

func (*EventBody) XXX_Marshal

func (m *EventBody) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*EventBody) XXX_Merge

func (m *EventBody) XXX_Merge(src proto.Message)

func (*EventBody) XXX_Size

func (m *EventBody) XXX_Size() int

func (*EventBody) XXX_Unmarshal

func (m *EventBody) XXX_Unmarshal(b []byte) error

type EventHash

type EventHash common.Hash

EventHash is a dedicated type for Event's hash.

func CalcEventHash

func CalcEventHash(data []byte) EventHash

CalcEventHash calculates hash of data.

func GenRootSelfParent

func GenRootSelfParent(participantID uint64) (hash EventHash)

GenRootSelfParent generates Event's parent hash from participant ID. Use it for first Event only.

func (*EventHash) Bytes

func (hash *EventHash) Bytes() []byte

Bytes returns value as bytes.

func (*EventHash) Equal

func (hash *EventHash) Equal(raw []byte) bool

Equal compares value with bytes.

func (*EventHash) Parse

func (hash *EventHash) Parse(raw string) error

Parse sets value to bytes parsed from hex string.

func (*EventHash) Set

func (hash *EventHash) Set(raw []byte)

Set sets value to bytes.

func (*EventHash) String

func (hash *EventHash) String() string

String returns value as hex string.

func (*EventHash) Zero

func (hash *EventHash) Zero() bool

Zero returns true if zero value.

type EventHashes

type EventHashes []EventHash

EventHashes provides additional methods of EventHash slice.

func (EventHashes) Bytes

func (hashes EventHashes) Bytes() [][]byte

Bytes returns values as slice of bytes.

func (EventHashes) Contains

func (hashes EventHashes) Contains(hash EventHash) bool

Contains returns true if there is the hash in values.

func (EventHashes) Len

func (hashes EventHashes) Len() int

Len is a part of sort.Interface implementation.

func (EventHashes) Less

func (hashes EventHashes) Less(i, j int) bool

Less is a part of sort.Interface implementation.

func (EventHashes) Strings

func (hashes EventHashes) Strings() []string

Strings returns values as slice of hex strings.

func (EventHashes) Swap

func (hashes EventHashes) Swap(i, j int)

Swap is a part of sort.Interface implementation.

type EventMessage

type EventMessage struct {
	Body                 *EventBody `protobuf:"bytes,1,opt,name=Body,proto3" json:"Body,omitempty"`
	Signature            string     `protobuf:"bytes,2,opt,name=Signature,proto3" json:"Signature,omitempty"`
	FlagTable            []byte     `protobuf:"bytes,3,opt,name=FlagTable,proto3" json:"FlagTable,omitempty"`
	ClothoProof          [][]byte   `protobuf:"bytes,4,rep,name=ClothoProof,proto3" json:"ClothoProof,omitempty"`
	SelfParentIndex      int64      `protobuf:"varint,5,opt,name=SelfParentIndex,proto3" json:"SelfParentIndex,omitempty"`
	OtherParentCreatorID uint64     `protobuf:"varint,6,opt,name=OtherParentCreatorID,proto3" json:"OtherParentCreatorID,omitempty"`
	OtherParentIndex     int64      `protobuf:"varint,7,opt,name=OtherParentIndex,proto3" json:"OtherParentIndex,omitempty"`
	CreatorID            uint64     `protobuf:"varint,8,opt,name=CreatorID,proto3" json:"CreatorID,omitempty"`
	TopologicalIndex     int64      `protobuf:"varint,9,opt,name=TopologicalIndex,proto3" json:"TopologicalIndex,omitempty"`
	Hash                 []byte     `protobuf:"bytes,10,opt,name=Hash,proto3" json:"Hash,omitempty"`
	XXX_NoUnkeyedLiteral struct{}   `json:"-"`
	XXX_unrecognized     []byte     `json:"-"`
	XXX_sizecache        int32      `json:"-"`
}

func (*EventMessage) Descriptor

func (*EventMessage) Descriptor() ([]byte, []int)

func (*EventMessage) Equals

func (m *EventMessage) Equals(that *EventMessage) bool

Equals compares equality of two event messages

func (*EventMessage) GetBody

func (m *EventMessage) GetBody() *EventBody

func (*EventMessage) GetClothoProof

func (m *EventMessage) GetClothoProof() [][]byte

func (*EventMessage) GetCreatorID

func (m *EventMessage) GetCreatorID() uint64

func (*EventMessage) GetFlagTable

func (m *EventMessage) GetFlagTable() []byte

func (*EventMessage) GetHash

func (m *EventMessage) GetHash() []byte

func (*EventMessage) GetOtherParentCreatorID

func (m *EventMessage) GetOtherParentCreatorID() uint64

func (*EventMessage) GetOtherParentIndex

func (m *EventMessage) GetOtherParentIndex() int64

func (*EventMessage) GetSelfParentIndex

func (m *EventMessage) GetSelfParentIndex() int64

func (*EventMessage) GetSignature

func (m *EventMessage) GetSignature() string

func (*EventMessage) GetTopologicalIndex

func (m *EventMessage) GetTopologicalIndex() int64

func (*EventMessage) ProtoMessage

func (*EventMessage) ProtoMessage()

func (*EventMessage) Reset

func (m *EventMessage) Reset()

func (*EventMessage) String

func (m *EventMessage) String() string

func (*EventMessage) ToEvent

func (m *EventMessage) ToEvent() Event

ToEvent converts message to event

func (*EventMessage) XXX_DiscardUnknown

func (m *EventMessage) XXX_DiscardUnknown()

func (*EventMessage) XXX_Marshal

func (m *EventMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*EventMessage) XXX_Merge

func (m *EventMessage) XXX_Merge(src proto.Message)

func (*EventMessage) XXX_Size

func (m *EventMessage) XXX_Size() int

func (*EventMessage) XXX_Unmarshal

func (m *EventMessage) XXX_Unmarshal(b []byte) error

type FlagTable

type FlagTable map[EventHash]int64

FlagTable is a dedicated type for the Events flags map.

func NewFlagTable

func NewFlagTable() FlagTable

NewFlagTable creates new empty FlagTable

func (FlagTable) Marshal

func (ft FlagTable) Marshal() []byte

Marshal converts FlagTable to protobuf.

func (FlagTable) Unmarshal

func (ft FlagTable) Unmarshal(buf []byte) error

Unmarshal reads protobuff into FlagTable.

type FlagTableWrapper

type FlagTableWrapper struct {
	Body                 map[string]int64 `` /* 150-byte string literal not displayed */
	XXX_NoUnkeyedLiteral struct{}         `json:"-"`
	XXX_unrecognized     []byte           `json:"-"`
	XXX_sizecache        int32            `json:"-"`
}

func (*FlagTableWrapper) Descriptor

func (*FlagTableWrapper) Descriptor() ([]byte, []int)

func (*FlagTableWrapper) GetBody

func (m *FlagTableWrapper) GetBody() map[string]int64

func (*FlagTableWrapper) ProtoMessage

func (*FlagTableWrapper) ProtoMessage()

func (*FlagTableWrapper) Reset

func (m *FlagTableWrapper) Reset()

func (*FlagTableWrapper) String

func (m *FlagTableWrapper) String() string

func (*FlagTableWrapper) XXX_DiscardUnknown

func (m *FlagTableWrapper) XXX_DiscardUnknown()

func (*FlagTableWrapper) XXX_Marshal

func (m *FlagTableWrapper) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*FlagTableWrapper) XXX_Merge

func (m *FlagTableWrapper) XXX_Merge(src proto.Message)

func (*FlagTableWrapper) XXX_Size

func (m *FlagTableWrapper) XXX_Size() int

func (*FlagTableWrapper) XXX_Unmarshal

func (m *FlagTableWrapper) XXX_Unmarshal(b []byte) error

type Frame

type Frame struct {
	Round                int64           `protobuf:"varint,1,opt,name=Round,proto3" json:"Round,omitempty"`
	Roots                []*Root         `protobuf:"bytes,2,rep,name=Roots,proto3" json:"Roots,omitempty"`
	Events               []*EventMessage `protobuf:"bytes,3,rep,name=Events,proto3" json:"Events,omitempty"`
	StateHash            []byte          `protobuf:"bytes,4,opt,name=StateHash,proto3" json:"StateHash,omitempty"`
	XXX_NoUnkeyedLiteral struct{}        `json:"-"`
	XXX_unrecognized     []byte          `json:"-"`
	XXX_sizecache        int32           `json:"-"`
}

func (*Frame) Descriptor

func (*Frame) Descriptor() ([]byte, []int)

func (*Frame) Equals

func (f *Frame) Equals(that *Frame) bool

Equals compares the equality of two frames

func (*Frame) GetEventBlocks

func (f *Frame) GetEventBlocks() []*EventMessage

GetEventBlocks provides alternative for non-existent Protobuf generated function

func (*Frame) GetEvents

func (m *Frame) GetEvents() []*EventMessage

func (*Frame) GetRoots

func (m *Frame) GetRoots() []*Root

func (*Frame) GetRound

func (m *Frame) GetRound() int64

func (*Frame) GetStateHash

func (m *Frame) GetStateHash() []byte

func (*Frame) Hash

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

Hash returns the Hash of a frame

func (*Frame) ProtoMarshal

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

ProtoMarshal json encoding of Frame

func (*Frame) ProtoMessage

func (*Frame) ProtoMessage()

func (*Frame) ProtoUnmarshal

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

ProtoUnmarshal converts protobuf to frame

func (*Frame) Reset

func (m *Frame) Reset()

func (*Frame) String

func (m *Frame) String() string

func (*Frame) XXX_DiscardUnknown

func (m *Frame) XXX_DiscardUnknown()

func (*Frame) XXX_Marshal

func (m *Frame) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Frame) XXX_Merge

func (m *Frame) XXX_Merge(src proto.Message)

func (*Frame) XXX_Size

func (m *Frame) XXX_Size() int

func (*Frame) XXX_Unmarshal

func (m *Frame) XXX_Unmarshal(b []byte) error

type InmemStore

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

InmemStore struct

func NewInmemStore

func NewInmemStore(participants *peers.Peers, cacheSize int, posConf *pos.Config) *InmemStore

NewInmemStore constructor

func (*InmemStore) AddConsensusEvent

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

AddConsensusEvent to store

func (*InmemStore) CacheSize

func (s *InmemStore) CacheSize() int

CacheSize size of cache

func (*InmemStore) Close

func (s *InmemStore) Close() error

Close the store

func (*InmemStore) ConsensusEvents

func (s *InmemStore) ConsensusEvents() EventHashes

ConsensusEvents returns all consensus events

func (*InmemStore) ConsensusEventsCount

func (s *InmemStore) ConsensusEventsCount() int64

ConsensusEventsCount returns count of all consnesus events

func (*InmemStore) GetBlock

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

GetBlock for index

func (*InmemStore) GetEventBlock

func (s *InmemStore) GetEventBlock(hash EventHash) (Event, error)

GetEventBlock gets specific event block by hash

func (*InmemStore) GetFrame

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

GetFrame by index

func (*InmemStore) GetRoot

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

GetRoot for participant

func (*InmemStore) GetRoundCreated

func (s *InmemStore) GetRoundCreated(r int64) (RoundCreated, error)

GetRoundCreated retrieves created round by ID

func (*InmemStore) GetRoundReceived

func (s *InmemStore) GetRoundReceived(r int64) (RoundReceived, error)

GetRoundReceived gets received round by ID

func (*InmemStore) LastBlockIndex

func (s *InmemStore) LastBlockIndex() int64

LastBlockIndex getter

func (*InmemStore) LastConsensusEventFrom

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

LastConsensusEventFrom participant

func (*InmemStore) LastEventFrom

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

LastEventFrom participant

func (*InmemStore) LastRound

func (s *InmemStore) LastRound() int64

LastRound getter

func (*InmemStore) NeedBootstrap

func (s *InmemStore) NeedBootstrap() bool

NeedBootstrap for the store

func (*InmemStore) ParticipantEvent

func (s *InmemStore) ParticipantEvent(participant string, index int64) (hash EventHash, err error)

ParticipantEvent specific event

func (*InmemStore) ParticipantEvents

func (s *InmemStore) ParticipantEvents(participant string, skip int64) (EventHashes, error)

ParticipantEvents events for the participant

func (*InmemStore) Participants

func (s *InmemStore) Participants() (*peers.Peers, error)

Participants returns participants

func (*InmemStore) Reset

func (s *InmemStore) Reset(roots map[string]Root) error

Reset resets the store

func (*InmemStore) RootsByParticipant

func (s *InmemStore) RootsByParticipant() map[string]Root

RootsByParticipant retrieve PubKeyHex map of roots

func (*InmemStore) RootsBySelfParent

func (s *InmemStore) RootsBySelfParent() map[EventHash]Root

RootsBySelfParent retrieve EventHash map of roots

func (*InmemStore) RoundClothos

func (s *InmemStore) RoundClothos(r int64) EventHashes

RoundClothos all clothos for the specified round

func (*InmemStore) RoundEvents

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

RoundEvents returns events for the round

func (*InmemStore) SetBlock

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

SetBlock TODO

func (*InmemStore) SetEvent

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

SetEvent set event for event block

func (*InmemStore) SetFrame

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

SetFrame in the store

func (*InmemStore) SetRoundCreated

func (s *InmemStore) SetRoundCreated(r int64, round RoundCreated) error

SetRoundCreated stores created round by ID

func (*InmemStore) SetRoundReceived

func (s *InmemStore) SetRoundReceived(r int64, round RoundReceived) error

SetRoundReceived stores received round by ID

func (*InmemStore) StateDB

func (s *InmemStore) StateDB() state.Database

StateDB returns state database

func (*InmemStore) StateRoot

func (s *InmemStore) StateRoot() hash.Hash

StateRoot returns genesis state hash.

func (*InmemStore) StorePath

func (s *InmemStore) StorePath() string

StorePath getter

func (*InmemStore) TopologicalEvents

func (s *InmemStore) TopologicalEvents() ([]Event, error)

TopologicalEvents returns event in topological order.

type Key

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

Key struct

func (Key) ToString

func (k Key) ToString() string

ToString converts key to string

type ParentRoundInfo

type ParentRoundInfo struct {
	Atropos int
	// contains filtered or unexported fields
}

ParentRoundInfo struct

func NewBaseParentRoundInfo

func NewBaseParentRoundInfo() ParentRoundInfo

NewBaseParentRoundInfo constructor

type ParticipantBlockSignaturesCache

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

ParticipantBlockSignaturesCache struct

func NewParticipantBlockSignaturesCache

func NewParticipantBlockSignaturesCache(size int, participants *peers.Peers) *ParticipantBlockSignaturesCache

NewParticipantBlockSignaturesCache constructor

func (*ParticipantBlockSignaturesCache) Get

func (psc *ParticipantBlockSignaturesCache) Get(participant string, skipIndex int64) ([]BlockSignature, error)

Get return participant BlockSignatures where index > skip

func (*ParticipantBlockSignaturesCache) GetItem

func (psc *ParticipantBlockSignaturesCache) GetItem(participant string, index int64) (BlockSignature, error)

GetItem get block signature at index for participant

func (*ParticipantBlockSignaturesCache) GetLast

func (psc *ParticipantBlockSignaturesCache) GetLast(participant string) (BlockSignature, error)

GetLast get last block signature for participant

func (*ParticipantBlockSignaturesCache) Known

func (psc *ParticipantBlockSignaturesCache) Known() map[uint64]int64

Known returns [participant id] => last BlockSignature Index

func (*ParticipantBlockSignaturesCache) Reset

Reset resets the block signature cache

func (*ParticipantBlockSignaturesCache) Set

func (psc *ParticipantBlockSignaturesCache) Set(participant string, sig BlockSignature) error

Set sets the last block signature for the participant

type ParticipantEventsCache

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

ParticipantEventsCache struct

func NewParticipantEventsCache

func NewParticipantEventsCache(size int, participants *peers.Peers) *ParticipantEventsCache

NewParticipantEventsCache constructor

func (*ParticipantEventsCache) AddPeer

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

AddPeer adds peer to cache and rolling index map, returns error if it failed to add to map

func (*ParticipantEventsCache) Get

func (pec *ParticipantEventsCache) Get(participant string, skipIndex int64) (EventHashes, error)

Get return participant events with index > skip

func (*ParticipantEventsCache) GetItem

func (pec *ParticipantEventsCache) GetItem(participant string, index int64) (hash EventHash, err error)

GetItem get event for participant at index

func (*ParticipantEventsCache) GetLast

func (pec *ParticipantEventsCache) GetLast(participant string) (hash EventHash, err error)

GetLast get last event for participant

func (*ParticipantEventsCache) Import

func (pec *ParticipantEventsCache) Import(other *ParticipantEventsCache)

Import from another event cache

func (*ParticipantEventsCache) Known

func (pec *ParticipantEventsCache) Known() map[uint64]int64

Known returns [participant id] => lastKnownIndex

func (*ParticipantEventsCache) Reset

func (pec *ParticipantEventsCache) Reset() error

Reset resets the event cache

func (*ParticipantEventsCache) Set

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

Set the event for the participant

type Poset

type Poset struct {
	Participants             *peers.Peers      // [public key] => id
	Store                    Store             // store of Events, Rounds, and Blocks
	UndeterminedEvents       []EventHash       // [index] => hash . FIFO queue of Events whose consensus order is not yet determined
	PendingRounds            []*pendingRound   // FIFO queue of Rounds which have not attained consensus yet
	PendingRoundReceived     common.Int64Slice // FIFO queue of RoundReceived which have not been made into frames yet
	LastConsensusRound       *int64            // index of last consensus round
	FirstConsensusRound      *int64            // index of first consensus round (only used in tests)
	AnchorBlock              *int64            // index of last block with enough signatures
	LastCommittedRoundEvents int               // number of events in round before LastConsensusRound
	SigPool                  []BlockSignature  // Pool of Block signatures that need to be processed
	ConsensusTransactions    uint64            // number of consensus transactions
	// contains filtered or unexported fields
}

Poset is a DAG of Events. It also contains methods to extract a consensus order of Events and map them onto a blockchain.

func NewPoset

func NewPoset(participants *peers.Peers, store Store, commitCh chan Block, logger *logrus.Entry) *Poset

NewPoset instantiates a Poset from a list of participants, underlying data store and commit channel

func (*Poset) ApplyInternalTransactions

func (p *Poset) ApplyInternalTransactions(round int64, orderedEvents []Event) (res hash.Hash, err error)

ApplyInternalTransactions calcs new PoS-state from prev round's state and returns its hash.

func (*Poset) Bootstrap

func (p *Poset) Bootstrap() error

Bootstrap loads all Events from the Store's DB (if there is one) and feeds them to the Poset (in topological order) for consensus ordering. After this method call, the Poset should be in a state coherent with the 'tip' of the Poset

func (*Poset) CheckBlock

func (p *Poset) CheckBlock(block Block) error

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

func (*Poset) DecideAtropos

func (p *Poset) DecideAtropos() error

DecideAtropos decides if clothos are atropos

func (*Poset) DecideRoundReceived

func (p *Poset) DecideRoundReceived() error

DecideRoundReceived assigns a RoundReceived to undetermined events when they reach consensus

func (*Poset) DivideRounds

func (p *Poset) DivideRounds() error

DivideRounds assigns a Round and LamportTimestamp to Events, and flags them as clothos if necessary. Pushes Rounds in the PendingRounds queue if necessary.

func (*Poset) GetAnchorBlockWithFrame

func (p *Poset) GetAnchorBlockWithFrame() (Block, Frame, error)

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

func (*Poset) GetConsensusTransactionsCount

func (p *Poset) GetConsensusTransactionsCount() uint64

GetConsensusTransactionsCount returns the count of finalized transactions

func (*Poset) GetFrame

func (p *Poset) GetFrame(roundReceived int64) (Frame, error)

GetFrame returns the Frame corresponding to a RoundReceived.

func (*Poset) GetLastConsensusRound

func (p *Poset) GetLastConsensusRound() int64

GetLastConsensusRound returns the last consensus round

func (*Poset) GetPeerFlagTableOfRandomUndeterminedEvent

func (p *Poset) GetPeerFlagTableOfRandomUndeterminedEvent() (map[string]int64, error)

GetPeerFlagTableOfRandomUndeterminedEvent returns the flag table for undermined events

func (*Poset) GetPendingLoadedEvents

func (p *Poset) GetPendingLoadedEvents() int64

GetPendingLoadedEvents returns all the pending events

func (*Poset) GetUndeterminedEvents

func (p *Poset) GetUndeterminedEvents() EventHashes

GetUndeterminedEvents returns all the undetermined events

func (*Poset) InsertEvent

func (p *Poset) InsertEvent(event Event, setWireInfo bool) error

InsertEvent attempts to insert an Event in the DAG. It verifies the signature, checks the dominators are known, and prevents the introduction of forks.

func (*Poset) MakeFrame

func (p *Poset) MakeFrame(roundReceived int64) (Frame, error)

MakeFrame computes the Frame corresponding to a RoundReceived.

func (*Poset) MapSentinels

func (p *Poset) MapSentinels(x, y EventHash, sentinels map[string]bool) error

MapSentinels participants in x's dominator that dominate y

func (*Poset) ProcessDecidedRounds

func (p *Poset) ProcessDecidedRounds() error

ProcessDecidedRounds takes Rounds whose clothos are decided, computes the corresponding Frames, maps them into Blocks, and commits the Blocks via the commit channel

func (*Poset) ProcessSigPool

func (p *Poset) ProcessSigPool() error

ProcessSigPool runs through the SignaturePool and tries to map a Signature to a known Block. If a Signature is found to be valid for a known Block, it is appended to the block and removed from the SignaturePool

func (*Poset) ReadWireInfo

func (p *Poset) ReadWireInfo(wevent WireEvent) (*Event, error)

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

func (*Poset) Reset

func (p *Poset) Reset(block Block, frame Frame) error

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

func (*Poset) SetCore

func (p *Poset) SetCore(core Core)

SetCore sets a core for poset.

func (*Poset) SetWireInfo

func (p *Poset) SetWireInfo(event *Event) error

SetWireInfo set wire info for the event

func (*Poset) SetWireInfoAndSign

func (p *Poset) SetWireInfoAndSign(event *Event, privKey *ecdsa.PrivateKey) error

SetWireInfoAndSign set wire info for the event and sign

type Root

type Root struct {
	NextRound            int64                 `protobuf:"varint,1,opt,name=NextRound,proto3" json:"NextRound,omitempty"`
	SelfParent           *RootEvent            `protobuf:"bytes,2,opt,name=SelfParent,proto3" json:"SelfParent,omitempty"`
	Others               map[string]*RootEvent `` /* 153-byte string literal not displayed */
	XXX_NoUnkeyedLiteral struct{}              `json:"-"`
	XXX_unrecognized     []byte                `json:"-"`
	XXX_sizecache        int32                 `json:"-"`
}

func NewBaseRoot

func NewBaseRoot(creatorID uint64) Root

NewBaseRoot initializes a Root object for a fresh Poset.

func (*Root) Descriptor

func (*Root) Descriptor() ([]byte, []int)

func (*Root) Equals

func (root *Root) Equals(that *Root) bool

Equals compares two roots

func (*Root) GetNextRound

func (m *Root) GetNextRound() int64

func (*Root) GetOthers

func (m *Root) GetOthers() map[string]*RootEvent

func (*Root) GetSelfParent

func (m *Root) GetSelfParent() *RootEvent

func (*Root) ProtoMarshal

func (root *Root) ProtoMarshal() ([]byte, error)

ProtoMarshal converts root to protobuff

func (*Root) ProtoMessage

func (*Root) ProtoMessage()

func (*Root) ProtoUnmarshal

func (root *Root) ProtoUnmarshal(data []byte) error

ProtoUnmarshal converts protobuff to a root struct

func (*Root) Reset

func (m *Root) Reset()

func (*Root) String

func (m *Root) String() string

func (*Root) XXX_DiscardUnknown

func (m *Root) XXX_DiscardUnknown()

func (*Root) XXX_Marshal

func (m *Root) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Root) XXX_Merge

func (m *Root) XXX_Merge(src proto.Message)

func (*Root) XXX_Size

func (m *Root) XXX_Size() int

func (*Root) XXX_Unmarshal

func (m *Root) XXX_Unmarshal(b []byte) error

type RootEvent

type RootEvent struct {
	Hash                 []byte   `protobuf:"bytes,1,opt,name=Hash,proto3" json:"Hash,omitempty"`
	CreatorID            uint64   `protobuf:"varint,2,opt,name=CreatorID,proto3" json:"CreatorID,omitempty"`
	Index                int64    `protobuf:"varint,3,opt,name=Index,proto3" json:"Index,omitempty"`
	LamportTimestamp     int64    `protobuf:"varint,4,opt,name=LamportTimestamp,proto3" json:"LamportTimestamp,omitempty"`
	Round                int64    `protobuf:"varint,5,opt,name=Round,proto3" json:"Round,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func NewBaseRootEvent

func NewBaseRootEvent(creatorID uint64) RootEvent

NewBaseRootEvent creates a RootEvent corresponding to the the very beginning of a Poset.

func (*RootEvent) Descriptor

func (*RootEvent) Descriptor() ([]byte, []int)

func (*RootEvent) Equals

func (re *RootEvent) Equals(that *RootEvent) bool

Equals compares two root events for equality

func (*RootEvent) GetCreatorID

func (m *RootEvent) GetCreatorID() uint64

func (*RootEvent) GetHash

func (m *RootEvent) GetHash() []byte

func (*RootEvent) GetIndex

func (m *RootEvent) GetIndex() int64

func (*RootEvent) GetLamportTimestamp

func (m *RootEvent) GetLamportTimestamp() int64

func (*RootEvent) GetRound

func (m *RootEvent) GetRound() int64

func (*RootEvent) ProtoMessage

func (*RootEvent) ProtoMessage()

func (*RootEvent) Reset

func (m *RootEvent) Reset()

func (*RootEvent) String

func (m *RootEvent) String() string

func (*RootEvent) XXX_DiscardUnknown

func (m *RootEvent) XXX_DiscardUnknown()

func (*RootEvent) XXX_Marshal

func (m *RootEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RootEvent) XXX_Merge

func (m *RootEvent) XXX_Merge(src proto.Message)

func (*RootEvent) XXX_Size

func (m *RootEvent) XXX_Size() int

func (*RootEvent) XXX_Unmarshal

func (m *RootEvent) XXX_Unmarshal(b []byte) error

type RoundCreated

type RoundCreated struct {
	Message RoundCreatedMessage
}

RoundCreated wrapper for protobuf created round event messages

func NewRoundCreated

func NewRoundCreated() *RoundCreated

NewRoundCreated creates a new round info struct

func (*RoundCreated) AddEvent

func (r *RoundCreated) AddEvent(x EventHash, clotho bool)

AddEvent add event to round info (optionally set clotho)

func (*RoundCreated) Atropos

func (r *RoundCreated) Atropos() (res []EventHash)

Atropos return Atropos

func (*RoundCreated) Clotho

func (r *RoundCreated) Clotho() EventHashes

Clotho return clothos

func (*RoundCreated) ClothoDecided

func (r *RoundCreated) ClothoDecided() bool

ClothoDecided return true if no clothos' fame is left undefined

func (*RoundCreated) ConsensusEvents

func (r *RoundCreated) ConsensusEvents() (res EventHashes)

ConsensusEvents returns all consensus events for the created round

func (*RoundCreated) Equals

func (r *RoundCreated) Equals(that *RoundCreated) bool

Equals compares two round created structs for equality

func (*RoundCreated) IsDecided

func (r *RoundCreated) IsDecided(clotho EventHash) bool

IsDecided checks if the event is a decided clotho

func (*RoundCreated) IsQueued

func (r *RoundCreated) IsQueued() bool

IsQueued returns whether the RoundCreated is queued for processing in PendingRounds

func (*RoundCreated) ProtoMarshal

func (r *RoundCreated) ProtoMarshal() ([]byte, error)

ProtoMarshal marshals the created round to protobuf

func (*RoundCreated) ProtoUnmarshal

func (r *RoundCreated) ProtoUnmarshal(data []byte) error

ProtoUnmarshal de-serialises the created round using protobuf

func (*RoundCreated) RoundEvents

func (r *RoundCreated) RoundEvents() (res EventHashes)

RoundEvents returns all non-consensus events for the created round

func (*RoundCreated) SetAtropos

func (r *RoundCreated) SetAtropos(x EventHash, f bool)

SetAtropos sets whether the given event is Atropos, otherwise it is Clotho when not found

func (*RoundCreated) SetConsensusEvent

func (r *RoundCreated) SetConsensusEvent(x EventHash)

SetConsensusEvent set an event as a consensus event

func (*RoundCreated) SetRoundReceived

func (r *RoundCreated) SetRoundReceived(x string, round int64)

SetRoundReceived set the received round for the given event

type RoundCreatedMessage

type RoundCreatedMessage struct {
	Events               map[string]*RoundEvent `` /* 153-byte string literal not displayed */
	Queued               bool                   `protobuf:"varint,2,opt,name=queued,proto3" json:"queued,omitempty"`
	XXX_NoUnkeyedLiteral struct{}               `json:"-"`
	XXX_unrecognized     []byte                 `json:"-"`
	XXX_sizecache        int32                  `json:"-"`
}

func (*RoundCreatedMessage) Descriptor

func (*RoundCreatedMessage) Descriptor() ([]byte, []int)

func (*RoundCreatedMessage) GetEvents

func (m *RoundCreatedMessage) GetEvents() map[string]*RoundEvent

func (*RoundCreatedMessage) GetQueued

func (m *RoundCreatedMessage) GetQueued() bool

func (*RoundCreatedMessage) ProtoMessage

func (*RoundCreatedMessage) ProtoMessage()

func (*RoundCreatedMessage) Reset

func (m *RoundCreatedMessage) Reset()

func (*RoundCreatedMessage) String

func (m *RoundCreatedMessage) String() string

func (*RoundCreatedMessage) XXX_DiscardUnknown

func (m *RoundCreatedMessage) XXX_DiscardUnknown()

func (*RoundCreatedMessage) XXX_Marshal

func (m *RoundCreatedMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RoundCreatedMessage) XXX_Merge

func (m *RoundCreatedMessage) XXX_Merge(src proto.Message)

func (*RoundCreatedMessage) XXX_Size

func (m *RoundCreatedMessage) XXX_Size() int

func (*RoundCreatedMessage) XXX_Unmarshal

func (m *RoundCreatedMessage) XXX_Unmarshal(b []byte) error

type RoundEvent

type RoundEvent struct {
	Consensus            bool     `protobuf:"varint,1,opt,name=Consensus,proto3" json:"Consensus,omitempty"`
	Clotho               bool     `protobuf:"varint,2,opt,name=Clotho,proto3" json:"Clotho,omitempty"`
	Atropos              Trilean  `protobuf:"varint,3,opt,name=Atropos,proto3,enum=poset.Trilean" json:"Atropos,omitempty"`
	RoundReceived        int64    `protobuf:"varint,4,opt,name=RoundReceived,proto3" json:"RoundReceived,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*RoundEvent) Descriptor

func (*RoundEvent) Descriptor() ([]byte, []int)

func (*RoundEvent) Equals

func (re *RoundEvent) Equals(that *RoundEvent) bool

Equals compares round events for equality

func (*RoundEvent) GetAtropos

func (m *RoundEvent) GetAtropos() Trilean

func (*RoundEvent) GetClotho

func (m *RoundEvent) GetClotho() bool

func (*RoundEvent) GetConsensus

func (m *RoundEvent) GetConsensus() bool

func (*RoundEvent) GetRoundReceived

func (m *RoundEvent) GetRoundReceived() int64

func (*RoundEvent) ProtoMessage

func (*RoundEvent) ProtoMessage()

func (*RoundEvent) Reset

func (m *RoundEvent) Reset()

func (*RoundEvent) String

func (m *RoundEvent) String() string

func (*RoundEvent) XXX_DiscardUnknown

func (m *RoundEvent) XXX_DiscardUnknown()

func (*RoundEvent) XXX_Marshal

func (m *RoundEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RoundEvent) XXX_Merge

func (m *RoundEvent) XXX_Merge(src proto.Message)

func (*RoundEvent) XXX_Size

func (m *RoundEvent) XXX_Size() int

func (*RoundEvent) XXX_Unmarshal

func (m *RoundEvent) XXX_Unmarshal(b []byte) error

type RoundReceived

type RoundReceived struct {
	Rounds               [][]byte `protobuf:"bytes,1,rep,name=Rounds,proto3" json:"Rounds,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func NewRoundReceived

func NewRoundReceived() *RoundReceived

NewRoundReceived constructor

func (*RoundReceived) Descriptor

func (*RoundReceived) Descriptor() ([]byte, []int)

func (*RoundReceived) GetRounds

func (m *RoundReceived) GetRounds() [][]byte

func (*RoundReceived) ProtoMarshal

func (r *RoundReceived) ProtoMarshal() ([]byte, error)

ProtoMarshal serialises the received round using protobuf

func (*RoundReceived) ProtoMessage

func (*RoundReceived) ProtoMessage()

func (*RoundReceived) ProtoUnmarshal

func (r *RoundReceived) ProtoUnmarshal(data []byte) error

ProtoUnmarshal de-serialises RoundReceived using protobuf

func (*RoundReceived) Reset

func (m *RoundReceived) Reset()

func (*RoundReceived) String

func (m *RoundReceived) String() string

func (*RoundReceived) XXX_DiscardUnknown

func (m *RoundReceived) XXX_DiscardUnknown()

func (*RoundReceived) XXX_Marshal

func (m *RoundReceived) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RoundReceived) XXX_Merge

func (m *RoundReceived) XXX_Merge(src proto.Message)

func (*RoundReceived) XXX_Size

func (m *RoundReceived) XXX_Size() int

func (*RoundReceived) XXX_Unmarshal

func (m *RoundReceived) XXX_Unmarshal(b []byte) error

type Store

type Store interface {
	TopologicalEvents() ([]Event, error) // returns event in topological order
	CacheSize() int
	Participants() (*peers.Peers, error)
	RootsBySelfParent() map[EventHash]Root
	RootsByParticipant() map[string]Root
	GetEventBlock(EventHash) (Event, error)
	SetEvent(Event) error
	ParticipantEvents(string, int64) (EventHashes, error)
	ParticipantEvent(string, int64) (EventHash, error)
	LastEventFrom(string) (EventHash, bool, error)
	LastConsensusEventFrom(string) (EventHash, bool, error)
	ConsensusEvents() EventHashes
	ConsensusEventsCount() int64
	AddConsensusEvent(Event) error
	GetRoundCreated(int64) (RoundCreated, error)
	SetRoundCreated(int64, RoundCreated) error
	GetRoundReceived(int64) (RoundReceived, error)
	SetRoundReceived(int64, RoundReceived) error
	LastRound() int64
	RoundClothos(int64) EventHashes
	RoundEvents(int64) int
	GetRoot(string) (Root, error)
	GetBlock(int64) (Block, error)
	SetBlock(Block) error
	LastBlockIndex() int64
	GetFrame(int64) (Frame, error)
	SetFrame(Frame) error
	Reset(map[string]Root) error
	Close() error
	NeedBootstrap() bool // Was the store loaded from existing db
	StorePath() string
	// StateDB returns state database
	StateDB() state.Database
	StateRoot() hash.Hash
}

Store provides an interface for persistent and non-persistent stores to store key lachesis consensus information on a node.

type Trilean

type Trilean int32
const (
	Trilean_UNDEFINED Trilean = 0
	Trilean_TRUE      Trilean = 1
	Trilean_FALSE     Trilean = 2
)

func (Trilean) EnumDescriptor

func (Trilean) EnumDescriptor() ([]byte, []int)

func (Trilean) String

func (x Trilean) String() string

type WireBlockSignature

type WireBlockSignature struct {
	Index                int64    `protobuf:"varint,1,opt,name=Index,proto3" json:"Index,omitempty"`
	Signature            string   `protobuf:"bytes,2,opt,name=Signature,proto3" json:"Signature,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*WireBlockSignature) Descriptor

func (*WireBlockSignature) Descriptor() ([]byte, []int)

func (*WireBlockSignature) Equals

func (wbs *WireBlockSignature) Equals(that *WireBlockSignature) bool

Equals compares the equality of wire block signatures

func (*WireBlockSignature) GetIndex

func (m *WireBlockSignature) GetIndex() int64

func (*WireBlockSignature) GetSignature

func (m *WireBlockSignature) GetSignature() string

func (*WireBlockSignature) ProtoMessage

func (*WireBlockSignature) ProtoMessage()

func (*WireBlockSignature) Reset

func (m *WireBlockSignature) Reset()

func (*WireBlockSignature) String

func (m *WireBlockSignature) String() string

func (*WireBlockSignature) XXX_DiscardUnknown

func (m *WireBlockSignature) XXX_DiscardUnknown()

func (*WireBlockSignature) XXX_Marshal

func (m *WireBlockSignature) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*WireBlockSignature) XXX_Merge

func (m *WireBlockSignature) XXX_Merge(src proto.Message)

func (*WireBlockSignature) XXX_Size

func (m *WireBlockSignature) XXX_Size() int

func (*WireBlockSignature) XXX_Unmarshal

func (m *WireBlockSignature) XXX_Unmarshal(b []byte) error

type WireBody

type WireBody struct {
	Transactions         [][]byte
	InternalTransactions []*inter.InternalTransaction
	BlockSignatures      []WireBlockSignature

	SelfParentIndex      int64
	OtherParentCreatorID uint64
	OtherParentIndex     int64
	CreatorID            uint64

	Index int64
}

WireBody struct

type WireEvent

type WireEvent struct {
	Body        WireBody
	Signature   string
	FlagTable   []byte
	ClothoProof [][]byte
}

WireEvent struct

func (*WireEvent) BlockSignatures

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

BlockSignatures TODO

Jump to

Keyboard shortcuts

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