Skip to content

Commit 693d721

Browse files
committed
prl: fix block fetcher
1 parent 26d8565 commit 693d721

File tree

4 files changed

+16
-22
lines changed

4 files changed

+16
-22
lines changed

prl/downloader/fetchers_concurrent_bodies.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ func (q *bodyQueue) request(peer *peerConnection, req *fetchRequest, resCh chan
8989
// deliver is responsible for taking a generic response packet from the concurrent
9090
// fetcher, unpacking the body data and delivering it to the downloader's queue.
9191
func (q *bodyQueue) deliver(peer *peerConnection, packet *prl.Response) (int, error) {
92-
txs, uncles := packet.Res.(*prl.BlockBodiesPacket).Unpack()
92+
txs := packet.Res.(*prl.BlockBodiesPacket).Unpack()
9393
hashsets := packet.Meta.([][]common.Hash) // {txs hashes, uncle hashes}
9494

95-
accepted, err := q.queue.DeliverBodies(peer.id, txs, hashsets[0], uncles, hashsets[1])
95+
accepted, err := q.queue.DeliverBodies(peer.id, txs, hashsets[0])
9696
switch {
9797
case err == nil && len(txs) == 0:
9898
peer.log.Trace("Requested bodies delivered")

prl/downloader/queue.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ func (q *queue) DeliverHeaders(id string, headers []*types.Header, hashes []comm
765765
// DeliverBodies injects a block body retrieval response into the results queue.
766766
// The method returns the number of blocks bodies accepted from the delivery and
767767
// also wakes any threads waiting for data delivery.
768-
func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListHashes []common.Hash, uncleLists [][]*types.Header, uncleListHashes []common.Hash) (int, error) {
768+
func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListHashes []common.Hash) (int, error) {
769769
q.lock.Lock()
770770
defer q.lock.Unlock()
771771

@@ -778,7 +778,6 @@ func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListH
778778

779779
reconstruct := func(index int, result *fetchResult) {
780780
result.Transactions = txLists[index]
781-
result.Uncles = uncleLists[index]
782781
result.SetBodyDone()
783782
}
784783
return q.deliver(id, q.blockTaskPool, q.blockTaskQueue, q.blockPendPool,

prl/fetcher/block_fetcher.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ type headerFilterTask struct {
124124
type bodyFilterTask struct {
125125
peer string // The source peer of block bodies
126126
transactions [][]*types.Transaction // Collection of transactions per block bodies
127-
uncles [][]*types.Header // Collection of uncles per block bodies
128127
time time.Time // Arrival time of the blocks' contents
129128
}
130129

@@ -303,29 +302,29 @@ func (f *BlockFetcher) FilterHeaders(peer string, headers []*types.Header, time
303302

304303
// FilterBodies extracts all the block bodies that were explicitly requested by
305304
// the fetcher, returning those that should be handled differently.
306-
func (f *BlockFetcher) FilterBodies(peer string, transactions [][]*types.Transaction, uncles [][]*types.Header, time time.Time) ([][]*types.Transaction, [][]*types.Header) {
307-
log.Trace("Filtering bodies", "peer", peer, "txs", len(transactions), "uncles", len(uncles))
305+
func (f *BlockFetcher) FilterBodies(peer string, transactions [][]*types.Transaction, time time.Time) [][]*types.Transaction {
306+
log.Trace("Filtering bodies", "peer", peer, "txs", len(transactions))
308307

309308
// Send the filter channel to the fetcher
310309
filter := make(chan *bodyFilterTask)
311310

312311
select {
313312
case f.bodyFilter <- filter:
314313
case <-f.quit:
315-
return nil, nil
314+
return nil
316315
}
317316
// Request the filtering of the body list
318317
select {
319-
case filter <- &bodyFilterTask{peer: peer, transactions: transactions, uncles: uncles, time: time}:
318+
case filter <- &bodyFilterTask{peer: peer, transactions: transactions, time: time}:
320319
case <-f.quit:
321-
return nil, nil
320+
return nil
322321
}
323322
// Retrieve the bodies remaining after filtering
324323
select {
325324
case task := <-filter:
326-
return task.transactions, task.uncles
325+
return task.transactions
327326
case <-f.quit:
328-
return nil, nil
327+
return nil
329328
}
330329
}
331330

@@ -542,8 +541,8 @@ func (f *BlockFetcher) loop() {
542541
case res := <-resCh:
543542
res.Done <- nil
544543

545-
txs, uncles := res.Res.(*prl.BlockBodiesPacket).Unpack()
546-
f.FilterBodies(peer, txs, uncles, time.Now())
544+
txs := res.Res.(*prl.BlockBodiesPacket).Unpack()
545+
f.FilterBodies(peer, txs, time.Now())
547546

548547
case <-timeout.C:
549548
// The peer didn't respond in time. The request
@@ -661,7 +660,7 @@ func (f *BlockFetcher) loop() {
661660
blocks := []*types.Block{}
662661
// abort early if there's nothing explicitly requested
663662
if len(f.completing) > 0 {
664-
for i := 0; i < len(task.transactions) && i < len(task.uncles); i++ {
663+
for i := 0; i < len(task.transactions); i++ {
665664
// Match up a body to any possible completion request
666665
var (
667666
matched = false
@@ -690,7 +689,6 @@ func (f *BlockFetcher) loop() {
690689
}
691690
if matched {
692691
task.transactions = append(task.transactions[:i], task.transactions[i+1:]...)
693-
task.uncles = append(task.uncles[:i], task.uncles[i+1:]...)
694692
i--
695693
continue
696694
}

prl/protocols/prl/protocol.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,12 @@ type BlockBody struct {
240240

241241
// Unpack retrieves the transactions and uncles from the range packet and returns
242242
// them in a split flat format that's more consistent with the internal data structures.
243-
func (p *BlockBodiesPacket) Unpack() ([][]*types.Transaction, [][]*types.Header) {
244-
var (
245-
txset = make([][]*types.Transaction, len(*p))
246-
uncleset = make([][]*types.Header, len(*p))
247-
)
243+
func (p *BlockBodiesPacket) Unpack() [][]*types.Transaction {
244+
txset := make([][]*types.Transaction, len(*p))
248245
for i, body := range *p {
249246
txset[i] = body.Transactions
250247
}
251-
return txset, uncleset
248+
return txset
252249
}
253250

254251
// GetNodeDataPacket represents a trie node data query.

0 commit comments

Comments
 (0)