aboutsummaryrefslogtreecommitdiffstats
path: root/les
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-09-20 19:11:14 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-09-20 19:14:48 +0800
commitaf89093116d2a4657c79d55f61b4293753b52588 (patch)
tree73a0b04eb9e3965be98219649f12595d9a26379c /les
parentf89dce0126f92eb5f3245f6b8e8b1e3ac13641b3 (diff)
downloaddexon-af89093116d2a4657c79d55f61b4293753b52588.tar
dexon-af89093116d2a4657c79d55f61b4293753b52588.tar.gz
dexon-af89093116d2a4657c79d55f61b4293753b52588.tar.bz2
dexon-af89093116d2a4657c79d55f61b4293753b52588.tar.lz
dexon-af89093116d2a4657c79d55f61b4293753b52588.tar.xz
dexon-af89093116d2a4657c79d55f61b4293753b52588.tar.zst
dexon-af89093116d2a4657c79d55f61b4293753b52588.zip
les, light, params: update light client CHTs
Diffstat (limited to 'les')
-rw-r--r--les/commons.go24
-rw-r--r--les/odr_requests.go16
2 files changed, 20 insertions, 20 deletions
diff --git a/les/commons.go b/les/commons.go
index a97687993..0b6cf3711 100644
--- a/les/commons.go
+++ b/les/commons.go
@@ -42,12 +42,12 @@ type lesCommons struct {
// NodeInfo represents a short summary of the Ethereum sub-protocol metadata
// known about the host peer.
type NodeInfo struct {
- Network uint64 `json:"network"` // Ethereum network ID (1=Frontier, 2=Morden, Ropsten=3, Rinkeby=4)
- Difficulty *big.Int `json:"difficulty"` // Total difficulty of the host's blockchain
- Genesis common.Hash `json:"genesis"` // SHA3 hash of the host's genesis block
- Config *params.ChainConfig `json:"config"` // Chain configuration for the fork rules
- Head common.Hash `json:"head"` // SHA3 hash of the host's best owned block
- CHT light.TrustedCheckpoint `json:"cht"` // Trused CHT checkpoint for fast catchup
+ Network uint64 `json:"network"` // Ethereum network ID (1=Frontier, 2=Morden, Ropsten=3, Rinkeby=4)
+ Difficulty *big.Int `json:"difficulty"` // Total difficulty of the host's blockchain
+ Genesis common.Hash `json:"genesis"` // SHA3 hash of the host's genesis block
+ Config *params.ChainConfig `json:"config"` // Chain configuration for the fork rules
+ Head common.Hash `json:"head"` // SHA3 hash of the host's best owned block
+ CHT params.TrustedCheckpoint `json:"cht"` // Trused CHT checkpoint for fast catchup
}
// makeProtocols creates protocol descriptors for the given LES versions.
@@ -76,7 +76,7 @@ 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
+ var cht params.TrustedCheckpoint
sections, _, _ := c.chtIndexer.Sections()
sections2, _, _ := c.bloomTrieIndexer.Sections()
@@ -98,11 +98,11 @@ func (c *lesCommons) nodeInfo() interface{} {
idxV2 := (sectionIndex+1)*c.iConfig.PairChtSize/c.iConfig.ChtSize - 1
chtRoot = light.GetChtRoot(c.chainDb, idxV2, sectionHead)
}
- cht = light.TrustedCheckpoint{
- SectionIdx: sectionIndex,
- SectionHead: sectionHead,
- CHTRoot: chtRoot,
- BloomRoot: light.GetBloomTrieRoot(c.chainDb, sectionIndex, sectionHead),
+ cht = params.TrustedCheckpoint{
+ SectionIndex: sectionIndex,
+ SectionHead: sectionHead,
+ CHTRoot: chtRoot,
+ BloomRoot: light.GetBloomTrieRoot(c.chainDb, sectionIndex, sectionHead),
}
}
diff --git a/les/odr_requests.go b/les/odr_requests.go
index 9e9b2673f..77b1b6d0c 100644
--- a/les/odr_requests.go
+++ b/les/odr_requests.go
@@ -478,7 +478,7 @@ func (r *ChtRequest) Validate(db ethdb.Database, msg *Msg) error {
}
type BloomReq struct {
- BloomTrieNum, BitIdx, SectionIdx, FromLevel uint64
+ BloomTrieNum, BitIdx, SectionIndex, FromLevel uint64
}
// ODR request type for requesting headers by Canonical Hash Trie, see LesOdrRequest interface
@@ -487,7 +487,7 @@ type BloomRequest light.BloomRequest
// GetCost returns the cost of the given ODR request according to the serving
// peer's cost table (implementation of LesOdrRequest)
func (r *BloomRequest) GetCost(peer *peer) uint64 {
- return peer.GetRequestCost(GetHelperTrieProofsMsg, len(r.SectionIdxList))
+ return peer.GetRequestCost(GetHelperTrieProofsMsg, len(r.SectionIndexList))
}
// CanSend tells if a certain peer is suitable for serving the given request
@@ -503,13 +503,13 @@ func (r *BloomRequest) CanSend(peer *peer) bool {
// Request sends an ODR request to the LES network (implementation of LesOdrRequest)
func (r *BloomRequest) Request(reqID uint64, peer *peer) error {
- peer.Log().Debug("Requesting BloomBits", "bloomTrie", r.BloomTrieNum, "bitIdx", r.BitIdx, "sections", r.SectionIdxList)
- reqs := make([]HelperTrieReq, len(r.SectionIdxList))
+ peer.Log().Debug("Requesting BloomBits", "bloomTrie", r.BloomTrieNum, "bitIdx", r.BitIdx, "sections", r.SectionIndexList)
+ reqs := make([]HelperTrieReq, len(r.SectionIndexList))
var encNumber [10]byte
binary.BigEndian.PutUint16(encNumber[:2], uint16(r.BitIdx))
- for i, sectionIdx := range r.SectionIdxList {
+ for i, sectionIdx := range r.SectionIndexList {
binary.BigEndian.PutUint64(encNumber[2:], sectionIdx)
reqs[i] = HelperTrieReq{
Type: htBloomBits,
@@ -524,7 +524,7 @@ func (r *BloomRequest) Request(reqID uint64, peer *peer) error {
// returns true and stores results in memory if the message was a valid reply
// to the request (implementation of LesOdrRequest)
func (r *BloomRequest) Validate(db ethdb.Database, msg *Msg) error {
- log.Debug("Validating BloomBits", "bloomTrie", r.BloomTrieNum, "bitIdx", r.BitIdx, "sections", r.SectionIdxList)
+ log.Debug("Validating BloomBits", "bloomTrie", r.BloomTrieNum, "bitIdx", r.BitIdx, "sections", r.SectionIndexList)
// Ensure we have a correct message with a single proof element
if msg.MsgType != MsgHelperTrieProofs {
@@ -535,13 +535,13 @@ func (r *BloomRequest) Validate(db ethdb.Database, msg *Msg) error {
nodeSet := proofs.NodeSet()
reads := &readTraceDB{db: nodeSet}
- r.BloomBits = make([][]byte, len(r.SectionIdxList))
+ r.BloomBits = make([][]byte, len(r.SectionIndexList))
// Verify the proofs
var encNumber [10]byte
binary.BigEndian.PutUint16(encNumber[:2], uint16(r.BitIdx))
- for i, idx := range r.SectionIdxList {
+ for i, idx := range r.SectionIndexList {
binary.BigEndian.PutUint64(encNumber[2:], idx)
value, _, err := trie.VerifyProof(r.BloomTrieRoot, encNumber[:], reads)
if err != nil {