mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +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 mux = stack.EventMux()
|
||||||
var sub = mux.Subscribe(downloader.BlockEvent{})
|
var sub = mux.Subscribe(downloader.DoneEvent{})
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case headers := <-sub.Chan():
|
case headers := <-sub.Chan():
|
||||||
if headers == nil {
|
if headers == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info("Synchronisation completed, checking", "check", headers)
|
if 600 >= time.Now().Unix()-headers.Time.Unix() {
|
||||||
time.Sleep(exitWhenSynced)
|
time.Sleep(exitWhenSynced)
|
||||||
stack.Stop()
|
stack.Stop()
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -414,7 +414,8 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td *big.I
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.mux.Post(FailedEvent{err})
|
d.mux.Post(FailedEvent{err})
|
||||||
} else {
|
} else {
|
||||||
d.mux.Post(DoneEvent{})
|
latest := d.blockchain.CurrentHeader()
|
||||||
|
d.mux.Post(DoneEvent{latest})
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if p.version < 62 {
|
if p.version < 62 {
|
||||||
|
|
@ -1562,9 +1563,6 @@ 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 600 > time.Now().Unix()-latest.Time.Int64() {
|
|
||||||
d.mux.Post(BlockEvent{})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,10 @@
|
||||||
|
|
||||||
package downloader
|
package downloader
|
||||||
|
|
||||||
type DoneEvent struct{}
|
import (
|
||||||
type BlockEvent struct{}
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DoneEvent struct{ *types.Header }
|
||||||
type StartEvent struct{}
|
type StartEvent struct{}
|
||||||
type FailedEvent struct{ Err error }
|
type FailedEvent struct{ Err error }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue