Skip to content

Commit 080fabc

Browse files
eth: fix review comments
1 parent db65cc3 commit 080fabc

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

core/types/receipt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, nu
372372
logIndex++
373373
}
374374
// also derive the Bloom if not derived yet
375-
rs[i].Bloom = CreateBloom(Receipts{(*Receipt)(rs[i])})
375+
rs[i].Bloom = CreateBloom(Receipts{rs[i]})
376376
}
377377

378378
return nil

eth/downloader/downloader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ func (dlp *downloadTesterPeer) RequestBodies(hashes []common.Hash, sink chan *et
301301
// peer in the download tester. The returned function can be used to retrieve
302302
// batches of block receipts from the particularly requested peer.
303303
func (dlp *downloadTesterPeer) RequestReceipts(hashes []common.Hash, sink chan *eth.Response) (*eth.Request, error) {
304-
blobs := eth.ServiceGetReceiptsQuery(dlp.chain, hashes)
304+
blobs := eth.ServiceGetReceiptsQuery68(dlp.chain, hashes)
305305

306306
receipts := make([][]*types.Receipt, len(blobs))
307307
for i, blob := range blobs {

eth/protocols/eth/handler.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ var eth68 = map[uint64]msgHandler{
171171
BlockHeadersMsg: handleBlockHeaders,
172172
GetBlockBodiesMsg: handleGetBlockBodies,
173173
BlockBodiesMsg: handleBlockBodies,
174-
GetReceiptsMsg: handleGetReceipts,
175-
ReceiptsMsg: handleReceipts,
174+
GetReceiptsMsg: handleGetReceipts68,
175+
ReceiptsMsg: handleReceipts68,
176176
GetPooledTransactionsMsg: handleGetPooledTransactions,
177177
PooledTransactionsMsg: handlePooledTransactions,
178178
}
@@ -203,9 +203,13 @@ func handleMessage(backend Backend, peer *Peer) error {
203203
}
204204
defer msg.Discard()
205205

206-
var handlers = eth68
207-
if peer.version == ETH69 {
206+
var handlers map[uint64]msgHandler
207+
if peer.version == ETH68 {
208+
handlers = eth68
209+
} else if peer.version == ETH69 {
208210
handlers = eth69
211+
} else {
212+
return fmt.Errorf("unknown eth protocol version: %v", peer.version)
209213
}
210214

211215
// Track the amount of time it takes to serve the request and run the handler

eth/protocols/eth/handlers.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,13 @@ func ServiceGetBlockBodiesQuery(chain *core.BlockChain, query GetBlockBodiesRequ
232232
return bodies
233233
}
234234

235-
func handleGetReceipts(backend Backend, msg Decoder, peer *Peer) error {
235+
func handleGetReceipts68(backend Backend, msg Decoder, peer *Peer) error {
236236
// Decode the block receipts retrieval message
237237
var query GetReceiptsPacket
238238
if err := msg.Decode(&query); err != nil {
239239
return fmt.Errorf("%w: message %v: %v", errDecode, msg, err)
240240
}
241-
response := ServiceGetReceiptsQuery(backend.Chain(), query.GetReceiptsRequest)
241+
response := ServiceGetReceiptsQuery68(backend.Chain(), query.GetReceiptsRequest)
242242
return peer.ReplyReceiptsRLP(query.RequestId, response)
243243
}
244244

@@ -252,9 +252,9 @@ func handleGetReceipts69(backend Backend, msg Decoder, peer *Peer) error {
252252
return peer.ReplyReceiptsRLP(query.RequestId, response)
253253
}
254254

255-
// ServiceGetReceiptsQuery assembles the response to a receipt query. It is
255+
// ServiceGetReceiptsQuery68 assembles the response to a receipt query. It is
256256
// exposed to allow external packages to test protocol behavior.
257-
func ServiceGetReceiptsQuery(chain *core.BlockChain, query GetReceiptsRequest) []rlp.RawValue {
257+
func ServiceGetReceiptsQuery68(chain *core.BlockChain, query GetReceiptsRequest) []rlp.RawValue {
258258
// Gather state data until the fetch or network limits is reached
259259
var (
260260
bytes int
@@ -408,7 +408,7 @@ func handleBlockBodies(backend Backend, msg Decoder, peer *Peer) error {
408408
}, metadata)
409409
}
410410

411-
func handleReceipts(backend Backend, msg Decoder, peer *Peer) error {
411+
func handleReceipts68(backend Backend, msg Decoder, peer *Peer) error {
412412
// A batch of receipts arrived to one of our previous requests
413413
res := new(ReceiptsPacket)
414414
if err := msg.Decode(res); err != nil {

eth/protocols/eth/protocol.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var ProtocolVersions = []uint{ETH69, ETH68}
4444

4545
// protocolLengths are the number of implemented message corresponding to
4646
// different protocol versions.
47-
var protocolLengths = map[uint]uint64{ETH68: 17, ETH69: 15}
47+
var protocolLengths = map[uint]uint64{ETH68: 17, ETH69: 17}
4848

4949
// maxMessageSize is the maximum cap on the size of a protocol message.
5050
const maxMessageSize = 10 * 1024 * 1024

0 commit comments

Comments
 (0)