Skip to content

Commit 5a99dcf

Browse files
committed
post-rebase fixes
post-rebase fixes 2
1 parent e9b2cbb commit 5a99dcf

File tree

6 files changed

+12
-51
lines changed

6 files changed

+12
-51
lines changed

addrmgr/addrmanager_internal_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ func TestAddrManagerSerialization(t *testing.T) {
9999
expectedAddrs := make(map[string]*wire.NetAddress, numAddrs)
100100
for i := 0; i < numAddrs; i++ {
101101
addr := randAddr(t)
102+
cnt := len(expectedAddrs)
102103
expectedAddrs[NetAddressKey(addr)] = addr
104+
if len(expectedAddrs) == cnt {
105+
i-- // accidentally generated a duplicate
106+
continue
107+
}
103108
addrMgr.AddAddress(addr, randAddr(t))
104109
}
105110

blockchain/claimtrie.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ import (
77

88
"github.com/pkg/errors"
99

10+
"github.com/lbryio/lbcd/chaincfg/chainhash"
1011
"github.com/lbryio/lbcd/txscript"
1112
"github.com/lbryio/lbcd/wire"
1213
btcutil "github.com/lbryio/lbcutil"
1314

1415
"github.com/lbryio/lbcd/claimtrie"
1516
"github.com/lbryio/lbcd/claimtrie/change"
17+
"github.com/lbryio/lbcd/claimtrie/merkletrie"
1618
"github.com/lbryio/lbcd/claimtrie/node"
1719
"github.com/lbryio/lbcd/claimtrie/normalization"
20+
"github.com/lbryio/lbcd/claimtrie/param"
1821
)
1922

2023
func (b *BlockChain) SetClaimtrieHeader(block *btcutil.Block, view *UtxoViewpoint) error {

blockchain/validate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/lbryio/lbcd/chaincfg"
1515
"github.com/lbryio/lbcd/chaincfg/chainhash"
16+
"github.com/lbryio/lbcd/claimtrie/param"
1617
"github.com/lbryio/lbcd/txscript"
1718
"github.com/lbryio/lbcd/wire"
1819
btcutil "github.com/lbryio/lbcutil"

claimtrie/claimtrie.go

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -458,56 +458,6 @@ func interruptRequested(interrupted <-chan struct{}) bool {
458458
return false
459459
}
460460

461-
func (ct *ClaimTrie) makeNameHashNext(names [][]byte, all bool, interrupt <-chan struct{}) chan NameHashNext {
462-
inputs := make(chan []byte, 512)
463-
outputs := make(chan NameHashNext, 512)
464-
465-
var wg sync.WaitGroup
466-
hashComputationWorker := func() {
467-
for name := range inputs {
468-
hash, next := ct.nodeManager.Hash(name)
469-
outputs <- NameHashNext{name, hash, next}
470-
}
471-
wg.Done()
472-
}
473-
474-
threads := int(0.8 * float32(runtime.NumCPU()))
475-
if threads < 1 {
476-
threads = 1
477-
}
478-
for threads > 0 {
479-
threads--
480-
wg.Add(1)
481-
go hashComputationWorker()
482-
}
483-
go func() {
484-
if all {
485-
ct.nodeManager.IterateNames(func(name []byte) bool {
486-
if interruptRequested(interrupt) {
487-
return false
488-
}
489-
clone := make([]byte, len(name))
490-
copy(clone, name) // iteration name buffer is reused on future loops
491-
inputs <- clone
492-
return true
493-
})
494-
} else {
495-
for _, name := range names {
496-
if interruptRequested(interrupt) {
497-
break
498-
}
499-
inputs <- name
500-
}
501-
}
502-
close(inputs)
503-
}()
504-
go func() {
505-
wg.Wait()
506-
close(outputs)
507-
}()
508-
return outputs
509-
}
510-
511461
func (ct *ClaimTrie) MerklePath(name []byte, n *node.Node, bid int) []merkletrie.HashSidePair {
512462
pairs := ct.merkleTrie.MerklePath(name)
513463
// TODO: organize this code better

claimtrie/claimtrie_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/lbryio/lbcd/claimtrie/change"
99
"github.com/lbryio/lbcd/claimtrie/config"
1010
"github.com/lbryio/lbcd/claimtrie/merkletrie"
11+
"github.com/lbryio/lbcd/claimtrie/node"
1112
"github.com/lbryio/lbcd/claimtrie/param"
1213

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

10561057
for i := 0; i < 10; i++ {
1057-
err = ct.AppendBlock()
1058+
err = ct.AppendBlock(false)
10581059
r.NoError(err)
10591060
}
10601061

claimtrie/node/hashfork_manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/binary"
66

77
"github.com/lbryio/lbcd/chaincfg/chainhash"
8+
"github.com/lbryio/lbcd/claimtrie/change"
89
"github.com/lbryio/lbcd/claimtrie/param"
910
)
1011

0 commit comments

Comments
 (0)