mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
Merge pull request #178 from nguyenbatam/remove_delay_when_mine_newblock
remove delay when mining new block
This commit is contained in:
commit
4986c317f4
5 changed files with 8 additions and 20 deletions
|
|
@ -24,19 +24,18 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
"strings"
|
||||||
"gopkg.in/urfave/cli.v1"
|
"gopkg.in/urfave/cli.v1"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
"github.com/ethereum/go-ethereum/dashboard"
|
"github.com/ethereum/go-ethereum/dashboard"
|
||||||
"github.com/ethereum/go-ethereum/eth"
|
"github.com/ethereum/go-ethereum/eth"
|
||||||
"github.com/ethereum/go-ethereum/internal/debug"
|
"github.com/ethereum/go-ethereum/internal/debug"
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
|
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
|
||||||
"github.com/naoina/toml"
|
"github.com/naoina/toml"
|
||||||
"strings"
|
|
||||||
"github.com/ethereum/go-ethereum/log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
||||||
|
|
@ -653,7 +653,7 @@ func setListenAddress(ctx *cli.Context, cfg *p2p.Config) {
|
||||||
// setNAT creates a port mapper from command line flags.
|
// setNAT creates a port mapper from command line flags.
|
||||||
func setNAT(ctx *cli.Context, cfg *p2p.Config) {
|
func setNAT(ctx *cli.Context, cfg *p2p.Config) {
|
||||||
if ctx.GlobalIsSet(NATFlag.Name) {
|
if ctx.GlobalIsSet(NATFlag.Name) {
|
||||||
log.Info("NAT is setted","value",ctx.GlobalString(NATFlag.Name))
|
log.Info("NAT is setted", "value", ctx.GlobalString(NATFlag.Name))
|
||||||
natif, err := nat.Parse(ctx.GlobalString(NATFlag.Name))
|
natif, err := nat.Parse(ctx.GlobalString(NATFlag.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fatalf("Option %s: %v", NATFlag.Name, err)
|
Fatalf("Option %s: %v", NATFlag.Name, err)
|
||||||
|
|
|
||||||
|
|
@ -769,21 +769,10 @@ func (c *Posv) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Sweet, the protocol permits us to sign the block, wait for our time
|
|
||||||
delay := time.Unix(header.Time.Int64(), 0).Sub(time.Now()) // nolint: gosimple
|
|
||||||
if header.Difficulty.Cmp(diffNoTurn) == 0 {
|
|
||||||
// It's not our turn explicitly to sign, delay it a bit
|
|
||||||
wiggle := time.Duration(len(masternodes)/2+1) * wiggleTime
|
|
||||||
delay += time.Duration(rand.Int63n(int64(wiggle)))
|
|
||||||
|
|
||||||
log.Trace("Out-of-turn signing requested", "wiggle", common.PrettyDuration(wiggle))
|
|
||||||
}
|
|
||||||
log.Trace("Waiting for slot to sign and propagate", "delay", common.PrettyDuration(delay))
|
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-stop:
|
case <-stop:
|
||||||
return nil, nil
|
return nil, nil
|
||||||
case <-time.After(delay):
|
default:
|
||||||
}
|
}
|
||||||
// Sign all the things!
|
// Sign all the things!
|
||||||
sighash, err := signFn(accounts.Account{Address: signer}, sigHash(header).Bytes())
|
sighash, err := signFn(accounts.Account{Address: signer}, sigHash(header).Bytes())
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,10 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
mrand "math/rand"
|
mrand "math/rand"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
"sort"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
@ -1402,7 +1402,7 @@ func (bc *BlockChain) PostChainEvents(events []interface{}, logs []*types.Log) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bc *BlockChain) update() {
|
func (bc *BlockChain) update() {
|
||||||
futureTimer := time.NewTicker(5 * time.Second)
|
futureTimer := time.NewTicker(10 * time.Millisecond)
|
||||||
defer futureTimer.Stop()
|
defer futureTimer.Stop()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
|
|
||||||
|
|
@ -1221,9 +1221,9 @@ func submitTransaction(ctx context.Context, b Backend, tx *types.Transaction) (c
|
||||||
return common.Hash{}, err
|
return common.Hash{}, err
|
||||||
}
|
}
|
||||||
addr := crypto.CreateAddress(from, tx.Nonce())
|
addr := crypto.CreateAddress(from, tx.Nonce())
|
||||||
log.Info("Submitted contract creation", "fullhash", tx.Hash().Hex(), "contract", addr.Hex())
|
log.Trace("Submitted contract creation", "fullhash", tx.Hash().Hex(), "contract", addr.Hex())
|
||||||
} else {
|
} else {
|
||||||
log.Info("Submitted transaction", "fullhash", tx.Hash().Hex(), "recipient", tx.To())
|
log.Trace("Submitted transaction", "fullhash", tx.Hash().Hex(), "recipient", tx.To())
|
||||||
}
|
}
|
||||||
return tx.Hash(), nil
|
return tx.Hash(), nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue