forked from cerc-io/plugeth
les: fix CHT field in nodeInfo (#17465)
This commit is contained in:
parent
76301ca051
commit
355fc47d39
@ -76,18 +76,30 @@ func (c *lesCommons) makeProtocols(versions []uint) []p2p.Protocol {
|
|||||||
// nodeInfo retrieves some protocol metadata about the running host node.
|
// nodeInfo retrieves some protocol metadata about the running host node.
|
||||||
func (c *lesCommons) nodeInfo() interface{} {
|
func (c *lesCommons) nodeInfo() interface{} {
|
||||||
var cht light.TrustedCheckpoint
|
var cht light.TrustedCheckpoint
|
||||||
sections, _, sectionHead := c.chtIndexer.Sections()
|
sections, _, _ := c.chtIndexer.Sections()
|
||||||
sections2, _, sectionHead2 := c.bloomTrieIndexer.Sections()
|
sections2, _, _ := c.bloomTrieIndexer.Sections()
|
||||||
|
|
||||||
|
if !c.protocolManager.lightSync {
|
||||||
|
// convert to client section size if running in server mode
|
||||||
|
sections /= light.CHTFrequencyClient / light.CHTFrequencyServer
|
||||||
|
}
|
||||||
|
|
||||||
if sections2 < sections {
|
if sections2 < sections {
|
||||||
sections = sections2
|
sections = sections2
|
||||||
sectionHead = sectionHead2
|
|
||||||
}
|
}
|
||||||
if sections > 0 {
|
if sections > 0 {
|
||||||
sectionIndex := sections - 1
|
sectionIndex := sections - 1
|
||||||
|
sectionHead := c.bloomTrieIndexer.SectionHead(sectionIndex)
|
||||||
|
var chtRoot common.Hash
|
||||||
|
if c.protocolManager.lightSync {
|
||||||
|
chtRoot = light.GetChtRoot(c.chainDb, sectionIndex, sectionHead)
|
||||||
|
} else {
|
||||||
|
chtRoot = light.GetChtV2Root(c.chainDb, sectionIndex, sectionHead)
|
||||||
|
}
|
||||||
cht = light.TrustedCheckpoint{
|
cht = light.TrustedCheckpoint{
|
||||||
SectionIdx: sectionIndex,
|
SectionIdx: sectionIndex,
|
||||||
SectionHead: sectionHead,
|
SectionHead: sectionHead,
|
||||||
CHTRoot: light.GetChtRoot(c.chainDb, sectionIndex, sectionHead),
|
CHTRoot: chtRoot,
|
||||||
BloomRoot: light.GetBloomTrieRoot(c.chainDb, sectionIndex, sectionHead),
|
BloomRoot: light.GetBloomTrieRoot(c.chainDb, sectionIndex, sectionHead),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user