blockchain

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultValidatorsWindowSize = 10

Blocks to average validator power over

Variables

This section is empty.

Functions

func DecodeValidators added in v0.19.0

func DecodeValidators(encoded []byte, validators *Validators) error

Decodes validators encoded with Encode - expects the exact encoded size with no trailing bytes

Types

type Blockchain added in v0.18.0

type Blockchain struct {
	*Root
	*Tip
	sync.RWMutex
	// contains filtered or unexported fields
}

func LoadOrNewBlockchain added in v0.18.0

func LoadOrNewBlockchain(db dbm.DB, genesisDoc *genesis.GenesisDoc,
	logger *logging.Logger) (*Blockchain, error)

func (*Blockchain) CommitBlock added in v0.19.0

func (bc *Blockchain) CommitBlock(blockTime time.Time, blockHash, appHash []byte) error

func (*Blockchain) Encode added in v0.19.0

func (bc *Blockchain) Encode() ([]byte, error)

type BlockchainInfo added in v0.19.0

type BlockchainInfo interface {
	TipInfo
	GenesisHash() []byte
	GenesisDoc() genesis.GenesisDoc
}

type PersistedState added in v0.18.0

type PersistedState struct {
	AppHashAfterLastBlock []byte
	LastBlockHeight       uint64
	GenesisDoc            genesis.GenesisDoc
}

func Decode added in v0.18.0

func Decode(encodedState []byte) (*PersistedState, error)

type Root added in v0.18.0

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

func NewRoot added in v0.18.0

func NewRoot(genesisDoc *genesis.GenesisDoc) *Root

func (*Root) GenesisDoc added in v0.18.0

func (r *Root) GenesisDoc() genesis.GenesisDoc

func (*Root) GenesisHash added in v0.18.0

func (r *Root) GenesisHash() []byte

type Tip added in v0.18.0

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

func NewTip added in v0.18.0

func NewTip(chainID string, genesisTime time.Time, genesisHash []byte) *Tip

Create genesis Tip

func (*Tip) AppHashAfterLastBlock added in v0.18.0

func (t *Tip) AppHashAfterLastBlock() []byte

func (*Tip) ChainID added in v0.18.0

func (t *Tip) ChainID() string

func (*Tip) IterateValidators added in v0.19.0

func (t *Tip) IterateValidators(iter func(publicKey crypto.PublicKey, power uint64) (stop bool)) (stopped bool)

func (*Tip) LastBlockHash added in v0.18.0

func (t *Tip) LastBlockHash() []byte

func (*Tip) LastBlockHeight added in v0.18.0

func (t *Tip) LastBlockHeight() uint64

func (*Tip) LastBlockTime added in v0.18.0

func (t *Tip) LastBlockTime() time.Time

func (*Tip) NumValidators added in v0.19.0

func (t *Tip) NumValidators() int

type TipInfo added in v0.19.0

type TipInfo interface {
	ChainID() string
	LastBlockHeight() uint64
	LastBlockTime() time.Time
	LastBlockHash() []byte
	AppHashAfterLastBlock() []byte
	IterateValidators(iter func(publicKey crypto.PublicKey, power uint64) (stop bool)) (stopped bool)
	NumValidators() int
}

type Validators added in v0.19.0

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

A Validator multiset

func NewValidators added in v0.19.0

func NewValidators() Validators

func (*Validators) AddPower added in v0.19.0

func (vs *Validators) AddPower(publicKey crypto.PublicKey, power uint64) error

func (*Validators) AlterPower added in v0.19.0

func (vs *Validators) AlterPower(publicKey crypto.PublicKey, power uint64) error

Add the power of a validator

func (*Validators) Encode added in v0.19.0

func (vs *Validators) Encode() []byte

Uses the fixed width public key encoding to

func (*Validators) Iterate added in v0.19.0

func (vs *Validators) Iterate(iter func(publicKey crypto.PublicKey, power uint64) (stop bool)) (stopped bool)

Iterates over validators sorted by address

func (*Validators) Length added in v0.19.0

func (vs *Validators) Length() int

func (*Validators) SubtractPower added in v0.19.0

func (vs *Validators) SubtractPower(publicKey crypto.PublicKey, power uint64) error

func (*Validators) TotalPower added in v0.19.0

func (vs *Validators) TotalPower() uint64

type ValidatorsWindow added in v0.19.0

type ValidatorsWindow struct {
	Buckets []Validators
	Total   Validators
	// contains filtered or unexported fields
}

func NewValidatorsWindow added in v0.19.0

func NewValidatorsWindow(size int) ValidatorsWindow

Provides a sliding window over the last size buckets of validator power changes

func (*ValidatorsWindow) AlterPower added in v0.19.0

func (vw *ValidatorsWindow) AlterPower(publicKey crypto.PublicKey, power uint64) error

Updates the current head bucket (accumulator)

func (*ValidatorsWindow) CommitInto added in v0.19.0

func (vw *ValidatorsWindow) CommitInto(validatorsToUpdate *Validators) error

Jump to

Keyboard shortcuts

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