Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Josh Wilcox
crown-core
Commits
ffab5ed8
Commit
ffab5ed8
authored
10 years ago
by
Pieter Wuille
Browse files
Options
Download
Email Patches
Plain Diff
Get rid of the dummy CCoinsViewCache constructor arg
parent
b8dc65d0
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
src/bitcoin-tx.cpp
+1
-1
src/bitcoin-tx.cpp
src/coins.cpp
+2
-2
src/coins.cpp
src/coins.h
+2
-2
src/coins.h
src/init.cpp
+1
-1
src/init.cpp
src/main.cpp
+5
-5
src/main.cpp
src/miner.cpp
+2
-2
src/miner.cpp
src/rpcblockchain.cpp
+1
-1
src/rpcblockchain.cpp
src/rpcrawtransaction.cpp
+2
-2
src/rpcrawtransaction.cpp
src/test/coins_tests.cpp
+2
-2
src/test/coins_tests.cpp
src/test/script_P2SH_tests.cpp
+1
-1
src/test/script_P2SH_tests.cpp
src/test/test_bitcoin.cpp
+1
-1
src/test/test_bitcoin.cpp
src/test/transaction_tests.cpp
+2
-2
src/test/transaction_tests.cpp
src/txmempool.cpp
+1
-1
src/txmempool.cpp
src/txmempool.h
+1
-1
src/txmempool.h
with
24 additions
and
24 deletions
+24
-24
src/bitcoin-tx.cpp
View file @
ffab5ed8
...
...
@@ -340,7 +340,7 @@ static void MutateTxSign(CMutableTransaction& tx, const string& flagStr)
CMutableTransaction
mergedTx
(
txVariants
[
0
]);
bool
fComplete
=
true
;
CCoinsView
viewDummy
;
CCoinsViewCache
view
(
viewDummy
);
CCoinsViewCache
view
(
&
viewDummy
);
if
(
!
registers
.
count
(
"privatekeys"
))
throw
runtime_error
(
"privatekeys register variable must be set."
);
...
...
This diff is collapsed.
Click to expand it.
src/coins.cpp
View file @
ffab5ed8
...
...
@@ -59,7 +59,7 @@ bool CCoinsView::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) { ret
bool
CCoinsView
::
GetStats
(
CCoinsStats
&
stats
)
const
{
return
false
;
}
CCoinsViewBacked
::
CCoinsViewBacked
(
CCoinsView
&
viewIn
)
:
base
(
&
viewIn
)
{
}
CCoinsViewBacked
::
CCoinsViewBacked
(
CCoinsView
*
viewIn
)
:
base
(
viewIn
)
{
}
bool
CCoinsViewBacked
::
GetCoins
(
const
uint256
&
txid
,
CCoins
&
coins
)
const
{
return
base
->
GetCoins
(
txid
,
coins
);
}
bool
CCoinsViewBacked
::
HaveCoins
(
const
uint256
&
txid
)
const
{
return
base
->
HaveCoins
(
txid
);
}
uint256
CCoinsViewBacked
::
GetBestBlock
()
const
{
return
base
->
GetBestBlock
();
}
...
...
@@ -69,7 +69,7 @@ bool CCoinsViewBacked::GetStats(CCoinsStats &stats) const { return base->GetStat
CCoinsKeyHasher
::
CCoinsKeyHasher
()
:
salt
(
GetRandHash
())
{}
CCoinsViewCache
::
CCoinsViewCache
(
CCoinsView
&
baseIn
,
bool
fDummy
)
:
CCoinsViewBacked
(
baseIn
),
hasModifier
(
false
),
hashBlock
(
0
)
{
}
CCoinsViewCache
::
CCoinsViewCache
(
CCoinsView
*
baseIn
)
:
CCoinsViewBacked
(
baseIn
),
hasModifier
(
false
),
hashBlock
(
0
)
{
}
CCoinsViewCache
::~
CCoinsViewCache
()
{
...
...
This diff is collapsed.
Click to expand it.
src/coins.h
View file @
ffab5ed8
...
...
@@ -333,7 +333,7 @@ protected:
CCoinsView
*
base
;
public:
CCoinsViewBacked
(
CCoinsView
&
viewIn
);
CCoinsViewBacked
(
CCoinsView
*
viewIn
);
bool
GetCoins
(
const
uint256
&
txid
,
CCoins
&
coins
)
const
;
bool
HaveCoins
(
const
uint256
&
txid
)
const
;
uint256
GetBestBlock
()
const
;
...
...
@@ -375,7 +375,7 @@ protected:
mutable
CCoinsMap
cacheCoins
;
public:
CCoinsViewCache
(
CCoinsView
&
baseIn
,
bool
fDummy
=
false
);
CCoinsViewCache
(
CCoinsView
*
baseIn
);
~
CCoinsViewCache
();
// Standard CCoinsView methods
...
...
This diff is collapsed.
Click to expand it.
src/init.cpp
View file @
ffab5ed8
...
...
@@ -958,7 +958,7 @@ bool AppInit2(boost::thread_group& threadGroup)
pblocktree
=
new
CBlockTreeDB
(
nBlockTreeDBCache
,
false
,
fReindex
);
pcoinsdbview
=
new
CCoinsViewDB
(
nCoinDBCache
,
false
,
fReindex
);
pcoinsTip
=
new
CCoinsViewCache
(
*
pcoinsdbview
);
pcoinsTip
=
new
CCoinsViewCache
(
pcoinsdbview
);
if
(
fReindex
)
pblocktree
->
WriteReindexing
(
true
);
...
...
This diff is collapsed.
Click to expand it.
src/main.cpp
View file @
ffab5ed8
...
...
@@ -896,12 +896,12 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
{
CCoinsView dummy;
CCoinsViewCache view(dummy);
CCoinsViewCache view(
&
dummy);
int64_t nValueIn = 0;
{
LOCK(pool.cs);
CCoinsViewMemPool viewMemPool(
*
pcoinsTip, pool);
CCoinsViewMemPool viewMemPool(pcoinsTip, pool);
view.SetBackend(viewMemPool);
// do we already have it?
...
...
@@ -1835,7 +1835,7 @@ bool static DisconnectTip(CValidationState &state) {
// Apply the block atomically to the chain state.
int64_t nStart = GetTimeMicros();
{
CCoinsViewCache view(
*
pcoinsTip
, true
);
CCoinsViewCache view(pcoinsTip);
if (!DisconnectBlock(block, state, pindexDelete, view))
return error("DisconnectTip() : DisconnectBlock %s failed", pindexDelete->GetBlockHash().ToString());
assert(view.Flush());
...
...
@@ -1888,7 +1888,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
int64_t nTime3;
LogPrint("bench", " - Load block from disk: %.2fms [%.2fs]\n", (nTime2 - nTime1) * 0.001, nTimeReadFromDisk * 0.000001);
{
CCoinsViewCache view(
*
pcoinsTip
, true
);
CCoinsViewCache view(pcoinsTip);
CInv inv(MSG_BLOCK, pindexNew->GetBlockHash());
if (!ConnectBlock(*pblock, state, pindexNew, view)) {
if (state.IsInvalid())
...
...
@@ -2936,7 +2936,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth
nCheckDepth = chainActive.Height();
nCheckLevel = std::max(0, std::min(4, nCheckLevel));
LogPrintf("Verifying last %i blocks at level %i\n", nCheckDepth, nCheckLevel);
CCoinsViewCache coins(
*
coinsview
, true
);
CCoinsViewCache coins(coinsview);
CBlockIndex* pindexState = chainActive.Tip();
CBlockIndex* pindexFailure = NULL;
int nGoodTransactions = 0;
...
...
This diff is collapsed.
Click to expand it.
src/miner.cpp
View file @
ffab5ed8
...
...
@@ -116,7 +116,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
{
LOCK2
(
cs_main
,
mempool
.
cs
);
CBlockIndex
*
pindexPrev
=
chainActive
.
Tip
();
CCoinsViewCache
view
(
*
pcoinsTip
,
true
);
CCoinsViewCache
view
(
pcoinsTip
);
// Priority order to process transactions
list
<
COrphan
>
vOrphan
;
// list memory doesn't move
...
...
@@ -316,7 +316,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
CBlockIndex
indexDummy
(
*
pblock
);
indexDummy
.
pprev
=
pindexPrev
;
indexDummy
.
nHeight
=
pindexPrev
->
nHeight
+
1
;
CCoinsViewCache
viewNew
(
*
pcoinsTip
,
true
);
CCoinsViewCache
viewNew
(
pcoinsTip
);
CValidationState
state
;
if
(
!
ConnectBlock
(
*
pblock
,
state
,
&
indexDummy
,
viewNew
,
true
))
throw
std
::
runtime_error
(
"CreateNewBlock() : ConnectBlock failed"
);
...
...
This diff is collapsed.
Click to expand it.
src/rpcblockchain.cpp
View file @
ffab5ed8
...
...
@@ -381,7 +381,7 @@ Value gettxout(const Array& params, bool fHelp)
CCoins
coins
;
if
(
fMempool
)
{
LOCK
(
mempool
.
cs
);
CCoinsViewMemPool
view
(
*
pcoinsTip
,
mempool
);
CCoinsViewMemPool
view
(
pcoinsTip
,
mempool
);
if
(
!
view
.
GetCoins
(
hash
,
coins
))
return
Value
::
null
;
mempool
.
pruneSpent
(
hash
,
coins
);
// TODO: this should be done by the CCoinsViewMemPool
...
...
This diff is collapsed.
Click to expand it.
src/rpcrawtransaction.cpp
View file @
ffab5ed8
...
...
@@ -557,11 +557,11 @@ Value signrawtransaction(const Array& params, bool fHelp)
// Fetch previous transactions (inputs):
CCoinsView
viewDummy
;
CCoinsViewCache
view
(
viewDummy
);
CCoinsViewCache
view
(
&
viewDummy
);
{
LOCK
(
mempool
.
cs
);
CCoinsViewCache
&
viewChain
=
*
pcoinsTip
;
CCoinsViewMemPool
viewMempool
(
viewChain
,
mempool
);
CCoinsViewMemPool
viewMempool
(
&
viewChain
,
mempool
);
view
.
SetBackend
(
viewMempool
);
// temporarily switch cache backend to db+mempool view
BOOST_FOREACH
(
const
CTxIn
&
txin
,
mergedTx
.
vin
)
{
...
...
This diff is collapsed.
Click to expand it.
src/test/coins_tests.cpp
View file @
ffab5ed8
...
...
@@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE(coins_cache_simulation_test)
// The cache stack.
CCoinsViewTest
base
;
// A CCoinsViewTest at the bottom.
std
::
vector
<
CCoinsViewCache
*>
stack
;
// A stack of CCoinsViewCaches on top.
stack
.
push_back
(
new
CCoinsViewCache
(
base
,
false
));
// Start with one cache.
stack
.
push_back
(
new
CCoinsViewCache
(
&
base
));
// Start with one cache.
// Use a limited set of random transaction ids, so we do test overwriting entries.
std
::
vector
<
uint256
>
txids
;
...
...
@@ -151,7 +151,7 @@ BOOST_AUTO_TEST_CASE(coins_cache_simulation_test)
}
else
{
removed_all_caches
=
true
;
}
stack
.
push_back
(
new
CCoinsViewCache
(
*
tip
,
false
));
stack
.
push_back
(
new
CCoinsViewCache
(
tip
));
if
(
stack
.
size
()
==
4
)
{
reached_4_caches
=
true
;
}
...
...
This diff is collapsed.
Click to expand it.
src/test/script_P2SH_tests.cpp
View file @
ffab5ed8
...
...
@@ -255,7 +255,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
{
LOCK
(
cs_main
);
CCoinsView
coinsDummy
;
CCoinsViewCache
coins
(
coinsDummy
);
CCoinsViewCache
coins
(
&
coinsDummy
);
CBasicKeyStore
keystore
;
CKey
key
[
6
];
vector
<
CPubKey
>
keys
;
...
...
This diff is collapsed.
Click to expand it.
src/test/test_bitcoin.cpp
View file @
ffab5ed8
...
...
@@ -41,7 +41,7 @@ struct TestingSetup {
mapArgs
[
"-datadir"
]
=
pathTemp
.
string
();
pblocktree
=
new
CBlockTreeDB
(
1
<<
20
,
true
);
pcoinsdbview
=
new
CCoinsViewDB
(
1
<<
23
,
true
);
pcoinsTip
=
new
CCoinsViewCache
(
*
pcoinsdbview
);
pcoinsTip
=
new
CCoinsViewCache
(
pcoinsdbview
);
InitBlockIndex
();
#ifdef ENABLE_WALLET
bool
fFirstRun
;
...
...
This diff is collapsed.
Click to expand it.
src/test/transaction_tests.cpp
View file @
ffab5ed8
...
...
@@ -260,7 +260,7 @@ BOOST_AUTO_TEST_CASE(test_Get)
{
CBasicKeyStore
keystore
;
CCoinsView
coinsDummy
;
CCoinsViewCache
coins
(
coinsDummy
);
CCoinsViewCache
coins
(
&
coinsDummy
);
std
::
vector
<
CMutableTransaction
>
dummyTransactions
=
SetupDummyInputs
(
keystore
,
coins
);
CMutableTransaction
t1
;
...
...
@@ -295,7 +295,7 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
LOCK
(
cs_main
);
CBasicKeyStore
keystore
;
CCoinsView
coinsDummy
;
CCoinsViewCache
coins
(
coinsDummy
);
CCoinsViewCache
coins
(
&
coinsDummy
);
std
::
vector
<
CMutableTransaction
>
dummyTransactions
=
SetupDummyInputs
(
keystore
,
coins
);
CMutableTransaction
t
;
...
...
This diff is collapsed.
Click to expand it.
src/txmempool.cpp
View file @
ffab5ed8
...
...
@@ -630,7 +630,7 @@ void CTxMemPool::ClearPrioritisation(const uint256 hash)
}
CCoinsViewMemPool
::
CCoinsViewMemPool
(
CCoinsView
&
baseIn
,
CTxMemPool
&
mempoolIn
)
:
CCoinsViewBacked
(
baseIn
),
mempool
(
mempoolIn
)
{
}
CCoinsViewMemPool
::
CCoinsViewMemPool
(
CCoinsView
*
baseIn
,
CTxMemPool
&
mempoolIn
)
:
CCoinsViewBacked
(
baseIn
),
mempool
(
mempoolIn
)
{
}
bool
CCoinsViewMemPool
::
GetCoins
(
const
uint256
&
txid
,
CCoins
&
coins
)
const
{
// If an entry in the mempool exists, always return that one, as it's guaranteed to never
...
...
This diff is collapsed.
Click to expand it.
src/txmempool.h
View file @
ffab5ed8
...
...
@@ -144,7 +144,7 @@ protected:
CTxMemPool
&
mempool
;
public:
CCoinsViewMemPool
(
CCoinsView
&
baseIn
,
CTxMemPool
&
mempoolIn
);
CCoinsViewMemPool
(
CCoinsView
*
baseIn
,
CTxMemPool
&
mempoolIn
);
bool
GetCoins
(
const
uint256
&
txid
,
CCoins
&
coins
)
const
;
bool
HaveCoins
(
const
uint256
&
txid
)
const
;
};
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help