solo

package
v0.0.0-...-a173fca Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: LGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MODULENAME = "solo"
)

Variables

View Source
var (
	ErrSignBlock     = errors.New("sign block error")
	ErrWalletNotOpen = errors.New("wallet is close")
	ErrCheckSigFail  = errors.New("verify sig in block fail")
	ErrGasUsed       = errors.New("gasused not match")
)
View Source
var (
	EnableSoloConsensusFlag = cli.BoolFlag{
		Name:  "enable",
		Usage: "enable solo consensus",
	}
)

Functions

func AccumulateRewards

func AccumulateRewards(pubkey *secp256k1.PublicKey, trieStore store.StoreInterface, totalGasBalance *big.Int, height uint64) error

AccumulateRewards credits,The leader gets half of the reward and other ,Other participants get the average of the other half

Types

type SoloConfig

type SoloConfig struct {
	MyPk           *secp256k1.PublicKey `json:"mypk"`
	StartMiner     bool                 `json:"startMiner"`
	BlockInterval  int                  `json:"blockInterval"`
	ChangeInterval uint64               `json:"changeInterval"`
}

type SoloConsensus

type SoloConsensus struct {
	CoinBase crypto.CommonAddress
	PrivKey  *secp256k1.PrivateKey
	Pubkey   *secp256k1.PublicKey

	ChainService chain.ChainServiceInterface
	DbService    *database.DatabaseService
	// contains filtered or unexported fields
}

func NewSoloConsensus

func NewSoloConsensus(
	chainService chain.ChainServiceInterface,
	blockGenerator blockmgr.IBlockBlockGenerator,
	myPk *secp256k1.PublicKey,
	dbService *database.DatabaseService,
	config *SoloConfig) *SoloConsensus

func (*SoloConsensus) ReceiveMsg

func (soloConsensus *SoloConsensus) ReceiveMsg(peer *consensusTypes.PeerInfo, t uint64, buf []byte)

func (*SoloConsensus) Run

func (soloConsensus *SoloConsensus) Run(privKey *secp256k1.PrivateKey) (*types.Block, error)

type SoloConsensusService

type SoloConsensusService struct {
	P2pServer        p2pService.P2P                       `service:"p2p"`
	ChainService     chainService.ChainServiceInterface   `service:"chain"`
	BroadCastor      blockMgrService.ISendMessage         `service:"blockmgr"`
	BlockMgrNotifier blockMgrService.IBlockNotify         `service:"blockmgr"`
	BlockGenerator   blockMgrService.IBlockBlockGenerator `service:"blockmgr"`
	DatabaseService  *database.DatabaseService            `service:"database"`
	WalletService    *accountService.AccountService       `service:"accounts"`

	Config *SoloConfig

	ConsensusEngine consensusTypes.IConsensusEngine
	Miner           *secp256k1.PrivateKey
	// contains filtered or unexported fields
}

func (*SoloConsensusService) Api

func (soloConsensusService *SoloConsensusService) Api() []app.API

func (*SoloConsensusService) CommandFlags

func (soloConsensusService *SoloConsensusService) CommandFlags() ([]cli.Command, []cli.Flag)

func (*SoloConsensusService) DefaultConfig

func (soloConsensusService *SoloConsensusService) DefaultConfig(netType params.NetType) *SoloConfig

func (*SoloConsensusService) Init

func (soloConsensusService *SoloConsensusService) Init(executeContext *app.ExecuteContext) error

func (*SoloConsensusService) Name

func (soloConsensusService *SoloConsensusService) Name() string

func (*SoloConsensusService) Start

func (soloConsensusService *SoloConsensusService) Start(executeContext *app.ExecuteContext) error

func (*SoloConsensusService) Stop

func (soloConsensusService *SoloConsensusService) Stop(executeContext *app.ExecuteContext) error

type SoloValidator

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

func NewSoloValidator

func NewSoloValidator(pubkey *secp256k1.PublicKey) *SoloValidator

func (*SoloValidator) ExecuteBlock

func (soloValidator *SoloValidator) ExecuteBlock(context *block.BlockExecuteContext) error

func (*SoloValidator) VerifyBody

func (soloValidator *SoloValidator) VerifyBody(block *types.Block) error

func (*SoloValidator) VerifyHeader

func (soloValidator *SoloValidator) VerifyHeader(header, parent *types.BlockHeader) error

Jump to

Keyboard shortcuts

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