backend

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2019 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Copyright 2019 The go-smilo Authors Copyright 2017 The go-ethereum Authors This file is part of the go-ethereum library.

The go-ethereum library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The go-ethereum library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	NewBlockMsg = 0x07
)

Variables

This section is empty.

Functions

func AccumulateRewards

func AccumulateRewards(communityAddress string, state *state.StateDB, header *types.Header)

AccumulateRewards (override from ethash) credits the coinbase of the given block with the mining reward. The total reward consists of the static block reward and rewards for the community.

func New

func New(config *sport.Config, privateKey *ecdsa.PrivateKey, db ethdb.Database) consensus.SmiloBFT

New creates an Ethereum backend for smilobft core engine.

Types

type API

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

API is a user facing RPC API to dump smilobft state

func (*API) Discard

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

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

func (*API) GetFullnodes

func (api *API) GetFullnodes(blockNum *rpc.BlockNumber) (address []common.Address, err error)

GetFullnodes return a array of fullnodes for a block

func (*API) GetFullnodesByHash

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

GetFullnodesByHash return a array of fullnodes for a bash

func (*API) GetSnapshot

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

GetSnapshot (clique override) retrieves the state snapshot at a given block.

func (*API) GetSnapshotAtHash

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

GetSnapshotAtHash (clique override) retrieves the state snapshot at a given block.

func (*API) Proposals

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

Proposals (clique override) return a array of candidates that aim to become full-nodes (proposals)

func (*API) Propose

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

Propose (clique override) injects a new authorization candidate that the fullnode 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

	Number      uint64                   // Block number 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
	FullnodeSet sport.FullnodeSet        // Set of authorized fullnodes 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"`     // Number 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 {
	Fullnode  common.Address `json:"fullnode"`  // Authorized fullnode that cast this vote
	BlockNum  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 fullnode 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