mirror of
https://github.com/LBRYFoundation/lbcd.git
synced 2025-08-23 17:47:24 +00:00
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
|
Type ChangeType
|
||||||
Height int32
|
Height int32
|
||||||
|
|
||||||
Name []byte `msg:"-"`
|
Name []byte
|
||||||
ClaimID ClaimID
|
ClaimID ClaimID
|
||||||
OutPoint wire.OutPoint
|
OutPoint wire.OutPoint
|
||||||
Amount int64
|
Amount int64
|
||||||
|
|
||||||
ActiveHeight int32 // for normalization fork
|
ActiveHeight int32
|
||||||
VisibleHeight int32
|
VisibleHeight int32 // for normalization fork
|
||||||
|
|
||||||
SpentChildren map[string]bool
|
SpentChildren map[string]bool
|
||||||
}
|
}
|
||||||
|
|
|
@ -422,7 +422,7 @@ func (ct *ClaimTrie) makeNameHashNext(names [][]byte, all bool) chan NameHashNex
|
||||||
outputs := make(chan NameHashNext, 512)
|
outputs := make(chan NameHashNext, 512)
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
computeHash := func() {
|
hashComputationWorker := func() {
|
||||||
for name := range inputs {
|
for name := range inputs {
|
||||||
hash, next := ct.nodeManager.Hash(name)
|
hash, next := ct.nodeManager.Hash(name)
|
||||||
outputs <- NameHashNext{name, hash, next}
|
outputs <- NameHashNext{name, hash, next}
|
||||||
|
@ -437,7 +437,7 @@ func (ct *ClaimTrie) makeNameHashNext(names [][]byte, all bool) chan NameHashNex
|
||||||
for threads >= 0 {
|
for threads >= 0 {
|
||||||
threads--
|
threads--
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go computeHash()
|
go hashComputationWorker()
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
if all {
|
if all {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
|
|
||||||
type KeyType []byte
|
type KeyType []byte
|
||||||
|
|
||||||
type collapsedVertex struct { // implements sort.Interface
|
type collapsedVertex struct {
|
||||||
children []*collapsedVertex
|
children []*collapsedVertex
|
||||||
key KeyType
|
key KeyType
|
||||||
merkleHash *chainhash.Hash
|
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?
|
start := make([]byte, len(name)+1) // zeros that last byte; need a constant len for stack alloc?
|
||||||
copy(start, name)
|
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{
|
prefixIterOptions := &pebble.IterOptions{
|
||||||
LowerBound: start,
|
LowerBound: start,
|
||||||
UpperBound: end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
iter := repo.db.NewIter(prefixIterOptions)
|
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() {
|
for iter.First(); iter.Valid(); iter.Next() {
|
||||||
// NOTE! iter.Key() is ephemeral!
|
// 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())
|
changes, err := unmarshalChanges(iter.Key(), iter.Value())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "from unmarshaller at %s", iter.Key())
|
return errors.Wrapf(err, "from unmarshaller at %s", iter.Key())
|
||||||
|
|
Loading…
Add table
Reference in a new issue