Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaning unused code #2558

Merged
merged 2 commits into from
Sep 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/coins.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ class CCoinsViewCursor

virtual bool GetKey(COutPoint& key) const = 0;
virtual bool GetValue(Coin& coin) const = 0;
/* Don't care about GetKeySize here */
virtual unsigned int GetValueSize() const = 0;

virtual bool Valid() const = 0;
Expand Down
17 changes: 0 additions & 17 deletions src/dbwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,6 @@ class CDBIterator
return CDataStream(slKey.data(), slKey.data() + slKey.size(), SER_DISK, CLIENT_VERSION);
}

unsigned int GetKeySize()
{
return piter->key().size();
}

template<typename V> bool GetValue(V& value)
{
leveldb::Slice slValue = piter->value();
Expand Down Expand Up @@ -487,18 +482,6 @@ class CDBTransactionIterator
}
}

unsigned int GetKeySize()
{
if (!Valid()) {
return 0;
}
if (curIsParent) {
return parentIt->GetKeySize();
} else {
return transactionIt->first.vKey.size();
}
}

template<typename V>
bool GetValue(V& value)
{
Expand Down
7 changes: 0 additions & 7 deletions src/httpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,6 @@ class WorkQueue
running = false;
cond.notify_all();
}

/** Return current depth of queue */
size_t Depth()
{
std::unique_lock<std::mutex> lock(cs);
return queue.size();
}
};

struct HTTPPathHandler
Expand Down
21 changes: 5 additions & 16 deletions src/key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,21 +164,10 @@ void CKey::MakeNewKey(bool fCompressedIn)
fCompressed = fCompressedIn;
}

bool CKey::SetPrivKey(const CPrivKey& privkey, bool fCompressedIn)
{
if (!ec_privkey_import_der(secp256k1_context_sign, (unsigned char*)begin(), &privkey[0], privkey.size()))
return false;
fCompressed = fCompressedIn;
fValid = true;
return true;
}

uint256 CKey::GetPrivKey_256()
{
void* key = keydata.data();
uint256* key_256 = (uint256*)key;

return *key_256;
return *(uint256*)key;
}

CPrivKey CKey::GetPrivKey() const
Expand All @@ -198,8 +187,8 @@ CPubKey CKey::GetPubKey() const
{
assert(fValid);
secp256k1_pubkey pubkey;
size_t clen = CPubKey::PUBLIC_KEY_SIZE;
CPubKey result;
size_t clen = 65;
int ret = secp256k1_ec_pubkey_create(secp256k1_context_sign, &pubkey, begin());
assert(ret);
secp256k1_ec_pubkey_serialize(secp256k1_context_sign, (unsigned char*)result.begin(), &clen, &pubkey, fCompressed ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED);
Expand Down Expand Up @@ -289,13 +278,13 @@ bool CKey::Derive(CKey& keyChild, ChainCode &ccChild, unsigned int nChild, const
return ret;
}

bool CExtKey::Derive(CExtKey& out, unsigned int nChild) const
bool CExtKey::Derive(CExtKey& out, unsigned int _nChild) const
{
out.nDepth = nDepth + 1;
CKeyID id = key.GetPubKey().GetID();
memcpy(&out.vchFingerprint[0], &id, 4);
out.nChild = nChild;
return key.Derive(out.key, out.chaincode, nChild, chaincode);
out.nChild = _nChild;
return key.Derive(out.key, out.chaincode, _nChild, chaincode);
}

void CExtKey::SetSeed(const unsigned char* seed, unsigned int nSeedLen)
Expand Down
3 changes: 0 additions & 3 deletions src/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ class CKey
//! Check whether the public key corresponding to this private key is (to be) compressed.
bool IsCompressed() const { return fCompressed; }

//! Initialize from a CPrivKey (serialized secp256k1 private key data).
bool SetPrivKey(const CPrivKey& vchPrivKey, bool fCompressed);

//! Generate a new private key using a cryptographic PRNG.
void MakeNewKey(bool fCompressed);

Expand Down
16 changes: 0 additions & 16 deletions src/pivx-tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,6 @@ static bool findSighashFlags(int& flags, const std::string& flagStr)
return false;
}

uint256 ParseHashUO(std::map<std::string, UniValue>& o, std::string strKey)
{
if (!o.count(strKey))
return UINT256_ZERO;
return ParseHashUV(o[strKey], strKey);
}

static inline int64_t roundint64(double d)
{
return (int64_t)(d > 0 ? d + 0.5 : d - 0.5);
Expand All @@ -437,15 +430,6 @@ static CAmount AmountFromValue(const UniValue& value)
return nAmount;
}

std::vector<unsigned char> ParseHexUO(std::map<std::string, UniValue>& o, std::string strKey)
{
if (!o.count(strKey)) {
std::vector<unsigned char> emptyVec;
return emptyVec;
}
return ParseHexUV(o[strKey], strKey);
}

static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
{
int nHashType = SIGHASH_ALL;
Expand Down
1 change: 0 additions & 1 deletion src/rpc/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ namespace RPCServer
void OnStarted(std::function<void ()> slot);
void OnStopped(std::function<void ()> slot);
void OnPreCommand(std::function<void (const CRPCCommand&)> slot);
void OnPostCommand(std::function<void (const CRPCCommand&)> slot);
}

class CBlockIndex;
Expand Down
23 changes: 0 additions & 23 deletions src/test/key_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,6 @@ static const std::string addr2C = "DNBVSAoc2whPFjZVAZ1pQbXPJk1LRrDC8Q";
static const std::string strAddressBad ="Xta1praZQjyELweyMByXyiREw1ZRsjXzVP";


#ifdef KEY_TESTS_DUMPINFO
void dumpKeyInfo(uint256 privkey)
{
CKey key;
key.resize(32);
memcpy(&secret[0], &privkey, 32);
std::vector<unsigned char> sec;
sec.resize(32);
memcpy(&sec[0], &secret[0], 32);
printf(" * secret (hex): %s\n", HexStr(sec).c_str());

for (int nCompressed=0; nCompressed<2; nCompressed++)
{
printf(" * secret (base58): %s\n", KeyIO::EncodeSecret(secret));
CKey key;
key.SetSecret(secret, fCompressed);
std::vector<unsigned char> vchPubKey = key.GetPubKey();
printf(" * pubkey (hex): %s\n", HexStr(vchPubKey).c_str());
printf(" * address (base58): %s\n", EncodeDestination(vchPubKey).c_str());
}
}
#endif

BOOST_FIXTURE_TEST_SUITE(key_tests, TestingSetup)

BOOST_AUTO_TEST_CASE(key_test1)
Expand Down
5 changes: 0 additions & 5 deletions src/test/script_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,6 @@ class TestBuilder
{
return comment;
}

const CScript& GetScriptPubKey()
{
return creditTx->vout[0].scriptPubKey;
}
};

std::string JSONPrettyPrint(const UniValue& univalue)
Expand Down