Skip to content

Commit 355fc47

Browse files
zsfelfoldikaralabe
authored andcommitted
les: fix CHT field in nodeInfo (#17465)
1 parent 76301ca commit 355fc47

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

les/commons.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,30 @@ func (c *lesCommons) makeProtocols(versions []uint) []p2p.Protocol {
7676
// nodeInfo retrieves some protocol metadata about the running host node.
7777
func (c *lesCommons) nodeInfo() interface{} {
7878
var cht light.TrustedCheckpoint
79-
sections, _, sectionHead := c.chtIndexer.Sections()
80-
sections2, _, sectionHead2 := c.bloomTrieIndexer.Sections()
79+
sections, _, _ := c.chtIndexer.Sections()
80+
sections2, _, _ := c.bloomTrieIndexer.Sections()
81+
82+
if !c.protocolManager.lightSync {
83+
// convert to client section size if running in server mode
84+
sections /= light.CHTFrequencyClient / light.CHTFrequencyServer
85+
}
86+
8187
if sections2 < sections {
8288
sections = sections2
83-
sectionHead = sectionHead2
8489
}
8590
if sections > 0 {
8691
sectionIndex := sections - 1
92+
sectionHead := c.bloomTrieIndexer.SectionHead(sectionIndex)
93+
var chtRoot common.Hash
94+
if c.protocolManager.lightSync {
95+
chtRoot = light.GetChtRoot(c.chainDb, sectionIndex, sectionHead)
96+
} else {
97+
chtRoot = light.GetChtV2Root(c.chainDb, sectionIndex, sectionHead)
98+
}
8799
cht = light.TrustedCheckpoint{
88100
SectionIdx: sectionIndex,
89101
SectionHead: sectionHead,
90-
CHTRoot: light.GetChtRoot(c.chainDb, sectionIndex, sectionHead),
102+
CHTRoot: chtRoot,
91103
BloomRoot: light.GetBloomTrieRoot(c.chainDb, sectionIndex, sectionHead),
92104
}
93105
}

0 commit comments

Comments
 (0)