mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
consensus, core: minor comment fixups
This commit is contained in:
parent
993267d311
commit
f03ea29113
3 changed files with 12 additions and 3 deletions
|
|
@ -652,7 +652,9 @@ func (c *Clique) Seal(chain consensus.ChainReader, block *types.Block, stop <-ch
|
||||||
return block.WithSeal(header), nil
|
return block.WithSeal(header), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have.
|
// CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty
|
||||||
|
// that a new block should have based on the previous blocks in the chain and the
|
||||||
|
// current signer.
|
||||||
func (c *Clique) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int {
|
func (c *Clique) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int {
|
||||||
snap, err := c.snapshot(chain, parent.Number.Uint64(), parent.Hash(), nil)
|
snap, err := c.snapshot(chain, parent.Number.Uint64(), parent.Hash(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -661,7 +663,9 @@ func (c *Clique) CalcDifficulty(chain consensus.ChainReader, time uint64, parent
|
||||||
return CalcDifficulty(snap, c.signer)
|
return CalcDifficulty(snap, c.signer)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CalcDifficulty returns block difficulty according to local signer is the inturn signer or not.
|
// CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty
|
||||||
|
// that a new block should have based on the previous blocks in the chain and the
|
||||||
|
// current signer.
|
||||||
func CalcDifficulty(snap *Snapshot, signer common.Address) *big.Int {
|
func CalcDifficulty(snap *Snapshot, signer common.Address) *big.Int {
|
||||||
if snap.inturn(snap.Number+1, signer) {
|
if snap.inturn(snap.Number+1, signer) {
|
||||||
return new(big.Int).Set(diffInTurn)
|
return new(big.Int).Set(diffInTurn)
|
||||||
|
|
|
||||||
|
|
@ -291,7 +291,9 @@ func (ethash *Ethash) CalcDifficulty(chain consensus.ChainReader, time uint64, p
|
||||||
return CalcDifficulty(chain.Config(), time, parent)
|
return CalcDifficulty(chain.Config(), time, parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CalcDifficulty returns block difficulty according to the parent block's time and difficulty.
|
// CalcDifficulty is the difficulty adjustment algorithm. It returns
|
||||||
|
// the difficulty that a new block should have when created at time
|
||||||
|
// given the parent block's time and difficulty.
|
||||||
func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int {
|
func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int {
|
||||||
next := new(big.Int).Add(parent.Number, big1)
|
next := new(big.Int).Add(parent.Number, big1)
|
||||||
switch {
|
switch {
|
||||||
|
|
|
||||||
|
|
@ -164,8 +164,11 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
|
||||||
}
|
}
|
||||||
blocks, receipts := make(types.Blocks, n), make([]types.Receipts, n)
|
blocks, receipts := make(types.Blocks, n), make([]types.Receipts, n)
|
||||||
genblock := func(i int, parent *types.Block, statedb *state.StateDB) (*types.Block, types.Receipts) {
|
genblock := func(i int, parent *types.Block, statedb *state.StateDB) (*types.Block, types.Receipts) {
|
||||||
|
// TODO(karalabe): This is needed for clique, which depends on multiple blocks.
|
||||||
|
// It's nonetheless ugly to spin up a blockchain here. Get rid of this somehow.
|
||||||
blockchain, _ := NewBlockChain(db, config, engine, vm.Config{})
|
blockchain, _ := NewBlockChain(db, config, engine, vm.Config{})
|
||||||
defer blockchain.Stop()
|
defer blockchain.Stop()
|
||||||
|
|
||||||
b := &BlockGen{i: i, parent: parent, chain: blocks, chainReader: blockchain, statedb: statedb, config: config, engine: engine}
|
b := &BlockGen{i: i, parent: parent, chain: blocks, chainReader: blockchain, statedb: statedb, config: config, engine: engine}
|
||||||
b.header = makeHeader(b.chainReader, parent, statedb, b.engine)
|
b.header = makeHeader(b.chainReader, parent, statedb, b.engine)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue