mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
cmd/geth, eth/down: Updated code to use header time stamp
This commit is contained in:
parent
1a808aecd7
commit
1008f2559b
3 changed files with 18 additions and 8 deletions
|
|
@ -32,8 +32,8 @@ import (
|
|||
"github.com/ethereum/go-ethereum/accounts/keystore"
|
||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||
"github.com/ethereum/go-ethereum/console"
|
||||
"github.com/ethereum/go-ethereum/eth"
|
||||
"github.com/ethereum/go-ethereum/eth/downloader"
|
||||
"github.com/ethereum/go-ethereum/eth"
|
||||
"github.com/ethereum/go-ethereum/ethclient"
|
||||
"github.com/ethereum/go-ethereum/internal/debug"
|
||||
"github.com/ethereum/go-ethereum/les"
|
||||
|
|
@ -346,11 +346,19 @@ func startNode(ctx *cli.Context, stack *node.Node) {
|
|||
}
|
||||
}
|
||||
var mux = stack.EventMux()
|
||||
var sub = mux.Subscribe(downloader.DoneEvent{})
|
||||
<-sub.Chan()
|
||||
log.Info("Synchronisation completed, exitting", "countdown", exitWhenSynced)
|
||||
time.Sleep(exitWhenSynced)
|
||||
stack.Stop()
|
||||
var sub = mux.Subscribe(downloader.BlockEvent{})
|
||||
for {
|
||||
select {
|
||||
case headers := <-sub.Chan():
|
||||
if headers == nil {
|
||||
return
|
||||
}
|
||||
log.Info("Synchronisation completed, checking", "check", headers)
|
||||
time.Sleep(exitWhenSynced)
|
||||
stack.Stop()
|
||||
default:
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1347,7 +1347,6 @@ func (d *Downloader) processHeaders(origin uint64, pivot uint64, td *big.Int) er
|
|||
}
|
||||
// Otherwise split the chunk of headers into batches and process them
|
||||
gotHeaders = true
|
||||
|
||||
for len(headers) > 0 {
|
||||
// Terminate if something failed in between processing chunks
|
||||
select {
|
||||
|
|
@ -1410,7 +1409,6 @@ func (d *Downloader) processHeaders(origin uint64, pivot uint64, td *big.Int) er
|
|||
headers = headers[limit:]
|
||||
origin += uint64(limit)
|
||||
}
|
||||
|
||||
// Update the highest block number we know if a higher one is found.
|
||||
d.syncStatsLock.Lock()
|
||||
if d.syncStatsChainHeight < origin {
|
||||
|
|
@ -1564,6 +1562,9 @@ func (d *Downloader) processFastSyncContent(latest *types.Header) error {
|
|||
if err := d.importBlockResults(afterP); err != nil {
|
||||
return err
|
||||
}
|
||||
if 4400000 > time.Now().Unix()-latest.Time.Int64() {
|
||||
d.mux.Post(BlockEvent{})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,5 +17,6 @@
|
|||
package downloader
|
||||
|
||||
type DoneEvent struct{}
|
||||
type BlockEvent struct{}
|
||||
type StartEvent struct{}
|
||||
type FailedEvent struct{ Err error }
|
||||
|
|
|
|||
Loading…
Reference in a new issue