mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
les: add GetCheckpoint to LES--tidy comments, rename fn
This commit is contained in:
parent
aab305de87
commit
e5efdebfdf
3 changed files with 7 additions and 11 deletions
|
|
@ -545,9 +545,7 @@ func (r *BloomRequest) Validate(db ethdb.Database, msg *Msg) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// status.im request 320
|
||||
|
||||
// For status.im request 320
|
||||
type CheckpointReq struct {
|
||||
SectionIdx uint64
|
||||
}
|
||||
|
|
@ -598,8 +596,6 @@ func (r *CheckpointRequest) Validate(db ethdb.Database, msg *Msg) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// readTraceDB stores the keys of database reads. We use this to check that received node
|
||||
// sets contain only the trie nodes necessary to make proofs pass.
|
||||
type readTraceDB struct {
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ func (p *peer) SendTxs(reqID, cost uint64, txs types.Transactions) error {
|
|||
}
|
||||
}
|
||||
|
||||
// RequestCheckpoint a checkpoint at the specified section index from a remote node.
|
||||
// RequestCheckpoint requests a checkpoint at the specified section index from a remote node.
|
||||
func (p *peer) RequestCheckpoint(reqID, cost uint64, req CheckpointReq) error {
|
||||
p.Log().Debug("Fetching checkpoint", "req", req, "p.version", p.version, "lpv1", lpv1)
|
||||
switch p.version {
|
||||
|
|
|
|||
10
les/sync.go
10
les/sync.go
|
|
@ -81,19 +81,19 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
|
|||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||
defer cancel()
|
||||
updateChtFromPeer(pm, peer, ctx)
|
||||
updateCheckpointFromPeer(pm, peer, ctx)
|
||||
pm.blockchain.(*light.LightChain).SyncCht(ctx)
|
||||
pm.downloader.Synchronise(peer.id, peer.Head(), peer.Td(), downloader.LightSync)
|
||||
}
|
||||
|
||||
// Status.im issue 320: Use GetHeaderProofs to download the latest CHT from a peer.
|
||||
func updateChtFromPeer(pm *ProtocolManager, peer *peer, ctx context.Context) {
|
||||
log.Info("Downloading latest CHT root from peer", "peer.headBlockInfo", peer.headBlockInfo())
|
||||
// Status.im issue 320: Use GetCheckpoint to download the latest checkpoint from a peer.
|
||||
func updateCheckpointFromPeer(pm *ProtocolManager, peer *peer, ctx context.Context) {
|
||||
log.Info("Downloading latest checkpoint from peer", "peer.headBlockInfo", peer.headBlockInfo())
|
||||
|
||||
// Formula from lightchain.go:SyncCht: num := cht.Number*ChtFrequency – 1
|
||||
var hbl = peer.headBlockInfo()
|
||||
var peerHeadBlockNum = hbl.Number
|
||||
log.Debug("UpdateChtFromPeer", "peerHeadBlockNum", peerHeadBlockNum)
|
||||
log.Debug("updateCheckpointFromPeer", "peerHeadBlockNum", peerHeadBlockNum)
|
||||
|
||||
var sectionIdx uint64 = ((peerHeadBlockNum + 1) / light.ChtFrequency) - 1
|
||||
log.Debug("Retrieving checkpoint with: ", "sectionIdx", sectionIdx)
|
||||
|
|
|
|||
Loading…
Reference in a new issue