aboutsummaryrefslogtreecommitdiffstats
path: root/les
diff options
context:
space:
mode:
authorFelföldi Zsolt <zsfelfoldi@gmail.com>2018-08-21 19:58:10 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-08-21 19:58:10 +0800
commit355fc47d396298bccf93c37bdbba9b9e88864790 (patch)
treee9aab83b811c2a4409866272326a48e5ed7ec800 /les
parent76301ca0517ef2d34e6e2d741b0b24cf0ff98642 (diff)
downloadgo-tangerine-355fc47d396298bccf93c37bdbba9b9e88864790.tar
go-tangerine-355fc47d396298bccf93c37bdbba9b9e88864790.tar.gz
go-tangerine-355fc47d396298bccf93c37bdbba9b9e88864790.tar.bz2
go-tangerine-355fc47d396298bccf93c37bdbba9b9e88864790.tar.lz
go-tangerine-355fc47d396298bccf93c37bdbba9b9e88864790.tar.xz
go-tangerine-355fc47d396298bccf93c37bdbba9b9e88864790.tar.zst
go-tangerine-355fc47d396298bccf93c37bdbba9b9e88864790.zip
les: fix CHT field in nodeInfo (#17465)
Diffstat (limited to 'les')
-rw-r--r--les/commons.go20
1 files changed, 16 insertions, 4 deletions
diff --git a/les/commons.go b/les/commons.go
index 251b7a583..d8e941295 100644
--- a/les/commons.go
+++ b/les/commons.go
@@ -76,18 +76,30 @@ func (c *lesCommons) makeProtocols(versions []uint) []p2p.Protocol {
// nodeInfo retrieves some protocol metadata about the running host node.
func (c *lesCommons) nodeInfo() interface{} {
var cht light.TrustedCheckpoint
- sections, _, sectionHead := c.chtIndexer.Sections()
- sections2, _, sectionHead2 := c.bloomTrieIndexer.Sections()
+ sections, _, _ := c.chtIndexer.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 {
sections = sections2
- sectionHead = sectionHead2
}
if sections > 0 {
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{
SectionIdx: sectionIndex,
SectionHead: sectionHead,
- CHTRoot: light.GetChtRoot(c.chainDb, sectionIndex, sectionHead),
+ CHTRoot: chtRoot,
BloomRoot: light.GetBloomTrieRoot(c.chainDb, sectionIndex, sectionHead),
}
}