consensus

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2018 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsProducerAddressValid

func IsProducerAddressValid(producer string) bool

Types

type BlockProducer added in v0.1.2

type BlockProducer interface {
	// Setup tells the producer to give rewards to beneficiaryAddr and return the new block through newBlockCh
	Setup(bc *core.Blockchain, beneficiaryAddr string, newBlockCh chan *NewBlock)

	SetPrivateKey(key string)

	// Beneficiary returns the address which receives rewards
	Beneficiary() string

	// SetRequirement defines the requirement that a new block must fulfill
	SetRequirement(requirement Requirement)

	Start()

	Stop()

	IsIdle() bool
}

type DPOS added in v0.1.2

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

func NewDPOS added in v0.1.2

func NewDPOS() *DPOS

func (*DPOS) AddProducer added in v0.1.2

func (dpos *DPOS) AddProducer(producer string) error

func (*DPOS) GetBlockChain added in v0.1.2

func (dpos *DPOS) GetBlockChain() *core.Blockchain

func (*DPOS) GetDynasty added in v0.1.2

func (dpos *DPOS) GetDynasty() *Dynasty

func (*DPOS) GetProducers added in v0.1.2

func (dpos *DPOS) GetProducers() []string

func (*DPOS) GetSlot added in v0.1.2

func (dpos *DPOS) GetSlot() *lru.Cache

func (*DPOS) IsProducingBlock added in v0.1.2

func (dpos *DPOS) IsProducingBlock() bool

func (*DPOS) SetDynasty added in v0.1.2

func (dpos *DPOS) SetDynasty(dynasty *Dynasty)

func (*DPOS) SetKey added in v0.1.2

func (dpos *DPOS) SetKey(key string)

func (*DPOS) Setup added in v0.1.2

func (dpos *DPOS) Setup(node core.NetService, cbAddr string)

func (*DPOS) Start added in v0.1.2

func (dpos *DPOS) Start()

func (*DPOS) Stop added in v0.1.2

func (dpos *DPOS) Stop()

func (*DPOS) Validate added in v0.1.2

func (dpos *DPOS) Validate(block *core.Block) bool

Validate checks that the block fulfills the dpos requirement and accepts the block in the time slot

type Delegate added in v0.1.2

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

func NewDelegate added in v0.1.2

func NewDelegate() *Delegate

func (*Delegate) Beneficiary added in v0.1.2

func (d *Delegate) Beneficiary() string

func (*Delegate) IsIdle added in v0.1.2

func (d *Delegate) IsIdle() bool

func (*Delegate) SetPrivateKey added in v0.1.2

func (d *Delegate) SetPrivateKey(key string)

func (*Delegate) SetRequirement added in v0.1.2

func (d *Delegate) SetRequirement(requirement Requirement)

func (*Delegate) Setup added in v0.1.2

func (d *Delegate) Setup(bc *core.Blockchain, beneficiaryAddr string, newBlockCh chan *NewBlock)

func (*Delegate) Start added in v0.1.2

func (d *Delegate) Start()

func (*Delegate) Stop added in v0.1.2

func (d *Delegate) Stop()

type Dynasty

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

func NewDynasty

func NewDynasty(producers []string, maxProducers, timeBetweenBlk int) *Dynasty

func NewDynastyWithConfigProducers added in v0.1.2

func NewDynastyWithConfigProducers(producers []string, maxProducers int) *Dynasty

New dynasty from config file

func (*Dynasty) AddMultipleProducers

func (dynasty *Dynasty) AddMultipleProducers(producers []string)

func (*Dynasty) AddProducer

func (dynasty *Dynasty) AddProducer(producer string) error

func (*Dynasty) GetDynastyTime added in v0.1.2

func (dynasty *Dynasty) GetDynastyTime() int

func (*Dynasty) GetProducerIndex

func (dynasty *Dynasty) GetProducerIndex(producer string) int

find the index of the producer. If not found, return -1

func (*Dynasty) GetProducers added in v0.1.2

func (dynasty *Dynasty) GetProducers() []string

func (*Dynasty) IsMyTurn

func (dynasty *Dynasty) IsMyTurn(producer string, now int64) bool

func (*Dynasty) ProducerAtATime

func (dynasty *Dynasty) ProducerAtATime(time int64) string

func (*Dynasty) SetMaxProducers

func (dynasty *Dynasty) SetMaxProducers(maxProducers int)

func (*Dynasty) SetTimeBetweenBlk

func (dynasty *Dynasty) SetTimeBetweenBlk(timeBetweenBlk int)

type Miner

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

func NewMiner

func NewMiner() *Miner

func (*Miner) Beneficiary added in v0.1.2

func (miner *Miner) Beneficiary() string

func (*Miner) IsIdle added in v0.1.2

func (miner *Miner) IsIdle() bool

func (*Miner) SetPrivateKey added in v0.1.2

func (miner *Miner) SetPrivateKey(key string)

func (*Miner) SetRequirement added in v0.1.2

func (miner *Miner) SetRequirement(requirement Requirement)

func (*Miner) Setup

func (miner *Miner) Setup(bc *core.Blockchain, beneficiaryAddr string, newBlockCh chan *NewBlock)

func (*Miner) Start

func (miner *Miner) Start()

func (*Miner) Stop

func (miner *Miner) Stop()

type NewBlock added in v0.1.2

type NewBlock struct {
	*core.Block
	IsValid bool
}

type ProofOfWork

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

func NewProofOfWork

func NewProofOfWork() *ProofOfWork

func (*ProofOfWork) AddProducer added in v0.1.2

func (pow *ProofOfWork) AddProducer(producer string) error

func (*ProofOfWork) GetProducers added in v0.1.2

func (pow *ProofOfWork) GetProducers() []string

func (*ProofOfWork) IsProducingBlock added in v0.1.2

func (pow *ProofOfWork) IsProducingBlock() bool

func (*ProofOfWork) SetKey added in v0.1.2

func (pow *ProofOfWork) SetKey(key string)

func (*ProofOfWork) SetTargetBit

func (pow *ProofOfWork) SetTargetBit(bit int)

func (*ProofOfWork) Setup

func (pow *ProofOfWork) Setup(node core.NetService, cbAddr string)

func (*ProofOfWork) Start

func (pow *ProofOfWork) Start()

func (*ProofOfWork) Stop

func (pow *ProofOfWork) Stop()

func (*ProofOfWork) Validate

func (pow *ProofOfWork) Validate(block *core.Block) bool

type Requirement added in v0.1.2

type Requirement func(block *core.Block) bool

Requirement inspects the given block and returns true if it fulfills the requirement

type State

type State int

Jump to

Keyboard shortcuts

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