issues found in code review
This commit is contained in:
parent
d83eaa4fed
commit
e4c637b02a
4 changed files with 9 additions and 13 deletions
|
@ -22,13 +22,13 @@ type Change struct {
|
|||
Type ChangeType
|
||||
Height int32
|
||||
|
||||
Name []byte `msg:"-"`
|
||||
Name []byte
|
||||
ClaimID ClaimID
|
||||
OutPoint wire.OutPoint
|
||||
Amount int64
|
||||
|
||||
ActiveHeight int32 // for normalization fork
|
||||
VisibleHeight int32
|
||||
ActiveHeight int32
|
||||
VisibleHeight int32 // for normalization fork
|
||||
|
||||
SpentChildren map[string]bool
|
||||
}
|
||||
|
|
|
@ -422,7 +422,7 @@ func (ct *ClaimTrie) makeNameHashNext(names [][]byte, all bool) chan NameHashNex
|
|||
outputs := make(chan NameHashNext, 512)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
computeHash := func() {
|
||||
hashComputationWorker := func() {
|
||||
for name := range inputs {
|
||||
hash, next := ct.nodeManager.Hash(name)
|
||||
outputs <- NameHashNext{name, hash, next}
|
||||
|
@ -437,7 +437,7 @@ func (ct *ClaimTrie) makeNameHashNext(names [][]byte, all bool) chan NameHashNex
|
|||
for threads >= 0 {
|
||||
threads--
|
||||
wg.Add(1)
|
||||
go computeHash()
|
||||
go hashComputationWorker()
|
||||
}
|
||||
go func() {
|
||||
if all {
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
type KeyType []byte
|
||||
|
||||
type collapsedVertex struct { // implements sort.Interface
|
||||
type collapsedVertex struct {
|
||||
children []*collapsedVertex
|
||||
key KeyType
|
||||
merkleHash *chainhash.Hash
|
||||
|
|
|
@ -103,15 +103,8 @@ func (repo *Pebble) IterateChildren(name []byte, f func(changes []change.Change)
|
|||
start := make([]byte, len(name)+1) // zeros that last byte; need a constant len for stack alloc?
|
||||
copy(start, name)
|
||||
|
||||
end := make([]byte, 256) // max name length is 255
|
||||
copy(end, name)
|
||||
for i := len(name); i < 256; i++ {
|
||||
end[i] = 255
|
||||
}
|
||||
|
||||
prefixIterOptions := &pebble.IterOptions{
|
||||
LowerBound: start,
|
||||
UpperBound: end,
|
||||
}
|
||||
|
||||
iter := repo.db.NewIter(prefixIterOptions)
|
||||
|
@ -119,6 +112,9 @@ func (repo *Pebble) IterateChildren(name []byte, f func(changes []change.Change)
|
|||
|
||||
for iter.First(); iter.Valid(); iter.Next() {
|
||||
// NOTE! iter.Key() is ephemeral!
|
||||
if len(iter.Key()) <= len(name) || !bytes.Equal(name, iter.Key()[:len(name)]) {
|
||||
break
|
||||
}
|
||||
changes, err := unmarshalChanges(iter.Key(), iter.Value())
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "from unmarshaller at %s", iter.Key())
|
||||
|
|
Loading…
Add table
Reference in a new issue