Skip to content

Commit d5871fc

Browse files
committed
Merge pull request #1295 from karalabe/fix-broadcast-order
eth: fix the propagation/announce order for mined blocks
2 parents e4f9ec8 + 4180ca7 commit d5871fc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

eth/handler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"sync"
77
"time"
88

9-
"github.com/ethereum/go-ethereum/pow"
109
"github.com/ethereum/go-ethereum/common"
1110
"github.com/ethereum/go-ethereum/core"
1211
"github.com/ethereum/go-ethereum/core/types"
@@ -16,6 +15,7 @@ import (
1615
"github.com/ethereum/go-ethereum/logger"
1716
"github.com/ethereum/go-ethereum/logger/glog"
1817
"github.com/ethereum/go-ethereum/p2p"
18+
"github.com/ethereum/go-ethereum/pow"
1919
"github.com/ethereum/go-ethereum/rlp"
2020
)
2121

@@ -307,7 +307,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
307307
blocks = nil
308308
}
309309
// Update the receive timestamp of each block
310-
for i:=0; i<len(blocks); i++ {
310+
for i := 0; i < len(blocks); i++ {
311311
blocks[i].ReceivedAt = msg.ReceivedAt
312312
}
313313
// Filter out any explicitly requested blocks, deliver the rest to the downloader
@@ -417,8 +417,8 @@ func (self *ProtocolManager) minedBroadcastLoop() {
417417
for obj := range self.minedBlockSub.Chan() {
418418
switch ev := obj.(type) {
419419
case core.NewMinedBlockEvent:
420-
self.BroadcastBlock(ev.Block, false)
421-
self.BroadcastBlock(ev.Block, true)
420+
self.BroadcastBlock(ev.Block, true) // First propagate block to peers
421+
self.BroadcastBlock(ev.Block, false) // Only then announce to the rest
422422
}
423423
}
424424
}

0 commit comments

Comments
 (0)