Skip to content

Commit

Permalink
fix: redundant keys and non-closed channel (#34)
Browse files Browse the repository at this point in the history
* fix: redundant keys and non-closed channel

* revert line to its original state
  • Loading branch information
gballet authored and holiman committed May 30, 2022
1 parent 46250b6 commit 9e0e01e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cmd/geth/converkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,19 @@ func convertToVerkle(ctx *cli.Context) error {
values[slotkey[31]] = value[:]
continue
}
kvCh <- &group{laststem, values[:]}

// flush the previous group, iff it's not the header group
if !bytes.Equal(stem[:31], laststem[:]) {
kvCh <- &group{stem: laststem, values: values[:]}
}

values = make([][]byte, 256)
values[slotkey[31]] = value[:]
copy(laststem[:], slotkey[:31])
}

// commit the last group if it's not the header group
if !bytes.Equal(laststem[:31], stem) {
if !bytes.Equal(laststem[:31], stem[:31]) {
kvCh <- &group{laststem, values[:]}
}
}
Expand Down Expand Up @@ -541,6 +549,7 @@ func doInsertion(ctx *cli.Context) error {
if err := readDataDump(itemCh, abortCh); err != nil {
log.Error("Error reading data", "err", err)
}
close(itemCh)
}()
defer close(abortCh)

Expand Down

0 comments on commit 9e0e01e

Please sign in to comment.