algo

package
v0.0.0-...-1f2bba2 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2019 License: GPL-3.0, GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const AssemblyTime time.Duration = 250 * time.Millisecond

AssemblyTime is the max amount of time to spend on generating a proposal block.

Variables

This section is empty.

Functions

func DeriveNewSeed

func DeriveNewSeed(address common.Address, vrfSK *vrf.PrivateKey, rnd uint64, period uint64, ledger consensus.ChainReader) (newSeed common.Seed, seedProof vrf.Proof, err error)

func Hash

func Hash(data []byte) common.Hash

Hash computes the SHASum512_256 hash of an array of bytes

func HashHeader

func HashHeader(h *types.Header) common.Hash

func HashObj

func HashObj(h Hashable) common.Hash

HashObj computes a hash of a Hashable object and its type

func VerifyNewSeed

func VerifyNewSeed(p *UnauthenticatedProposal, ledger consensus.ChainReader) error

Types

type Algorand

type Algorand struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Algorand is the pure-proof-of-stake consensus engine.

func (*Algorand) Seal

func (a *Algorand) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)

Seal implements consensus.Engine, attempting to create a sealed block using the local signing credentials.

type AsyncPseudoNode

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

func (*AsyncPseudoNode) MakeProposals

func (n *AsyncPseudoNode) MakeProposals(ctx context.Context, r uint64, p uint64) (<-chan externalEvent, error)

type AsyncVoteVerifier

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

AsyncVoteVerifier uses workers to verify agreement protocol votes and writes the results on an output channel specified by the user.

type BlockFactory

type BlockFactory interface {
	// AssembleBlock produces a new ValidatedBlock which is suitable for proposal
	// at a given Round.  The time argument specifies a target deadline by
	// which the block should be produced.  Specifically, the deadline can
	// cause the factory to add fewer transactions to the block in question
	// than might otherwise be possible.
	//
	// AssembleBlock should produce a ValidatedBlock for which the corresponding
	// BlockValidator validates (i.e. for which BlockValidator.Validate
	// returns true). If an insufficient number of nodes can assemble valid
	// entries, the agreement protocol may lose liveness.
	//
	// AssembleBlock may return an error if the BlockFactory is unable to
	// produce a ValidatedBlock for the given round. If an insufficient number of
	// nodes on the network can assemble entries, the agreement protocol may
	// lose liveness.
	AssembleBlock(uint64, time.Time) (*types.Block, error)
}

type BlockValidator

type BlockValidator interface {
	// Validate must return an error if a given Block cannot be determined
	// to be valid as applied to the agreement state; otherwise, it returns
	// nil.
	//
	// The correctness of Validate is essential to the correctness of the
	// protocol. If Validate accepts an invalid Block (i.e., a false
	// positive), the agreement protocol may fork, or the system state may
	// even become undefined. If Validate rejects a valid Block (i.e., a
	// false negative), the agreement protocol may even lose
	// liveness. Validate should therefore be conservative in which Entries
	// it accepts.
	//
	// TODO There should probably be a second Round argument here.
	Validate(context.Context, *types.Block) (*types.Block, error)
}

type Hashable

type Hashable interface {
	ToBeHashed() (protocol.HashID, []byte, error)
}

Hashable is an interface implemented by an object that can be represented with a sequence of bytes to be hashed or signed, together with a type ID to distinguish different types of objects.

type Proposal

type Proposal struct {
	UnauthenticatedProposal
	// contains filtered or unexported fields
}

A proposal is an Block along with everything needed to validate it.

func MakeProposal

func MakeProposal(b *types.Block, pf []byte, origPer uint64, origProp *ecdsa.PublicKey) *Proposal

func (*Proposal) U

type ProposalValue

type ProposalValue struct {
	OriginalPeriod   uint64
	OriginalProposer []byte
	BlockDigest      common.Hash
	EncodingDigest   common.Hash
}

ProposalValue is a triplet of a block hashes (the contents themselves and the encoding of the block), its proposer, and the period in which it was proposed.

type ProposerSeed

type ProposerSeed struct {
	Addr common.Address
	VRF  vrf.Output
}

A proposerSeed is a Hashable input to proposer seed derivation.

func (*ProposerSeed) ToBeHashed

func (s *ProposerSeed) ToBeHashed() (protocol.HashID, []byte, error)

ToBeHashed implements the Hashable interface.

type PseudoNodeBaseTask

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

type PseudoNodeProposalsTask

type PseudoNodeProposalsTask struct {
	PseudoNodeBaseTask
	// contains filtered or unexported fields
}

type PseudoNodeTask

type PseudoNodeTask interface {
	// contains filtered or unexported methods
}

PseudoNodeTask encapsulates a single task which should be executed by the pseudonode.

type PseudoNodeVerifier

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

type Round

type Round uint64

Round represents a protocol round index

type SeedInput

type SeedInput struct {
	Alpha   common.Hash
	History common.Hash
}

A seedInput is a Hashable input to seed rerandomization.

func (*SeedInput) ToBeHashed

func (i *SeedInput) ToBeHashed() (protocol.HashID, []byte, error)

ToBeHashed implements the Hashable interface.

type SignTxFn

SignTxFn is a signTx

type SignerFn

type SignerFn func(accounts.Account, []byte) ([]byte, error)

SignerFn is a signer callback function to request a hash to be signed by a backing account.

type UnauthenticatedProposal

type UnauthenticatedProposal struct {
	*types.Block
	SeedProof        []byte
	OriginalPeriod   uint64
	OriginalProposer []byte
}

UnauthenticatedProposal is an Block along with everything needed to validate it.

func (*UnauthenticatedProposal) Seed

value returns the proposal-value associated with this proposal.

func (*UnauthenticatedProposal) ToBeHashed

func (p *UnauthenticatedProposal) ToBeHashed() (protocol.HashID, []byte, error)

ToBeHashed implements the Hashable interface.

func (UnauthenticatedProposal) Validate

func (p UnauthenticatedProposal) Validate(ctx context.Context, current uint64, ledger consensus.ChainReader, validator BlockValidator) (*Proposal, error)

Validate returns true if the proposal is valid. It checks the proposal seed and then calls validator.Validate.

func (*UnauthenticatedProposal) Value

value returns the proposal-value associated with this proposal.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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