validator

package
v0.20.1 Latest Latest
Warning

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

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

Documentation

Overview

Package validator is a generated protocol buffer package.

It is generated from these files:

validator.proto

It has these top-level messages:

Validator

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthValidator = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowValidator   = fmt.Errorf("proto: integer overflow")
)

Functions

func Add

func Add(vs ReaderWriter, vsOther Iterable) (err error)

Adds vsOther to vs

func AddPower

func AddPower(vs ReaderWriter, id crypto.PublicKey, power *big.Int) error

func Alter

func Alter(vs Writer, vsOther Iterable) (err error)

func Subtract

func Subtract(vs ReaderWriter, vsOther Iterable) (err error)

Subtracts vsOther from vs

func SubtractPower

func SubtractPower(vs ReaderWriter, id crypto.PublicKey, power *big.Int) error

Types

type Iterable

type Iterable interface {
	Iterate(func(id crypto.Addressable, power *big.Int) (stop bool)) (stopped bool)
}

type IterableReader

type IterableReader interface {
	Reader
	Iterable
}

type IterableReaderWriter

type IterableReaderWriter interface {
	ReaderWriter
	Iterable
}

type PersistedRing

type PersistedRing struct {
	Delta [][]*Validator
	Cum   [][]*Validator
	Power []*Validator
	Flow  []*Validator
	Head  int64
}

type Reader

type Reader interface {
	Power(id crypto.PublicKey) *big.Int
}

type ReaderWriter

type ReaderWriter interface {
	Reader
	Writer
}

type Ring

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

func NewRing

func NewRing(initialSet Iterable, windowSize int) *Ring

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

func UnpersistRing

func UnpersistRing(pc PersistedRing) *Ring

func (*Ring) AlterPower

func (vc *Ring) AlterPower(id crypto.PublicKey, power *big.Int) (*big.Int, error)

Updates the current head bucket (accumulator) with some safety checks

func (*Ring) Cum

func (vc *Ring) Cum() *Set

func (*Ring) CurrentSet

func (vc *Ring) CurrentSet() *Set

func (*Ring) Equal

func (vc *Ring) Equal(vwOther *Ring) bool

func (*Ring) Flow

func (vc *Ring) Flow(id crypto.PublicKey, power *big.Int) *big.Int

Returns the flow that would be induced by a validator change by comparing the head accumulater with the current set

func (*Ring) Head

func (vc *Ring) Head() *Set

Get the current accumulator bucket

func (*Ring) MaxFlow

func (vc *Ring) MaxFlow() *big.Int

To ensure that in the maximum valildator shift at least one unit of validator power in the intersection of last block validators and this block validators must have at least one non-byzantine validator who can tell you if you've been lied to about the validator set So need at most ceiling((Total Power)/3) - 1, in integer division we have ceiling(X*p/q) = (p(X+1)-1)/q For p = 1 just X/q So we want (Total Power)/3 - 1

func (*Ring) Next

func (vc *Ring) Next() *Set

func (*Ring) OrderedBuckets

func (vc *Ring) OrderedBuckets() (delta, cum []*Set)

Returns buckets in order head, previous, ...

func (*Ring) Persistable

func (vc *Ring) Persistable() PersistedRing

func (*Ring) Power

func (vc *Ring) Power(id crypto.PublicKey) *big.Int

func (*Ring) PowerAt

func (vc *Ring) PowerAt(index int64, id crypto.PublicKey) *big.Int

Implement Reader Get power at index from the delta bucket then falling through to the cumulative

func (*Ring) PreviousSet

func (vc *Ring) PreviousSet() *Set

func (*Ring) Resultant

func (vc *Ring) Resultant(index int64) *Set

Return the resultant set at index of current cum plus delta

func (*Ring) Rotate

func (vc *Ring) Rotate() (totalPowerChange *big.Int, totalFlow *big.Int, err error)

Advance the current head bucket to the next bucket and returns the change in total power between the previous bucket and the current head, and the total flow which is the sum of absolute values of all changes each validator's power after rotation the next head is a copy of the current head

func (*Ring) Size

func (vc *Ring) Size() int64

