mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
cmd/geth, eth/downloader: Updated downloading event to pass latest header
This commit is contained in:
parent
965da6938a
commit
f761250f23
3 changed files with 12 additions and 10 deletions
|
|
@ -346,16 +346,17 @@ func startNode(ctx *cli.Context, stack *node.Node) {
|
|||
}
|
||||
}
|
||||
var mux = stack.EventMux()
|
||||
var sub = mux.Subscribe(downloader.BlockEvent{})
|
||||
var sub = mux.Subscribe(downloader.DoneEvent{})
|
||||
for {
|
||||
select {
|
||||
case headers := <-sub.Chan():
|
||||
if headers == nil {
|
||||
return
|
||||
}
|
||||
log.Info("Synchronisation completed, checking", "check", headers)
|
||||
time.Sleep(exitWhenSynced)
|
||||
stack.Stop()
|
||||
if 600 >= time.Now().Unix()-headers.Time.Unix() {
|
||||
time.Sleep(exitWhenSynced)
|
||||
stack.Stop()
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -414,7 +414,8 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td *big.I
|
|||
if err != nil {
|
||||
d.mux.Post(FailedEvent{err})
|
||||
} else {
|
||||
d.mux.Post(DoneEvent{})
|
||||
latest := d.blockchain.CurrentHeader()
|
||||
d.mux.Post(DoneEvent{latest})
|
||||
}
|
||||
}()
|
||||
if p.version < 62 {
|
||||
|
|
@ -1562,9 +1563,6 @@ func (d *Downloader) processFastSyncContent(latest *types.Header) error {
|
|||
if err := d.importBlockResults(afterP); err != nil {
|
||||
return err
|
||||
}
|
||||
if 600 > time.Now().Unix()-latest.Time.Int64() {
|
||||
d.mux.Post(BlockEvent{})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,10 @@
|
|||
|
||||
package downloader
|
||||
|
||||
type DoneEvent struct{}
|
||||
type BlockEvent struct{}
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
)
|
||||
|
||||
type DoneEvent struct{ *types.Header }
|
||||
type StartEvent struct{}
|
||||
type FailedEvent struct{ Err error }
|
||||
|
|
|
|||
Loading…
Reference in a new issue