Skip to content

Commit 4eb5c1d

Browse files
joemphilipsCryptAxe
authored andcommitted
rename all SidechainDB class according to bitcoin style guide (#10)
1 parent c4beef5 commit 4eb5c1d

File tree

5 files changed

+42
-42
lines changed

5 files changed

+42
-42
lines changed

src/sidechaindb.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
#include "utilstrencodings.h"
1515
#include "wallet/wallet.h"
1616

17-
SidechainDB::SidechainDB()
17+
CSidechainDB::CSidechainDB()
1818
{
1919
SCDB.resize(ARRAYLEN(ValidSidechains));
2020
}
2121

22-
void SidechainDB::AddDeposits(const std::vector<CTransaction>& vtx)
22+
void CSidechainDB::AddDeposits(const std::vector<CTransaction>& vtx)
2323
{
2424
std::vector<SidechainDeposit> vDeposit;
2525
for (const CTransaction& tx : vtx) {
@@ -65,7 +65,7 @@ void SidechainDB::AddDeposits(const std::vector<CTransaction>& vtx)
6565
}
6666
}
6767

68-
bool SidechainDB::AddWTJoin(uint8_t nSidechain, const CTransaction& tx)
68+
bool CSidechainDB::AddWTJoin(uint8_t nSidechain, const CTransaction& tx)
6969
{
7070
if (vWTJoinCache.size() >= SIDECHAIN_MAX_WT)
7171
return false;
@@ -82,7 +82,7 @@ bool SidechainDB::AddWTJoin(uint8_t nSidechain, const CTransaction& tx)
8282
return false;
8383
}
8484

85-
bool SidechainDB::HaveDepositCached(const SidechainDeposit &deposit) const
85+
bool CSidechainDB::HaveDepositCached(const SidechainDeposit &deposit) const
8686
{
8787
for (const SidechainDeposit& d : vDepositCache) {
8888
if (d == deposit)
@@ -91,7 +91,7 @@ bool SidechainDB::HaveDepositCached(const SidechainDeposit &deposit) const
9191
return false;
9292
}
9393

94-
bool SidechainDB::HaveWTJoinCached(const uint256& wtxid) const
94+
bool CSidechainDB::HaveWTJoinCached(const uint256& wtxid) const
9595
{
9696
for (const CTransaction& tx : vWTJoinCache) {
9797
if (tx.GetHash() == wtxid)
@@ -100,7 +100,7 @@ bool SidechainDB::HaveWTJoinCached(const uint256& wtxid) const
100100
return false;
101101
}
102102

103-
std::vector<SidechainDeposit> SidechainDB::GetDeposits(uint8_t nSidechain) const
103+
std::vector<SidechainDeposit> CSidechainDB::GetDeposits(uint8_t nSidechain) const
104104
{
105105
std::vector<SidechainDeposit> vSidechainDeposit;
106106
for (size_t i = 0; i < vDepositCache.size(); i++) {
@@ -110,7 +110,7 @@ std::vector<SidechainDeposit> SidechainDB::GetDeposits(uint8_t nSidechain) const
110110
return vSidechainDeposit;
111111
}
112112

113-
CTransaction SidechainDB::GetWTJoinTx(uint8_t nSidechain, int nHeight) const
113+
CTransaction CSidechainDB::GetWTJoinTx(uint8_t nSidechain, int nHeight) const
114114
{
115115
if (!HasState())
116116
return CTransaction();
@@ -217,7 +217,7 @@ CTransaction SidechainDB::GetWTJoinTx(uint8_t nSidechain, int nHeight) const
217217
return mtx;
218218
}
219219

220-
CScript SidechainDB::CreateStateScript(int nHeight) const
220+
CScript CSidechainDB::CreateStateScript(int nHeight) const
221221
{
222222
if (!HasState())
223223
return CScript();
@@ -273,7 +273,7 @@ CScript SidechainDB::CreateStateScript(int nHeight) const
273273
return script;
274274
}
275275

276-
uint256 SidechainDB::GetSCDBHash() const
276+
uint256 CSidechainDB::GetSCDBHash() const
277277
{
278278
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
279279
for (const SCDBIndex& index : SCDB) {
@@ -287,7 +287,7 @@ uint256 SidechainDB::GetSCDBHash() const
287287
return ss.GetHash();
288288
}
289289

290-
bool SidechainDB::ReadStateScript(const CTransactionRef& coinbase)
290+
bool CSidechainDB::ReadStateScript(const CTransactionRef& coinbase)
291291
{
292292
/*
293293
* Only one state script of the current version is valid.
@@ -336,12 +336,12 @@ bool SidechainDB::ReadStateScript(const CTransactionRef& coinbase)
336336

337337
// Invalid or no update script try to apply default
338338
if (!ApplyDefaultUpdate())
339-
LogPrintf("SidechainDB::ReadStateScript: Invalid update & failed to apply default update!\n");
339+
LogPrintf("CSidechainDB::ReadStateScript: Invalid update & failed to apply default update!\n");
340340

341341
return false;
342342
}
343343

344-
bool SidechainDB::Update(uint8_t nSidechain, uint16_t nBlocks, uint16_t nScore, uint256 wtxid, bool fJustCheck)
344+
bool CSidechainDB::Update(uint8_t nSidechain, uint16_t nBlocks, uint16_t nScore, uint256 wtxid, bool fJustCheck)
345345
{
346346
if (!SidechainNumberValid(nSidechain))
347347
return false;
@@ -362,7 +362,7 @@ bool SidechainDB::Update(uint8_t nSidechain, uint16_t nBlocks, uint16_t nScore,
362362
return (index.InsertMember(member));
363363
}
364364

365-
bool SidechainDB::Update(int nHeight, const uint256& hashBlock, const CTransactionRef& coinbase)
365+
bool CSidechainDB::Update(int nHeight, const uint256& hashBlock, const CTransactionRef& coinbase)
366366
{
367367
if (!coinbase || !coinbase->IsCoinBase())
368368
return false;
@@ -376,7 +376,7 @@ bool SidechainDB::Update(int nHeight, const uint256& hashBlock, const CTransacti
376376

377377
// Apply state script
378378
if (!ReadStateScript(coinbase))
379-
LogPrintf("SidechainDB::Update: failed to read state script\n");
379+
LogPrintf("CSidechainDB::Update: failed to read state script\n");
380380

381381
// Scan for h*(s) in coinbase outputs
382382
for (const CTxOut& out : coinbase->vout) {
@@ -426,7 +426,7 @@ bool SidechainDB::Update(int nHeight, const uint256& hashBlock, const CTransacti
426426
}
427427

428428
if (!fValid) {
429-
LogPrintf("SidechainDB::Update: h* with invalid block height ignored: %s\n", hashCritical.ToString());
429+
LogPrintf("CSidechainDB::Update: h* with invalid block height ignored: %s\n", hashCritical.ToString());
430430
continue;
431431
}
432432

@@ -449,17 +449,17 @@ bool SidechainDB::Update(int nHeight, const uint256& hashBlock, const CTransacti
449449
return true;
450450
}
451451

452-
uint256 SidechainDB::GetHashBlockLastSeen()
452+
uint256 CSidechainDB::GetHashBlockLastSeen()
453453
{
454454
return hashBlockLastSeen;
455455
}
456456

457-
std::multimap<uint256, int> SidechainDB::GetLinkingData() const
457+
std::multimap<uint256, int> CSidechainDB::GetLinkingData() const
458458
{
459459
return mapBMMLD;
460460
}
461461

462-
bool SidechainDB::HasState() const
462+
bool CSidechainDB::HasState() const
463463
{
464464
// Make sure that SCDB is actually initialized
465465
if (SCDB.size() != ARRAYLEN(ValidSidechains))
@@ -478,7 +478,7 @@ bool SidechainDB::HasState() const
478478
return false;
479479
}
480480

481-
std::vector<SidechainWTJoinState> SidechainDB::GetState(uint8_t nSidechain) const
481+
std::vector<SidechainWTJoinState> CSidechainDB::GetState(uint8_t nSidechain) const
482482
{
483483
if (!HasState() || !SidechainNumberValid(nSidechain))
484484
return std::vector<SidechainWTJoinState>();
@@ -491,7 +491,7 @@ std::vector<SidechainWTJoinState> SidechainDB::GetState(uint8_t nSidechain) cons
491491
return vState;
492492
}
493493

494-
bool SidechainDB::ApplyStateScript(const CScript& script, const std::vector<std::vector<SidechainWTJoinState>>& vState, bool fJustCheck)
494+
bool CSidechainDB::ApplyStateScript(const CScript& script, const std::vector<std::vector<SidechainWTJoinState>>& vState, bool fJustCheck)
495495
{
496496
if (script.size() < 4)
497497
return false;
@@ -547,7 +547,7 @@ bool SidechainDB::ApplyStateScript(const CScript& script, const std::vector<std:
547547
return true;
548548
}
549549

550-
bool SidechainDB::ApplyDefaultUpdate()
550+
bool CSidechainDB::ApplyDefaultUpdate()
551551
{
552552
if (!HasState())
553553
return true;
@@ -572,7 +572,7 @@ bool SidechainDB::ApplyDefaultUpdate()
572572
return true;
573573
}
574574

575-
bool SidechainDB::CheckWorkScore(const uint8_t& nSidechain, const uint256& wtxid) const
575+
bool CSidechainDB::CheckWorkScore(const uint8_t& nSidechain, const uint256& wtxid) const
576576
{
577577
if (!SidechainNumberValid(nSidechain))
578578
return false;
@@ -589,10 +589,10 @@ bool SidechainDB::CheckWorkScore(const uint8_t& nSidechain, const uint256& wtxid
589589
return false;
590590
}
591591

592-
std::string SidechainDB::ToString() const
592+
std::string CSidechainDB::ToString() const
593593
{
594594
std::string str;
595-
str += "SidechainDB:\n";
595+
str += "CSidechainDB:\n";
596596
for (const Sidechain& s : ValidSidechains) {
597597
// Print sidechain name
598598
str += "Sidechain: " + s.GetSidechainName() + "\n";

src/sidechaindb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ struct SidechainDeposit;
1919
struct SidechainWTJoinState;
2020
struct SCDBIndex;
2121

22-
class SidechainDB
22+
class CSidechainDB
2323
{
2424
public:
25-
SidechainDB();
25+
CSidechainDB();
2626

2727
/** Add deposit to cache */
2828
void AddDeposits(const std::vector<CTransaction>& vtx);

src/test/sidechaindb_tests.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ BOOST_FIXTURE_TEST_SUITE(sidechaindb_tests, TestChain100Setup)
2929

3030
BOOST_AUTO_TEST_CASE(sidechaindb_isolated)
3131
{
32-
// Test SidechainDB without blocks
33-
SidechainDB scdb;
32+
// Test CSidechainDB without blocks
33+
CSidechainDB scdb;
3434

3535
uint256 hashWTTest = GetRandHash();
3636
uint256 hashWTHivemind = GetRandHash();
@@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(sidechaindb_MultipleTauPeriods)
5252
{
5353
// Test SCDB with multiple tau periods,
5454
// approve multiple WT^s on the same sidechain.
55-
SidechainDB scdb;
55+
CSidechainDB scdb;
5656
const Sidechain& test = ValidSidechains[SIDECHAIN_TEST];
5757

5858
// WT^ hash for first period
@@ -97,7 +97,7 @@ BOOST_AUTO_TEST_CASE(sidechaindb_EmptyStateScript)
9797
// Test empty SCDB
9898
const Sidechain& sidechainTest = ValidSidechains[SIDECHAIN_TEST];
9999
CScript scriptEmptyExpected = CScript();
100-
SidechainDB scdbEmpty;
100+
CSidechainDB scdbEmpty;
101101
BOOST_CHECK(scriptEmptyExpected == scdbEmpty.CreateStateScript(sidechainTest.GetTau() - 1));
102102
}
103103

@@ -112,7 +112,7 @@ BOOST_AUTO_TEST_CASE(sidechaindb_PopulatedStateScript)
112112
<< SCOP_VERIFY << SCOP_SC_DELIM
113113
<< SCOP_VERIFY;
114114

115-
SidechainDB scdbPopulated;
115+
CSidechainDB scdbPopulated;
116116

117117
uint256 hashWTTest = GetRandHash();
118118
uint256 hashWTHivemind = GetRandHash();
@@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE(sidechaindb_FullStateScript)
138138
<< SCOP_SC_DELIM
139139
<< SCOP_VERIFY << SCOP_WT_DELIM << SCOP_REJECT << SCOP_WT_DELIM << SCOP_REJECT;
140140

141-
SidechainDB scdbFull;
141+
CSidechainDB scdbFull;
142142

143143
uint256 hashWTTest1 = GetRandHash();
144144
uint256 hashWTTest2 = GetRandHash();
@@ -178,7 +178,7 @@ BOOST_AUTO_TEST_CASE(sidechaindb_CountStateScript)
178178
<< SCOP_REJECT << SCOP_WT_DELIM << SCOP_VERIFY
179179
<< SCOP_SC_DELIM
180180
<< SCOP_REJECT << SCOP_WT_DELIM << SCOP_VERIFY << SCOP_WT_DELIM << SCOP_REJECT;
181-
SidechainDB scdbCount;
181+
CSidechainDB scdbCount;
182182

183183
uint256 hashWTTest = GetRandHash();
184184

@@ -203,7 +203,7 @@ BOOST_AUTO_TEST_CASE(sidechaindb_CountStateScript)
203203

204204
BOOST_AUTO_TEST_CASE(sidechaindb_PositionStateScript)
205205
{
206-
// Verify that state scripts created based on known SidechainDB
206+
// Verify that state scripts created based on known CSidechainDB
207207
// state examples are formatted as expected
208208
const Sidechain& sidechainTest = ValidSidechains[SIDECHAIN_TEST];
209209

@@ -216,7 +216,7 @@ BOOST_AUTO_TEST_CASE(sidechaindb_PositionStateScript)
216216
<< SCOP_SC_DELIM
217217
<< SCOP_REJECT << SCOP_WT_DELIM << SCOP_REJECT << SCOP_WT_DELIM << SCOP_VERIFY;
218218

219-
SidechainDB scdbPosition;
219+
CSidechainDB scdbPosition;
220220

221221
uint256 hashWTTest1 = GetRandHash();
222222
uint256 hashWTTest2 = GetRandHash();
@@ -249,7 +249,7 @@ BOOST_AUTO_TEST_CASE(sidechaindb_PositionStateScript)
249249
BOOST_AUTO_TEST_CASE(bmm_checkCriticalHashValid)
250250
{
251251
// Check that valid critical hash is added to ratchet
252-
SidechainDB scdb;
252+
CSidechainDB scdb;
253253

254254
// Create h* bribe script
255255
uint256 hashCritical = GetRandHash();
@@ -281,7 +281,7 @@ BOOST_AUTO_TEST_CASE(bmm_checkCriticalHashInvalid)
281281
{
282282
// Make sure that a invalid h* with a valid block number will
283283
// be rejected.
284-
SidechainDB scdb;
284+
CSidechainDB scdb;
285285

286286
// Create h* bribe script
287287
CScript scriptPubKey;
@@ -308,7 +308,7 @@ BOOST_AUTO_TEST_CASE(bmm_checkBlockNumberValid)
308308
{
309309
// Make sure that a valid h* with a valid block number
310310
// will be accepted.
311-
SidechainDB scdb;
311+
CSidechainDB scdb;
312312

313313
// We have to add the first h* to the ratchet so that
314314
// there is something to compare with.
@@ -353,7 +353,7 @@ BOOST_AUTO_TEST_CASE(bmm_checkBlockNumberInvalid)
353353
{
354354
// Try to add a valid h* with an invalid block number
355355
// and make sure it is skipped.
356-
SidechainDB scdb;
356+
CSidechainDB scdb;
357357

358358
// We have to add the first h* to the ratchet so that
359359
// there is something to compare with.

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE;
8888
CBlockPolicyEstimator feeEstimator;
8989
CTxMemPool mempool(&feeEstimator);
9090

91-
SidechainDB scdb;
91+
CSidechainDB scdb;
9292

9393
static void CheckBlockIndex(const Consensus::Params& consensusParams);
9494

src/validation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class CBlockPolicyEstimator;
4343
class CTxMemPool;
4444
class CValidationInterface;
4545
class CValidationState;
46-
class SidechainDB;
46+
class CSidechainDB;
4747
struct ChainTxData;
4848

4949
struct PrecomputedTransactionData;
@@ -528,7 +528,7 @@ void DumpMempool();
528528
bool LoadMempool();
529529

530530
/** Tracks validation status of sidechain WT^(s) */
531-
extern SidechainDB scdb;
531+
extern CSidechainDB scdb;
532532

533533
/** Remove extra coinbase(s) from chainActive */
534534
void PruneCoinbaseCache();

0 commit comments

Comments
 (0)