evidence

package
v0.0.0-...-f47aca1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EvidenceChannel = byte(0x38)
)

Variables

This section is empty.

Functions

func RegisterMessages

func RegisterMessages(cdc *amino.Codec)

func RegisterMockEvidences

func RegisterMockEvidences()

For testing purposes only

Types

type ErrEvidenceAlreadyStored

type ErrEvidenceAlreadyStored struct{}

ErrEvidenceAlreadyStored indicates that the evidence has already been stored in the evidence db

func (ErrEvidenceAlreadyStored) Error

func (e ErrEvidenceAlreadyStored) Error() string

type ErrInvalidEvidence

type ErrInvalidEvidence struct {
	Reason error
}

ErrInvalidEvidence returns when evidence failed to validate

func (ErrInvalidEvidence) Error

func (e ErrInvalidEvidence) Error() string

type Info

type Info struct {
	Committed bool
	Priority  int64
	Evidence  types.Evidence
}

type ListMessage

type ListMessage struct {
	Evidence []types.Evidence
}

ListMessage 证据集合.

func (*ListMessage) String

func (m *ListMessage) String() string

String returns a string representation of the ListMessage.

func (*ListMessage) ValidateBasic

func (m *ListMessage) ValidateBasic() error

ValidateBasic performs basic validation.

type Message

type Message interface {
	ValidateBasic() error
}

Message is a message sent or received by the Reactor.

type PeerState

type PeerState interface {
	GetHeight() int64
}

PeerState describes the state of a peer.

type Pool

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

Pool maintains a pool of valid evidence in an Store.

func NewPool

func NewPool(stateDB, evidenceDB dbm.DB) *Pool

func (*Pool) AddEvidence

func (evpool *Pool) AddEvidence(evidence types.Evidence) error

AddEvidence checks the evidence is valid and adds it to the pool.

func (*Pool) EvidenceFront

func (evpool *Pool) EvidenceFront() *clist.CElement

func (*Pool) EvidenceWaitChan

func (evpool *Pool) EvidenceWaitChan() <-chan struct{}

func (*Pool) IsCommitted

func (evpool *Pool) IsCommitted(evidence types.Evidence) bool

IsCommitted returns true if we have already seen this exact evidence and it is already marked as committed.

func (*Pool) MarkEvidenceAsCommitted

func (evpool *Pool) MarkEvidenceAsCommitted(height int64, lastBlockTime time.Time, evidence []types.Evidence)

MarkEvidenceAsCommitted marks all the evidence as committed and removes it from the queue.

func (*Pool) PendingEvidence

func (evpool *Pool) PendingEvidence(maxNum int64) []types.Evidence

PendingEvidence 返回maxNum个未提交的证据. -1返回全部

func (*Pool) PriorityEvidence

func (evpool *Pool) PriorityEvidence() []types.Evidence

PriorityEvidence 返回按高到低优先级排序的证据。

func (*Pool) SetLogger

func (evpool *Pool) SetLogger(l log.Logger)

SetLogger sets the Logger.

func (*Pool) State

func (evpool *Pool) State() sm.State

State 返回当前证据池的状态.

func (*Pool) Update

func (evpool *Pool) Update(block *types.Block, state sm.State)

Update loads the latest

type Reactor

type Reactor struct {
	p2p.BaseReactor
	// contains filtered or unexported fields
}

Reactor handles evpool evidence broadcasting amongst peers.

func NewReactor

func NewReactor(evpool *Pool) *Reactor

NewReactor returns a new Reactor with the given config and evpool.

func (*Reactor) AddPeer

func (evR *Reactor) AddPeer(peer p2p.Peer)

AddPeer implements Reactor.

func (*Reactor) GetChannels

func (evR *Reactor) GetChannels() []*p2p.ChannelDescriptor

GetChannels implements Reactor. It returns the list of channels for this reactor.

func (*Reactor) Receive

func (evR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)

Receive implements Reactor. It adds any received evidence to the evpool.

func (*Reactor) SetEventBus

func (evR *Reactor) SetEventBus(b *types.EventBus)

SetEventBus implements events.Eventable.

func (*Reactor) SetLogger

func (evR *Reactor) SetLogger(l log.Logger)

SetLogger sets the Logger on the reactor and the underlying Evidence.

type Store

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

Store 用于存储我们看见的所有证据,包括已经提交的证据、已经验证但是没有广播的证据 和已经广播但是没有提交的证据。

func NewStore

func NewStore(db dbm.DB) *Store

func (*Store) AddNewEvidence

func (store *Store) AddNewEvidence(evidence types.Evidence, priority int64) (bool, error)

AddNewEvidence 把证据保存到数据库。如果证据已经存在,返回false。

func (*Store) GetInfo

func (store *Store) GetInfo(height int64, hash []byte) Info

GetInfo 根据给定的高度和哈希获取Info。如果没有找到,Info.Evidence为空

func (*Store) Has

func (store *Store) Has(evidence types.Evidence) bool

Has 检查这个证据是否被保存

func (*Store) MarkEvidenceAsBroadcasted

func (store *Store) MarkEvidenceAsBroadcasted(evidence types.Evidence)

MarkEvidenceAsBroadcasted 把证据从Outqueued中删除

func (*Store) MarkEvidenceAsCommitted

func (store *Store) MarkEvidenceAsCommitted(evidence types.Evidence)

MarkEvidenceAsCommitted removes evidence from pending and outqueue and sets the state to committed.

func (*Store) PendingEvidence

func (store *Store) PendingEvidence(maxNum int64) (evidence []types.Evidence)

PendingEvidence 返回maxNum个已知,但是未提交的证据。 如果maxNum为-1,返回所有证据。

func (*Store) PriorityEvidence

func (store *Store) PriorityEvidence() (evidence []types.Evidence)

PriorityEvidence returns the evidence from the outqueue, sorted by highest priority.

Jump to

Keyboard shortcuts

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