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