Skip to content

Commit 83d1657

Browse files
zsfelfoldifjl
authored andcommitted
les: fix les/1 CHT compatibility issue (#15692)
1 parent 9d06026 commit 83d1657

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

les/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,8 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
846846
}
847847

848848
if header := pm.blockchain.GetHeaderByNumber(req.BlockNum); header != nil {
849-
sectionHead := core.GetCanonicalHash(pm.chainDb, (req.ChtNum+1)*light.ChtV1Frequency-1)
850-
if root := light.GetChtRoot(pm.chainDb, req.ChtNum, sectionHead); root != (common.Hash{}) {
849+
sectionHead := core.GetCanonicalHash(pm.chainDb, req.ChtNum*light.ChtV1Frequency-1)
850+
if root := light.GetChtRoot(pm.chainDb, req.ChtNum-1, sectionHead); root != (common.Hash{}) {
851851
if tr, _ := trie.New(root, trieDb); tr != nil {
852852
var encNumber [8]byte
853853
binary.BigEndian.PutUint64(encNumber[:], req.BlockNum)

les/peer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func (p *peer) RequestHelperTrieProofs(reqID, cost uint64, reqs []HelperTrieReq)
296296
}
297297
blockNum := binary.BigEndian.Uint64(req.Key)
298298
// convert HelperTrie request to old CHT request
299-
reqsV1[i] = ChtReq{ChtNum: (req.TrieIdx+1)*(light.ChtFrequency/light.ChtV1Frequency) - 1, BlockNum: blockNum, FromLevel: req.FromLevel}
299+
reqsV1[i] = ChtReq{ChtNum: (req.TrieIdx + 1) * (light.ChtFrequency / light.ChtV1Frequency), BlockNum: blockNum, FromLevel: req.FromLevel}
300300
}
301301
return sendRequest(p.rw, GetHeaderProofsMsg, reqID, cost, reqsV1)
302302
case lpv2:

0 commit comments

Comments
 (0)