server

package
v0.0.0-...-4097cb8 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: LGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainVer

func ContainVer(addres []common.Address, ver common.Address) (int, bool)

func NewServer

func NewServer(config *BFT.BFTConfig, privateKey *ecdsa.PrivateKey, db database.Database) consensus.Bft

NeServer new a server for bft backend. This server as the engine as in the POW Algorithm

Types

type API

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

func (*API) Candidates

func (api *API) Candidates() map[common.Address]bool

Candidates returns the current candidates the node tries to uphold and vote on.

func (*API) Discard

func (api *API) Discard(address common.Address)

Discard drops a currently running candidate, stopping the verifier from casting further votes (either for or against).

func (*API) GetSnapshot

func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error)

define all apis here

func (*API) GetSnapshotAtHash

func (api *API) GetSnapshotAtHash(hash common.Hash) (*Snapshot, error)

GetSnapshotAtHash retrieves the state snapshot at a given block.

func (*API) GetVerifiers

func (api *API) GetVerifiers(number *rpc.BlockNumber) ([]common.Address, error)

GetVerifiers retrieves the list of authorized verifiers at the specified block.

func (*API) GetVerifiersAtHash

func (api *API) GetVerifiersAtHash(hash common.Hash) ([]common.Address, error)

GetVerifiersAtHash retrieves the state snapshot at a given block.

func (*API) Propose

func (api *API) Propose(address common.Address, auth bool)

Propose injects a new authorization candidate that the verifier will attempt to push through.

type Snapshot

type Snapshot struct {
	Epoch  uint64                   // The number of blocks after which to checkpoint and reset the pending votes
	Height uint64                   // Block height where the snapshot was created
	Hash   common.Hash              // Block hash where the snapshot was created
	Votes  []*Vote                  // List of votes cast in chronological order
	Tally  map[common.Address]Tally // Current vote tally to avoid recalculating
	VerSet bft.VerifierSet          // Set of authorized verifiers at this moment
}

Snapshot is the state of the authorization voting at a given point in time.

func (*Snapshot) MarshalJSON

func (s *Snapshot) MarshalJSON() ([]byte, error)

Marshal to a json byte array

func (*Snapshot) UnmarshalJSON

func (s *Snapshot) UnmarshalJSON(b []byte) error

Unmarshal from a json byte array

type Tally

type Tally struct {
	Authorize bool `json:"authorize"` // Whether the vote it about authorizing or kicking someone
	Votes     int  `json:"votes"`     // Height of votes until now wanting to pass the proposal
}

Tally is a simple vote tally to keep the current score of votes. Votes that go against the proposal aren't counted since it's equivalent to not voting.

type Vote

type Vote struct {
	Verifier  common.Address `json:"verifier"`  // Authorized verifier that cast this vote
	Block     uint64         `json:"block"`     // Block number the vote was cast in (expire old votes)
	Address   common.Address `json:"address"`   // Account being voted on to change its authorization
	Authorize bool           `json:"authorize"` // Whether to authorize or deauthorize the voted account
}

Vote represents a single vote that an authorized verifier made to modify the list of authorizations.

Jump to

Keyboard shortcuts

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