rootchain

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: AGPL-3.0, ISC Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrEncryptionPubKeyIsNil          = "encryption public key is nil"
	ErrQuorumThresholdOnlyDistributed = "quorum threshold must only be less than total nodes in root chain"
)

Variables

View Source
var ErrSignerIsNil = errors.New("signer is nil")

Functions

func GetPublicKeyAndVerifier

func GetPublicKeyAndVerifier(signer crypto.Signer) ([]byte, crypto.Verifier, error)

func NewDistributedRootGenesis added in v0.1.1

func NewDistributedRootGenesis(rootGenesis []*genesis.RootGenesis) (*genesis.RootGenesis, []*genesis.PartitionGenesis, error)

func NewPartitionRecordFromNodes added in v0.1.1

func NewPartitionRecordFromNodes(nodes []*genesis.PartitionNode) ([]*genesis.PartitionRecord, error)

func NewRootGenesis added in v0.1.1

func NewRootGenesis(id string, s crypto.Signer, encPubKey []byte, partitions []*genesis.PartitionRecord,
	opts ...GenesisOption) (*genesis.RootGenesis, []*genesis.PartitionGenesis, error)

Types

type CertRequestStore added in v0.1.1

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

func NewCertificationRequestStore added in v0.1.1

func NewCertificationRequestStore() *CertRequestStore

NewCertificationRequestStore create new certification requests store

func (*CertRequestStore) Add added in v0.1.1

Add request to certification store. Per node id first valid request is stored. Rest are either duplicate or equivocating and in both cases error is returned. Clear or Reset in order to receive new requests

func (*CertRequestStore) Clear added in v0.1.1

func (c *CertRequestStore) Clear(id p.SystemIdentifier)

Clear clears requests in one partition

func (*CertRequestStore) GetRequests added in v0.1.1

GetRequests returns all stored requests per system identifier

func (*CertRequestStore) IsConsensusReceived added in v0.1.1

func (c *CertRequestStore) IsConsensusReceived(id p.SystemIdentifier, nrOfNodes int) (*certificates.InputRecord, bool)

IsConsensusReceived has partition with id reached consensus. Required nrOfNodes as input to calculate consensus

func (*CertRequestStore) Reset added in v0.1.1

func (c *CertRequestStore) Reset()

Reset removed all incoming requests from all stores

type CertificationRequestStore added in v0.1.1

type CertificationRequestStore interface {
	Add(request *certification.BlockCertificationRequest) error
	IsConsensusReceived(id p.SystemIdentifier, nrOfNodes int) (*certificates.InputRecord, bool)
	GetRequests(id p.SystemIdentifier) []*certification.BlockCertificationRequest
	Reset()
	Clear(id p.SystemIdentifier)
}

type GenesisOption added in v0.1.1

type GenesisOption func(c *rootGenesisConf)

func WithBlockRate added in v0.1.1

func WithBlockRate(rate uint32) GenesisOption

func WithConsensusTimeout added in v0.1.1

func WithConsensusTimeout(timeoutMs uint32) GenesisOption

func WithHashAlgorithm added in v0.1.1

func WithHashAlgorithm(hashAlgorithm gocrypto.Hash) GenesisOption

WithHashAlgorithm set custom hash algorithm (unused for now, remove?)

func WithQuorumThreshold added in v0.1.1

func WithQuorumThreshold(threshold uint32) GenesisOption

func WithTotalNodes added in v0.1.1

func WithTotalNodes(rootValidators uint32) GenesisOption

type Net

type Net interface {
	Send(msg network.OutputMessage, receivers []peer.ID) error
	ReceivedChannel() <-chan network.ReceivedMessage
}

Net provides an interface for sending messages to and receiving messages from other nodes in the network.

type Option

type Option func(c *rootChainConf)

func WithStateStore added in v0.1.1

func WithStateStore(store StateStore) Option

func WithT3Timeout

func WithT3Timeout(timeout time.Duration) Option

type RootChain

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

func NewRootChain

func NewRootChain(peer *network.Peer, genesis *genesis.RootGenesis, signer crypto.Signer, net Net, opts ...Option) (*RootChain, error)

NewRootChain creates a new instance of the root chain.

func (*RootChain) Close

func (rc *RootChain) Close()

type RootNodeInfo added in v0.1.1

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

type State

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

State holds the State of the root chain.

func NewState added in v0.1.1

func NewState(g *genesis.RootGenesis, self string, signer crypto.Signer, stateStore StateStore) (*State, error)

func NewStateFromPartitionRecords

func NewStateFromPartitionRecords(partitions []*genesis.PartitionRecord, nodeId string, signer crypto.Signer, hashAlgorithm gocrypto.Hash) (*State, error)

NewStateFromPartitionRecords creates the State from the genesis.PartitionRecord array. The State returned by this method is usually used to generate genesis file.

func (*State) CopyOldInputRecords

func (s *State) CopyOldInputRecords(id p.SystemIdentifier)

CopyOldInputRecords copies input records from the latest unicity certificate

func (*State) CreateUnicityCertificates

func (s *State) CreateUnicityCertificates() (*store.RootState, error)

CreateUnicityCertificates certifies input records and returns state containing changes (new root, round, UCs changed)

func (*State) GetLatestUnicityCertificate

func (s *State) GetLatestUnicityCertificate(id p.SystemIdentifier) (*certificates.UnicityCertificate, error)

GetLatestUnicityCertificate returns last UC for system identifier

func (*State) HandleBlockCertificationRequest

func (s *State) HandleBlockCertificationRequest(req *certification.BlockCertificationRequest) (*certificates.UnicityCertificate, error)

type StateStore added in v0.1.1

type StateStore interface {
	Save(state store.RootState) error
	Get() (store.RootState, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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