Skip to content

Commit

Permalink
post-rebase fixes
Browse files Browse the repository at this point in the history
post-rebase fixes 2
  • Loading branch information
BrannonKing committed Mar 26, 2024
1 parent e9b2cbb commit 5a99dcf
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 51 deletions.
5 changes: 5 additions & 0 deletions addrmgr/addrmanager_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ func TestAddrManagerSerialization(t *testing.T) {
expectedAddrs := make(map[string]*wire.NetAddress, numAddrs)
for i := 0; i < numAddrs; i++ {
addr := randAddr(t)
cnt := len(expectedAddrs)
expectedAddrs[NetAddressKey(addr)] = addr
if len(expectedAddrs) == cnt {
i-- // accidentally generated a duplicate
continue
}
addrMgr.AddAddress(addr, randAddr(t))
}

Expand Down
3 changes: 3 additions & 0 deletions blockchain/claimtrie.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ import (

"github.com/pkg/errors"

"github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/lbryio/lbcd/txscript"
"github.com/lbryio/lbcd/wire"
btcutil "github.com/lbryio/lbcutil"

"github.com/lbryio/lbcd/claimtrie"
"github.com/lbryio/lbcd/claimtrie/change"
"github.com/lbryio/lbcd/claimtrie/merkletrie"
"github.com/lbryio/lbcd/claimtrie/node"
"github.com/lbryio/lbcd/claimtrie/normalization"
"github.com/lbryio/lbcd/claimtrie/param"
)

func (b *BlockChain) SetClaimtrieHeader(block *btcutil.Block, view *UtxoViewpoint) error {
Expand Down
1 change: 1 addition & 0 deletions blockchain/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/lbryio/lbcd/chaincfg"
"github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/lbryio/lbcd/claimtrie/param"
"github.com/lbryio/lbcd/txscript"
"github.com/lbryio/lbcd/wire"
btcutil "github.com/lbryio/lbcutil"
Expand Down
50 changes: 0 additions & 50 deletions claimtrie/claimtrie.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,56 +458,6 @@ func interruptRequested(interrupted <-chan struct{}) bool {
return false
}

func (ct *ClaimTrie) makeNameHashNext(names [][]byte, all bool, interrupt <-chan struct{}) chan NameHashNext {
inputs := make(chan []byte, 512)
outputs := make(chan NameHashNext, 512)

var wg sync.WaitGroup
hashComputationWorker := func() {
for name := range inputs {
hash, next := ct.nodeManager.Hash(name)
outputs <- NameHashNext{name, hash, next}
}
wg.Done()
}

threads := int(0.8 * float32(runtime.NumCPU()))
if threads < 1 {
threads = 1
}
for threads > 0 {
threads--
wg.Add(1)
go hashComputationWorker()
}
go func() {
if all {
ct.nodeManager.IterateNames(func(name []byte) bool {
if interruptRequested(interrupt) {
return false
}
clone := make([]byte, len(name))
copy(clone, name) // iteration name buffer is reused on future loops
inputs <- clone
return true
})
} else {
for _, name := range names {
if interruptRequested(interrupt) {
break
}
inputs <- name
}
}
close(inputs)
}()
go func() {
wg.Wait()
close(outputs)
}()
return outputs
}

func (ct *ClaimTrie) MerklePath(name []byte, n *node.Node, bid int) []merkletrie.HashSidePair {
pairs := ct.merkleTrie.MerklePath(name)
// TODO: organize this code better
Expand Down
3 changes: 2 additions & 1 deletion claimtrie/claimtrie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/lbryio/lbcd/claimtrie/change"
"github.com/lbryio/lbcd/claimtrie/config"
"github.com/lbryio/lbcd/claimtrie/merkletrie"
"github.com/lbryio/lbcd/claimtrie/node"
"github.com/lbryio/lbcd/claimtrie/param"

"github.com/lbryio/lbcd/chaincfg/chainhash"
Expand Down Expand Up @@ -1054,7 +1055,7 @@ func TestMerklePath(t *testing.T) {
r.NoError(err)

for i := 0; i < 10; i++ {
err = ct.AppendBlock()
err = ct.AppendBlock(false)
r.NoError(err)
}

Expand Down
1 change: 1 addition & 0 deletions claimtrie/node/hashfork_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/binary"

"github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/lbryio/lbcd/claimtrie/change"
"github.com/lbryio/lbcd/claimtrie/param"
)

Expand Down

0 comments on commit 5a99dcf

Please sign in to comment.