Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
remove deadcode
Browse files Browse the repository at this point in the history
  • Loading branch information
dajohi authored and davecgh committed Jul 17, 2017
1 parent 59db139 commit a923485
Show file tree
Hide file tree
Showing 19 changed files with 12 additions and 467 deletions.
2 changes: 0 additions & 2 deletions addrmgr/addrmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ const (
// address manager will claim to need more addresses.
needAddressThreshold = 1000

newAddressBufferSize = 50

// dumpAddressInterval is the interval used to dump the address
// cache to disk for future use.
dumpAddressInterval = time.Minute * 10
Expand Down
20 changes: 0 additions & 20 deletions blockchain/chainio.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,6 @@ import (
)

var (
// hashIndexBucketName is the name of the db bucket used to house to the
// block hash -> block height index.
hashIndexBucketName = []byte("hashidx")

// heightIndexBucketName is the name of the db bucket used to house to
// the block height -> block hash index.
heightIndexBucketName = []byte("heightidx")

// chainStateKeyName is the name of the db key used to store the best
// chain state.
chainStateKeyName = []byte("chainstate")

// spendJournalBucketName is the name of the db bucket used to house
// transactions outputs that are spent in each block.
spendJournalBucketName = []byte("spendjournal")

// utxoSetBucketName is the name of the db bucket used to house the
// unspent transaction output set.
utxoSetBucketName = []byte("utxoset")

// thresholdBucketName is the name of the db bucket used to house cached
// threshold states.
thresholdBucketName = []byte("thresholdstate")
Expand Down
9 changes: 9 additions & 0 deletions blockchain/chainio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ import (
"github.com/decred/dcrd/wire"
)

// newHashFromStr converts the passed big-endian hex string into a
// chainhash.Hash. It only differs from the one available in chainhash in that
// it ignores the error since it will only (and must only) be called with
// hard-coded, and therefore known good, hashes.
func newHashFromStr(hexStr string) *chainhash.Hash {
hash, _ := chainhash.NewHashFromStr(hexStr)
return hash
}

// DoStxoTest does a test on a simulated blockchain to ensure that the data
// stored in the STXO buckets is not corrupt.
func (b *BlockChain) DoStxoTest() error {
Expand Down
9 changes: 0 additions & 9 deletions blockchain/checkpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ import (
// best block chain that a good checkpoint candidate must be.
const CheckpointConfirmations = 4096

// newHashFromStr converts the passed big-endian hex string into a
// chainhash.Hash. It only differs from the one available in chainhash in that
// it ignores the error since it will only (and must only) be called with
// hard-coded, and therefore known good, hashes.
func newHashFromStr(hexStr string) *chainhash.Hash {
hash, _ := chainhash.NewHashFromStr(hexStr)
return hash
}

// DisableCheckpoints provides a mechanism to disable validation against
// checkpoints which you DO NOT want to do in production. It is provided only
// for debug purposes.
Expand Down
9 changes: 0 additions & 9 deletions blockchain/fullblocktests/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,6 @@ func replaceStakeSigScript(sigScript []byte) func(*wire.MsgBlock) {
}
}

// replaceDevOrgScript returns a function that itself takes a block and modifies
// it by replacing the public key script of the dev org payout in the coinbase
// transaction.
func replaceDevOrgScript(pkScript []byte) func(*wire.MsgBlock) {
return func(b *wire.MsgBlock) {
b.Transactions[0].TxOut[0].PkScript = pkScript
}
}

// additionalPoWTx returns a function that itself takes a block and modifies it
// by adding the the provided transaction to the regular transaction tree.
func additionalPoWTx(tx *wire.MsgTx) func(*wire.MsgBlock) {
Expand Down
9 changes: 0 additions & 9 deletions blockmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import (
)

const (
chanBufferSize = 50

// minInFlightBlocks is the minimum number of blocks that should be
// in the request queue for headers-first mode before requesting
// more.
Expand Down Expand Up @@ -151,13 +149,6 @@ type calcNextReqDifficultyMsg struct {
reply chan calcNextReqDifficultyResponse
}

// calcNextReqDiffNodeResponse is a response sent to the reply channel of a
// calcNextReqDiffNodeMsg query.
type calcNextReqDiffNodeResponse struct {
difficulty uint32
err error
}

// calcNextReqDiffNodeMsg is a message type to be sent across the message
// channel for requesting the required difficulty for some block building on
// the given block hash.
Expand Down
2 changes: 0 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const (
defaultMaxRPCClients = 10
defaultMaxRPCWebsockets = 25
defaultMaxRPCConcurrentReqs = 20
defaultVerifyEnabled = false
defaultDbType = "ffldb"
defaultFreeTxRelayLimit = 15.0
defaultBlockMinSize = 0
Expand All @@ -53,7 +52,6 @@ const (
blockMaxSizeMax = wire.MaxBlockPayload - 1000
defaultAddrIndex = false
defaultGenerate = false
defaultNonAggressive = false
defaultNoMiningStateSync = false
defaultAllowOldVotes = false
defaultMaxOrphanTransactions = 1000
Expand Down
13 changes: 0 additions & 13 deletions database/ffldb/dbcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@ const (
// threshold in between database cache flushes when the cache size has
// not been exceeded.
defaultFlushSecs = 300 // 5 minutes

// ldbBatchHeaderSize is the size of a leveldb batch header which
// includes the sequence header and record counter.
//
// ldbRecordIKeySize is the size of the ikey used internally by leveldb
// when appending a record to a batch.
//
// These are used to help preallocate space needed for a batch in one
// allocation instead of letting leveldb itself constantly grow it.
// This results in far less pressure on the GC and consequently helps
// prevent the GC from allocating a lot of extra unneeded space.
ldbBatchHeaderSize = 12
ldbRecordIKeySize = 8
)

// ldbCacheIter wraps a treap iterator to provide the additional functionality
Expand Down
49 changes: 1 addition & 48 deletions dcrec/edwards/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,16 @@ var (

// fieldIntSize is the size of a field element encoded
// as bytes.
fieldIntSize = 32
fieldElementSize = 10
fieldElementBytesSize = 40
fieldIntSize = 32
)

// feZero is the field element representation of zero.
var feZero = edwards25519.FieldElement{
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
}

// feOne is the field element representation of one. This is
// also the neutral (null) element.
var feOne = edwards25519.FieldElement{
1, 0, 0, 0, 0,
0, 0, 0, 0, 0,
}

// feTwo is the field element representation of one.
var feTwo = edwards25519.FieldElement{
1, 0, 0, 0, 0,
0, 0, 0, 0, 0,
}

// feThree is the field element representation of one.
var feThree = edwards25519.FieldElement{
3, 0, 0, 0, 0,
0, 0, 0, 0, 0,
}

// feA is the field element representation of one.
var feA = edwards25519.FieldElement{
486662, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Expand All @@ -69,35 +49,8 @@ var fed2 = edwards25519.FieldElement{
15978800, -12551817, -6495438, 29715968, 9444199,
}

// feSqrtM1 is the field element representation of M^(1/2).
var feSqrtM1 = edwards25519.FieldElement{
-32595792, -7943725, 9377950, 3500415, 12389472,
-272473, -25146209, -2005654, 326686, 11406482,
}

// feI is the field element representation of I.
var feI = edwards25519.FieldElement{
-32595792, -7943725, 9377950, 3500415, 12389472,
-272473, -25146209, -2005654, 326686, 11406482,
}

// feExtBasePoint is the base point of the curve represented
// in projective extended format with field elements.
var feExtBasePoint = edwards25519.ExtendedGroupElement{
X: edwards25519.FieldElement{
25485296, 5318399, 8791791, -8299916, -14349720,
6939349, -3324311, -7717049, 7287234, -6577708,
},
Y: edwards25519.FieldElement{
-758052, -1832720, 13046421, -4857925, 6576754,
14371947, -13139572, 6845540, -2198883, -4003719,
},
Z: edwards25519.FieldElement{
-947565, 6097708, -469190, 10704810, -8556274,
-15589498, -16424464, -16608899, 14028613, -5004649,
},
T: edwards25519.FieldElement{
6966464, -2456167, 7033433, 6781840, 28785542,
12262365, -2659449, 13959020, -21013759, -5262166,
},
}
19 changes: 0 additions & 19 deletions dcrec/edwards/primitives.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package edwards

import (
"bytes"
"fmt"
"math/big"

Expand Down Expand Up @@ -85,15 +84,6 @@ func copyBytes64(aB []byte) *[64]byte {
return s
}

// zeroArray zeroes the memory of a scalar array.
func zeroArray(a *[PrivScalarSize]byte) {
for i := 0; i < PrivScalarSize; i++ {
a[i] = 0x00
}

return
}

// zeroSlice zeroes the memory of a scalar byte slice.
func zeroSlice(s []byte) {
for i := 0; i < PrivScalarSize; i++ {
Expand Down Expand Up @@ -297,15 +287,6 @@ func FieldElementToEncodedBytes(fe *edwards25519.FieldElement) *[32]byte {
return s
}

// feEqual checks if two field elements equate.
func feEqual(a, b *edwards25519.FieldElement) bool {
aB := new([32]byte)
edwards25519.FeToBytes(aB, a)
bB := new([32]byte)
edwards25519.FeToBytes(bB, b)
return bytes.Equal(aB[:], bB[:])
}

// invert inverts a big integer over the Ed25519 curve.
func (curve *TwistedEdwardsCurve) invert(a *big.Int) *big.Int {
sub2 := new(big.Int).Sub(curve.P, two)
Expand Down
6 changes: 1 addition & 5 deletions dcrec/secp256k1/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ const (
// 2^(fieldBase*i) where i is the word position.
fieldBase = 26

// fieldOverflowBits is the minimum number of "overflow" bits for each
// word in the field value.
fieldOverflowBits = 32 - fieldBase

// fieldBaseMask is the mask for the bits in each word needed to
// represent the numeric base of each word (except the most significant
// word).
Expand Down Expand Up @@ -581,7 +577,7 @@ func (f *fieldVal) Add2(val *fieldVal, val2 *fieldVal) *fieldVal {
// f.MulInt(2).Add(f2) so that f = 2 * f + f2.
func (f *fieldVal) MulInt(val uint) *fieldVal {
// Since each word of the field representation can hold up to
// fieldOverflowBits extra bits which will be normalized out, it's safe
// 32 - fieldBase extra bits which will be normalized out, it's safe
// to multiply each word without using a larger type or carry
// propagation so long as the values won't overflow a uint32. This
// could obviously be done in a loop, but the unrolled version is
Expand Down
25 changes: 0 additions & 25 deletions dcrec/secp256k1/schnorr/primitives.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,6 @@ func copyBytes(aB []byte) *[32]byte {
return s
}

// copyBytes64 copies a byte slice to a 64 byte array.
func copyBytes64(aB []byte) *[64]byte {
if aB == nil {
return nil
}

s := new([64]byte)

// If we have a short byte string, expand
// it so that it's long enough.
aBLen := len(aB)
if aBLen < 64 {
diff := 64 - aBLen
for i := 0; i < diff; i++ {
aB = append([]byte{0x00}, aB...)
}
}

for i := 0; i < 64; i++ {
s[i] = aB[i]
}

return s
}

// BigIntToEncodedBytes converts a big integer into its corresponding
// 32 byte little endian representation.
func BigIntToEncodedBytes(a *big.Int) *[32]byte {
Expand Down
1 change: 0 additions & 1 deletion ipc.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ type lifetimeAction byte

const (
lifetimeEventDBOpen lifetimeAction = iota
lifetimeEventTicketDB
lifetimeEventP2PServer
)

Expand Down
47 changes: 0 additions & 47 deletions mining.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ import (
)

const (
// minHighPriority is the minimum priority value that allows a
// transaction to be considered high priority.
minHighPriority = dcrutil.AtomsPerCoin * 144.0 / 250

// generatedBlockVersion is the version of the block being generated for
// the main network. It is defined as a constant here rather than using
// the wire.BlockVersion constant since a change in the block version
Expand Down Expand Up @@ -167,49 +163,6 @@ func compareStakePriority(i, j *txPrioItem) int {
return 0
}

// txPQByPriority sorts a txPriorityQueue by transaction priority and then fees
// per kilobyte.
func txPQByPriority(pq *txPriorityQueue, i, j int) bool {
// Using > here so that pop gives the highest priority item as opposed
// to the lowest. Sort by priority first, then fee.
if pq.items[i].priority == pq.items[j].priority {
return pq.items[i].feePerKB > pq.items[j].feePerKB
}
return pq.items[i].priority > pq.items[j].priority
}

// txPQByStakeAndPriority sorts a txPriorityQueue by stake priority then
// transaction priority, and then fees per kilobyte.
func txPQByStakeAndPriority(pq *txPriorityQueue, i, j int) bool {
// Sort by stake priority, continue if they're the same stake priority.
cmp := compareStakePriority(pq.items[i], pq.items[j])
if cmp == 1 {
return true
}
if cmp == -1 {
return false
}

// Using > here so that pop gives the highest priority item as opposed
// to the lowest. Sort by priority first, then fee.
if pq.items[i].priority == pq.items[j].priority {
return pq.items[i].feePerKB > pq.items[j].feePerKB
}

return pq.items[i].priority > pq.items[j].priority
}

// txPQByFee sorts a txPriorityQueue by fees per kilobyte and then transaction
// priority.
func txPQByFee(pq *txPriorityQueue, i, j int) bool {
// Using > here so that pop gives the highest fee item as opposed
// to the lowest. Sort by fee first, then priority.
if pq.items[i].feePerKB == pq.items[j].feePerKB {
return pq.items[i].priority > pq.items[j].priority
}
return pq.items[i].feePerKB > pq.items[j].feePerKB
}

// txPQByStakeAndFee sorts a txPriorityQueue by stake priority, followed by
// fees per kilobyte, and then transaction priority.
func txPQByStakeAndFee(pq *txPriorityQueue, i, j int) bool {
Expand Down
Loading

0 comments on commit a923485

Please sign in to comment.