Get the number of buckets in the ring (use Current().Count() to get the current number of validators)

func (*Ring) String

func (vc *Ring) String() string

func (*Ring) TotalPower

func (vc *Ring) TotalPower() *big.Int

type Set

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

A Validator multiset - can be used to capture the global state of validators or as an accumulator each block

func Copy

func Copy(vs Iterable) *Set

func CopyTrim

func CopyTrim(vs Iterable) *Set

func NewSet

func NewSet() *Set

Create a new Validators which can act as an accumulator for validator power changes

func NewTrimSet

func NewTrimSet() *Set

Like Set but removes entries when power is set to 0 this make Count() == CountNonZero() and prevents a set from leaking but does mean that a zero will not be iterated over when performing an update which is necessary in Ring

func UnpersistSet

func UnpersistSet(pvs []*Validator) *Set

func (*Set) AlterPower

func (vs *Set) AlterPower(id crypto.PublicKey, power *big.Int) (flow *big.Int, err error)

Implements Writer, but will never error

func (*Set) ChangePower

func (vs *Set) ChangePower(id crypto.PublicKey, power *big.Int) *big.Int

Add the power of a validator and returns the flow into that validator

func (*Set) Count

func (vs *Set) Count() int

func (*Set) CountNonZero

func (vs *Set) CountNonZero() int

func (*Set) Equal

func (vs *Set) Equal(vsOther *Set) bool

func (*Set) Iterate

func (vs *Set) Iterate(iter func(id crypto.Addressable, power *big.Int) (stop bool)) (stopped bool)

Iterates over validators sorted by address

func (*Set) MaybePower

func (vs *Set) MaybePower(id crypto.PublicKey) *big.Int

Returns the power of id but only if it is set

func (*Set) Power

func (vs *Set) Power(id crypto.PublicKey) *big.Int

func (*Set) String

func (vs *Set) String() string

func (*Set) Strings

func (vs *Set) Strings() string

func (*Set) TotalPower

func (vs *Set) TotalPower() *big.Int

func (*Set) Validators

func (vs *Set) Validators() []*Validator

type Validator

type Validator struct {
	Address   *github_com_hyperledger_burrow_crypto.Address `protobuf:"bytes,1,opt,name=Address,proto3,customtype=github.com/hyperledger/burrow/crypto.Address" json:"Address,omitempty"`
	PublicKey crypto.PublicKey                              `protobuf:"bytes,2,opt,name=PublicKey" json:"PublicKey"`
	Power     uint64                                        `protobuf:"varint,3,opt,name=Power,proto3" json:"Power,omitempty"`
}

func FromAccount

func FromAccount(acc acm.Account, power uint64) Validator

func (*Validator) Descriptor

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

func (Validator) FillAddress

func (v Validator) FillAddress()

func (*Validator) GetPower

func (m *Validator) GetPower() uint64

func (*Validator) GetPublicKey

func (m *Validator) GetPublicKey() crypto.PublicKey

func (*Validator) Marshal

func (m *Validator) Marshal() (dAtA []byte, err error)

func (*Validator) MarshalTo

func (m *Validator) MarshalTo(dAtA []byte) (int, error)

func (*Validator) ProtoMessage

func (*Validator) ProtoMessage()

func (*Validator) Reset

func (m *Validator) Reset()

func (*Validator) Size

func (m *Validator) Size() (n int)

func (Validator) String

func (v Validator) String() string

func (*Validator) Unmarshal

func (m *Validator) Unmarshal(dAtA []byte) error

func (*Validator) XXX_MessageName

func (*Validator) XXX_MessageName() string

type Writer

type Writer interface {
	AlterPower(id crypto.PublicKey, power *big.Int) (flow *big.Int, err error)
}

type WriterFunc

type WriterFunc func(id crypto.PublicKey, power *big.Int) (flow *big.Int, err error)

func SyncWriter

func SyncWriter(locker sync.Locker, writerFunc WriterFunc) WriterFunc

func (WriterFunc) AlterPower

func (wf WriterFunc) AlterPower(id crypto.PublicKey, power *big.Int) (flow *big.Int, err error)

Jump to

Keyboard shortcuts

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