mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
BUG: Fixed order
This commit is contained in:
parent
dbee17b27d
commit
a053ac76fd
2 changed files with 20 additions and 1 deletions
|
|
@ -272,7 +272,26 @@ func NewFirehose(config *FirehoseConfig) *Firehose {
|
||||||
|
|
||||||
// Output channel to order the flushing linearly
|
// Output channel to order the flushing linearly
|
||||||
firehose.flushOutputDone.Add(1)
|
firehose.flushOutputDone.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer firehose.flushOutputDone.Done()
|
||||||
|
|
||||||
|
expected := uint64(0)
|
||||||
|
buffer := make(map[uint64][]byte)
|
||||||
|
|
||||||
|
for result := range firehose.blockOutputQueue {
|
||||||
|
buffer[result.blockNum] = result.data
|
||||||
|
|
||||||
|
for {
|
||||||
|
data, ok := buffer[expected]
|
||||||
|
if !ok {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
firehose.flushToFirehose(data)
|
||||||
|
delete(buffer, expected)
|
||||||
|
expected++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
return firehose
|
return firehose
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ func TestFirehose_BlockPrintsToFirehose_SingleBlock(t *testing.T) {
|
||||||
|
|
||||||
func TestFirehose_BlocksPrintToFirehose_MultipleBlocksInOrder(t *testing.T) {
|
func TestFirehose_BlocksPrintToFirehose_MultipleBlocksInOrder(t *testing.T) {
|
||||||
|
|
||||||
const blockCount = 10
|
const blockCount = 100
|
||||||
const baseBlockNum = 0
|
const baseBlockNum = 0
|
||||||
|
|
||||||
f := NewFirehose(&FirehoseConfig{
|
f := NewFirehose(&FirehoseConfig{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue