Skip to content

Commit

Permalink
multi: remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
joostjager committed Sep 10, 2019
1 parent 5d016f8 commit 3d7de2a
Show file tree
Hide file tree
Showing 71 changed files with 35 additions and 766 deletions.
4 changes: 0 additions & 4 deletions aezeed/cipherseed.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ const (
// checkSumSize is the index within an enciphered cipher seed that
// marks the start of the checksum.
checkSumOffset = EncipheredCipherSeedSize - checkSumSize

// encipheredSeedSize is the size of the cipherseed before applying the
// external version, salt, and checksum for the final encoding.
encipheredSeedSize = DecipheredCipherSeedSize + CipherTextExpansion
)

var (
Expand Down
8 changes: 0 additions & 8 deletions autopilot/choice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ import (
"testing/quick"
)

var (
nID1 = NodeID([33]byte{1})
nID2 = NodeID([33]byte{2})
nID3 = NodeID([33]byte{3})
nID4 = NodeID([33]byte{4})
)

// TestWeightedChoiceEmptyMap tests that passing in an empty slice of weights
// returns an error.
func TestWeightedChoiceEmptyMap(t *testing.T) {
Expand Down Expand Up @@ -95,7 +88,6 @@ type nonNegative []float64
// Generate generates a value of type nonNegative to be used during
// QuickTests.
func (nonNegative) Generate(rand *rand.Rand, size int) reflect.Value {
const precision = 100
w := make([]float64, size)

for i := range w {
Expand Down
45 changes: 0 additions & 45 deletions autopilot/prefattach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ var chanGraphs = []struct {
// TestPrefAttachmentSelectEmptyGraph ensures that when passed an
// empty graph, the NodeSores function always returns a score of 0.
func TestPrefAttachmentSelectEmptyGraph(t *testing.T) {
const (
maxChanSize = btcutil.Amount(btcutil.SatoshiPerBitcoin)
)

prefAttach := NewPrefAttachment()

// Create a random public key, which we will query to get a score for.
Expand Down Expand Up @@ -123,47 +119,6 @@ func TestPrefAttachmentSelectEmptyGraph(t *testing.T) {
}
}

// completeGraph is a helper method that adds numNodes fully connected nodes to
// the graph.
func completeGraph(t *testing.T, g testGraph, numNodes int) {
const chanCapacity = btcutil.SatoshiPerBitcoin
nodes := make(map[int]*btcec.PublicKey)
for i := 0; i < numNodes; i++ {
for j := i + 1; j < numNodes; j++ {

node1 := nodes[i]
node2 := nodes[j]
edge1, edge2, err := g.addRandChannel(
node1, node2, chanCapacity)
if err != nil {
t.Fatalf("unable to generate channel: %v", err)
}

if node1 == nil {
pubKeyBytes := edge1.Peer.PubKey()
nodes[i], err = btcec.ParsePubKey(
pubKeyBytes[:], btcec.S256(),
)
if err != nil {
t.Fatalf("unable to parse pubkey: %v",
err)
}
}

if node2 == nil {
pubKeyBytes := edge2.Peer.PubKey()
nodes[j], err = btcec.ParsePubKey(
pubKeyBytes[:], btcec.S256(),
)
if err != nil {
t.Fatalf("unable to parse pubkey: %v",
err)
}
}
}
}
}

// TestPrefAttachmentSelectTwoVertexes ensures that when passed a
// graph with only two eligible vertexes, then both are given the same score,
// and the funds are appropriately allocated across each peer.
Expand Down
16 changes: 0 additions & 16 deletions breacharbiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1982,19 +1982,3 @@ func forceStateTransition(chanA, chanB *lnwallet.LightningChannel) error {

return nil
}

// calcStaticFee calculates appropriate fees for commitment transactions. This
// function provides a simple way to allow test balance assertions to take fee
// calculations into account.
//
// TODO(bvu): Refactor when dynamic fee estimation is added.
// TODO(conner) remove code duplication
func calcStaticFee(numHTLCs int) btcutil.Amount {
const (
commitWeight = btcutil.Amount(724)
htlcWeight = 172
feePerKw = btcutil.Amount(24/4) * 1000
)
return feePerKw * (commitWeight +
btcutil.Amount(htlcWeight*numHTLCs)) / 1000
}
15 changes: 0 additions & 15 deletions chainntnfs/bitcoindnotify/bitcoind.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ const (
notifierType = "bitcoind"
)

// chainUpdate encapsulates an update to the current main chain. This struct is
// used as an element within an unbounded queue in order to avoid blocking the
// main rpc dispatch rule.
type chainUpdate struct {
blockHash *chainhash.Hash
blockHeight int32
}

// TODO(roasbeef): generalize struct below:
// * move chans to config
// * extract common code
Expand Down Expand Up @@ -166,13 +158,6 @@ func (b *BitcoindNotifier) Stop() error {
return nil
}

// blockNtfn packages a notification of a connected/disconnected block along
// with its height at the time.
type blockNtfn struct {
sha *chainhash.Hash
height int32
}

// notificationDispatcher is the primary goroutine which handles client
// notification registrations, as well as notification dispatches.
func (b *BitcoindNotifier) notificationDispatcher() {
Expand Down
9 changes: 0 additions & 9 deletions chainntnfs/height_hint_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@ import (
"github.com/lightningnetwork/lnd/channeldb"
)

const (
// dbName is the default name of the database storing the height hints.
dbName = "heighthint.db"

// dbFilePermission is the default permission of the database file
// storing the height hints.
dbFilePermission = 0600
)

var (
// spendHintBucket is the name of the bucket which houses the height
// hint for outpoints. Each height hint represents the earliest height
Expand Down
2 changes: 0 additions & 2 deletions chainntnfs/txnotifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"testing"

"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/chainntnfs"
Expand All @@ -33,7 +32,6 @@ var (
0x86, 0xf4, 0xcb, 0xf9, 0x8e, 0xae, 0xd2, 0x21,
0xb3, 0x0b, 0xd9, 0xa0, 0xb9, 0x28,
}
testScript, _ = txscript.ParsePkScript(testRawScript)
)

type mockHintCache struct {
Expand Down
24 changes: 0 additions & 24 deletions channeldb/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -2298,23 +2298,6 @@ func serializeChannelCloseSummary(w io.Writer, cs *ChannelCloseSummary) error {
return nil
}

func fetchChannelCloseSummary(tx *bbolt.Tx,
chanID []byte) (*ChannelCloseSummary, error) {

closedChanBucket, err := tx.CreateBucketIfNotExists(closedChannelBucket)
if err != nil {
return nil, err
}

summaryBytes := closedChanBucket.Get(chanID)
if summaryBytes == nil {
return nil, fmt.Errorf("closed channel summary not found")
}

summaryReader := bytes.NewReader(summaryBytes)
return deserializeCloseChannelSummary(summaryReader)
}

func deserializeCloseChannelSummary(r io.Reader) (*ChannelCloseSummary, error) {
c := &ChannelCloseSummary{}

Expand Down Expand Up @@ -2679,13 +2662,6 @@ func makeLogKey(updateNum uint64) [8]byte {
return key
}

// readLogKey parse the first 8- bytes of a byte slice into a uint64.
//
// NOTE: The slice must be at least 8 bytes long.
func readLogKey(b []byte) uint64 {
return byteOrder.Uint64(b)
}

func appendChannelLogEntry(log *bbolt.Bucket,
commit *ChannelCommitment) error {

Expand Down
16 changes: 0 additions & 16 deletions channeldb/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"testing"

"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
Expand All @@ -23,23 +22,12 @@ import (
)

var (
netParams = &chaincfg.TestNet3Params

key = [chainhash.HashSize]byte{
0x81, 0xb6, 0x37, 0xd8, 0xfc, 0xd2, 0xc6, 0xda,
0x68, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17,
0xd, 0xe7, 0x93, 0xe4, 0xb7, 0x25, 0xb8, 0x4d,
0x1e, 0xb, 0x4c, 0xf9, 0x9e, 0xc5, 0x8c, 0xe9,
}
id = &wire.OutPoint{
Hash: [chainhash.HashSize]byte{
0x51, 0xb6, 0x37, 0xd8, 0xfc, 0xd2, 0xc6, 0xda,
0x48, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17,
0x2d, 0xe7, 0x93, 0xe4, 0xb7, 0x25, 0xb8, 0x4d,
0x1f, 0xb, 0x4c, 0xf9, 0x9e, 0xc5, 0x8c, 0xe9,
},
Index: 9,
}
rev = [chainhash.HashSize]byte{
0x51, 0xb6, 0x37, 0xd8, 0xfc, 0xd2, 0xc6, 0xda,
0x48, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17,
Expand Down Expand Up @@ -77,10 +65,6 @@ var (
},
LockTime: 5,
}
testOutpoint = &wire.OutPoint{
Hash: key,
Index: 0,
}
privKey, pubKey = btcec.PrivKeyFromBytes(btcec.S256(), key[:])

wireSig, _ = lnwire.NewSigFromSignature(testSig)
Expand Down
3 changes: 0 additions & 3 deletions channeldb/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ import (
"github.com/lightningnetwork/lnd/shachain"
)

// outPointSize is the size of a serialized outpoint on disk.
const outPointSize = 36

// writeOutpoint writes an outpoint to the passed writer using the minimal
// amount of bytes possible.
func writeOutpoint(w io.Writer, o *wire.OutPoint) error {
Expand Down
5 changes: 0 additions & 5 deletions channeldb/forwarding_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -919,11 +919,6 @@ func uint16Key(i uint16) []byte {
return key
}

// uint16FromKey reconstructs a 16-bit unsigned integer from a 2-byte slice.
func uint16FromKey(key []byte) uint16 {
return byteOrder.Uint16(key)
}

// Compile-time constraint to ensure that ChannelPackager implements the public
// FwdPackager interface.
var _ FwdPackager = (*ChannelPackager)(nil)
Expand Down
4 changes: 1 addition & 3 deletions channeldb/graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ var (
"[2001:db8:85a3:0:0:8a2e:370:7334]:80")
testAddrs = []net.Addr{testAddr, anotherAddr}

randSource = prand.NewSource(time.Now().Unix())
randInts = prand.New(randSource)
testSig = &btcec.Signature{
testSig = &btcec.Signature{
R: new(big.Int),
S: new(big.Int),
}
Expand Down
8 changes: 0 additions & 8 deletions channeldb/payments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,6 @@ func makeFakeInfo() (*PaymentCreationInfo, *PaymentAttemptInfo) {
return c, a
}

func makeFakePaymentHash() [32]byte {
var paymentHash [32]byte
rBytes, _ := randomBytes(0, 32)
copy(paymentHash[:], rBytes)

return paymentHash
}

// randomBytes creates random []byte with length in range [minLen, maxLen)
func randomBytes(minLen, maxLen int) ([]byte, error) {
randBuf := make([]byte, minLen+rand.Intn(maxLen-minLen))
Expand Down
4 changes: 2 additions & 2 deletions channelnotifier/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func UseLogger(logger btclog.Logger) {

// logClosure is used to provide a closure over expensive logging operations so
// don't have to be performed when the logging level doesn't warrant it.
type logClosure func() string
type logClosure func() string // nolint:unused

// String invokes the underlying function and returns the result.
func (c logClosure) String() string {
Expand All @@ -40,6 +40,6 @@ func (c logClosure) String() string {
// newLogClosure returns a new closure over a function that returns a string
// which itself provides a Stringer interface so that it can be used with the
// logging system.
func newLogClosure(c func() string) logClosure {
func newLogClosure(c func() string) logClosure { // nolint:unused
return logClosure(c)
}
31 changes: 0 additions & 31 deletions cmd/lncli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2818,37 +2818,6 @@ func describeGraph(ctx *cli.Context) error {
return nil
}

// normalizeFunc is a factory function which returns a function that normalizes
// the capacity of edges within the graph. The value of the returned
// function can be used to either plot the capacities, or to use a weight in a
// rendering of the graph.
func normalizeFunc(edges []*lnrpc.ChannelEdge, scaleFactor float64) func(int64) float64 {
var (
min float64 = math.MaxInt64
max float64
)

for _, edge := range edges {
// In order to obtain saner values, we reduce the capacity of a
// channel to its base 2 logarithm.
z := math.Log2(float64(edge.Capacity))

if z < min {
min = z
}
if z > max {
max = z
}
}

return func(x int64) float64 {
y := math.Log2(float64(x))

// TODO(roasbeef): results in min being zero
return (y - min) / (max - min) * scaleFactor
}
}

var listPaymentsCommand = cli.Command{
Name: "listpayments",
Category: "Payments",
Expand Down
1 change: 0 additions & 1 deletion contractcourt/channel_arbitrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type mockArbitratorLog struct {
failCommit bool
failCommitState ArbitratorState
resolutions *ContractResolutions
chainActions ChainActionMap
resolvers map[ContractResolver]struct{}

commitSet *CommitSet
Expand Down
11 changes: 3 additions & 8 deletions discovery/gossiper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ var (
_, _ = testSig.R.SetString("63724406601629180062774974542967536251589935445068131219452686511677818569431", 10)
_, _ = testSig.S.SetString("18801056069249825825291287104931333862866033135609736119018462340006816851118", 10)

inputStr = "147caa76786596590baa4e98f5d9f48b86c7765e489f7a6ff3360fe5c674360b"
sha, _ = chainhash.NewHashFromStr(inputStr)
outpoint = wire.NewOutPoint(sha, 0)

bitcoinKeyPriv1, _ = btcec.NewPrivateKey(btcec.S256())
bitcoinKeyPub1 = bitcoinKeyPriv1.PubKey()

Expand All @@ -59,10 +55,9 @@ var (
nodeKeyPriv2, _ = btcec.NewPrivateKey(btcec.S256())
nodeKeyPub2 = nodeKeyPriv2.PubKey()

trickleDelay = time.Millisecond * 100
retransmitDelay = time.Hour * 1
proofMatureDelta uint32
maxBtcFundingAmount = btcutil.Amount(1<<62) - 1
trickleDelay = time.Millisecond * 100
retransmitDelay = time.Hour * 1
proofMatureDelta uint32
)

// makeTestDB creates a new instance of the ChannelDB for testing purposes. A
Expand Down
Loading

0 comments on commit 3d7de2a

Please sign in to comment.