replica

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReplicaStateDB

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

ReplicaStateDB represents a Map that can be accessed either by address or enode

func OpenReplicaStateDB

func OpenReplicaStateDB(path string) (*ReplicaStateDB, error)

OpenReplicaStateDB opens a validator enode database for storing and retrieving infos about validator enodes. If no path is given an in-memory, temporary database is constructed.

func (*ReplicaStateDB) Close

func (rsdb *ReplicaStateDB) Close() error

Close flushes and closes the database files.

func (*ReplicaStateDB) GetReplicaState

func (rsdb *ReplicaStateDB) GetReplicaState() (*replicaStateImpl, error)

func (*ReplicaStateDB) StoreReplicaState

func (rsdb *ReplicaStateDB) StoreReplicaState(rs State) error

StoreReplicaState will store the latest replica state

type ReplicaStateSummary

type ReplicaStateSummary struct {
	State                string   `json:"state"`
	IsPrimary            bool     `json:"isPrimary"`
	StartValidatingBlock *big.Int `json:"startValidatingBlock"`
	StopValidatingBlock  *big.Int `json:"stopValidatingBlock"`
}

type State

type State interface {
	// Functions exposed through to the management RPC.
	SetStartValidatingBlock(blockNumber *big.Int) error
	SetStopValidatingBlock(blockNumber *big.Int) error
	MakeReplica() error
	MakePrimary() error

	// Internal functions
	// Updates replica state given the current block undergoing consensus.
	NewChainHead(blockNumber *big.Int)
	// Closes the replica state database.
	Close() error

	// view functions
	IsPrimary() bool
	IsPrimaryForSeq(blockNumber *big.Int) bool
	Summary() *ReplicaStateSummary
}

func NewState

func NewState(isReplica bool, path string, startFn, stopFn func() error) (State, error)

NewState creates a replicaState in the given replica state and opens or creates the replica state DB at `path`.

Jump to

Keyboard shortcuts

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