eth, les: use the same method to serve block bodies

This commit is contained in:
Zsolt Felfoldi 2018-06-14 11:24:30 +02:00
parent cf059f15cb
commit daa1923141
2 changed files with 4 additions and 6 deletions

View file

@ -407,7 +407,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
bytes int bytes int
bodies []rlp.RawValue bodies []rlp.RawValue
) )
for bytes < softResponseLimit && len(bodies) < downloader.MaxBlockFetch { for bytes < softResponseLimit && len(bodies) < downloader.MaxBodyFetch {
// Retrieve the hash of the next block // Retrieve the hash of the next block
if err := msgStream.Decode(&hash); err == rlp.EOL { if err := msgStream.Decode(&hash); err == rlp.EOL {
break break

View file

@ -469,11 +469,9 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
break break
} }
// Retrieve the requested block body, stopping if enough was found // Retrieve the requested block body, stopping if enough was found
if number := rawdb.ReadHeaderNumber(pm.chainDb, hash); number != nil { if data := pm.blockchain.(*core.BlockChain).GetBodyRLP(hash); len(data) != 0 {
if data := rawdb.ReadBodyRLP(pm.chainDb, hash, *number); len(data) != 0 { bodies = append(bodies, data)
bodies = append(bodies, data) bytes += len(data)
bytes += len(data)
}
} }
} }
bv, rcost := p.fcClient.RequestProcessed(costs.baseCost + uint64(reqCnt)*costs.reqCost) bv, rcost := p.fcClient.RequestProcessed(costs.baseCost + uint64(reqCnt)*costs.reqCost)