Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c606253c41 | |||
| b2dfb627cc |
+1
-1
@@ -8,7 +8,7 @@
|
||||
// These need to be macros, as version.cpp's and triangles-qt.rc's voodoo requires it
|
||||
#define CLIENT_VERSION_MAJOR 5
|
||||
#define CLIENT_VERSION_MINOR 9
|
||||
#define CLIENT_VERSION_REVISION 15
|
||||
#define CLIENT_VERSION_REVISION 17
|
||||
#define CLIENT_VERSION_BUILD 0
|
||||
|
||||
// Converts the parameter X to a string after macro replacement on X has been performed.
|
||||
|
||||
+30
-1
@@ -3771,8 +3771,9 @@ bool FastImportBlockFile()
|
||||
int64_t nFees = 0;
|
||||
unsigned int nTxPos = nBlockPos + ::GetSerializeSize(CBlock(), SER_DISK, CLIENT_VERSION)
|
||||
- (2 * GetSizeOfCompactSize(0)) + GetSizeOfCompactSize(block.vtx.size());
|
||||
for (const CTransaction& tx : block.vtx)
|
||||
for (size_t nTxIdx = 0; nTxIdx < block.vtx.size(); nTxIdx++)
|
||||
{
|
||||
const CTransaction& tx = block.vtx[nTxIdx];
|
||||
uint256 hashTx = tx.GetHash();
|
||||
CDiskTxPos posThisTx(1, nBlockPos, nTxPos);
|
||||
txdb.UpdateTxIndex(hashTx, CTxIndex(posThisTx, tx.vout.size()));
|
||||
@@ -3790,6 +3791,18 @@ bool FastImportBlockFile()
|
||||
CUtxoEntry utxo;
|
||||
if (txdb.ReadUtxo(txin.prevout.hash, txin.prevout.n, utxo))
|
||||
nTxValueIn += utxo.nValue;
|
||||
if (fAddressIndex && !utxo.scriptPubKey.empty() && utxo.nValue != 0)
|
||||
{
|
||||
int nAType; uint160 aHash;
|
||||
if (GetAddressFromScript(utxo.scriptPubKey, nAType, aHash))
|
||||
{
|
||||
txdb.EraseAddressUtxo(nAType, aHash, txin.prevout.hash, txin.prevout.n);
|
||||
int64_t nABal = 0;
|
||||
txdb.ReadAddressBalance(nAType, aHash, nABal);
|
||||
nABal -= utxo.nValue;
|
||||
txdb.WriteAddressBalance(nAType, aHash, nABal);
|
||||
}
|
||||
}
|
||||
txdb.EraseUtxo(txin.prevout.hash, txin.prevout.n);
|
||||
}
|
||||
nBlockValueIn += nTxValueIn;
|
||||
@@ -3808,6 +3821,20 @@ bool FastImportBlockFile()
|
||||
utxo.fCoinStake = tx.IsCoinStake();
|
||||
utxo.nTxTime = tx.nTime;
|
||||
txdb.WriteUtxo(hashTx, k, utxo);
|
||||
if (fAddressIndex && !tx.vout[k].scriptPubKey.empty() && tx.vout[k].nValue != 0)
|
||||
{
|
||||
int nAType; uint160 aHash;
|
||||
if (GetAddressFromScript(tx.vout[k].scriptPubKey, nAType, aHash))
|
||||
{
|
||||
txdb.WriteAddressUtxo(nAType, aHash, hashTx, k,
|
||||
tx.vout[k].nValue, pindexNew->nHeight, tx.vout[k].scriptPubKey);
|
||||
int64_t nABal = 0;
|
||||
txdb.ReadAddressBalance(nAType, aHash, nABal);
|
||||
nABal += tx.vout[k].nValue;
|
||||
txdb.WriteAddressBalance(nAType, aHash, nABal);
|
||||
txdb.WriteAddressTxId(nAType, aHash, pindexNew->nHeight, (int)nTxIdx, hashTx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3859,6 +3886,8 @@ bool FastImportBlockFile()
|
||||
// Final commit
|
||||
if (pindexBest)
|
||||
{
|
||||
if (fAddressIndex)
|
||||
UpdateAddressIndexSyncState(txdb, pindexBest);
|
||||
txdb.WriteHashBestChain(hashBestChain);
|
||||
|
||||
// Write sync checkpoint
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
#include "checkpoints.h"
|
||||
#include "util.h"
|
||||
#include "ui_interface.h"
|
||||
#include "addressindex.h"
|
||||
|
||||
#include <variant>
|
||||
|
||||
// defined in main.cpp
|
||||
extern bool fAddressIndex;
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
@@ -190,6 +196,22 @@ bool DumpSnapshot(const fs::path& destPath,
|
||||
return true;
|
||||
}
|
||||
|
||||
// Extract (type, hash160) from a scriptPubKey for the address index.
|
||||
// Mirrors GetAddressFromScript() in main.cpp (which is file-static there).
|
||||
static bool SnapAddressFromScript(const CScript& script, int& nType, uint160& hashBytes)
|
||||
{
|
||||
CTxDestination dest;
|
||||
if (!ExtractDestination(script, dest))
|
||||
return false;
|
||||
if (const CKeyID* keyId = std::get_if<CKeyID>(&dest)) {
|
||||
nType = ADDR_TYPE_P2PKH; hashBytes = *keyId; return true;
|
||||
}
|
||||
if (const CScriptID* scriptId = std::get_if<CScriptID>(&dest)) {
|
||||
nType = ADDR_TYPE_P2SH; hashBytes = *scriptId; return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// LoadSnapshot - load a UTXO snapshot into a fresh LevelDB
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -383,6 +405,19 @@ bool LoadSnapshot(const fs::path& snapshotPath,
|
||||
strError = "WriteUtxo failed at index " + std::to_string(i);
|
||||
break;
|
||||
}
|
||||
|
||||
// Address index: snapshot UTXOs are all unspent -> credit balance + record UTXO.
|
||||
if (::fAddressIndex && !entry.scriptPubKey.empty() && entry.nValue != 0) {
|
||||
int nAType; uint160 aHash;
|
||||
if (SnapAddressFromScript(entry.scriptPubKey, nAType, aHash)) {
|
||||
txdb.WriteAddressUtxo(nAType, aHash, txhash, nIndex,
|
||||
entry.nValue, entry.nHeight, entry.scriptPubKey);
|
||||
int64_t nABal = 0;
|
||||
txdb.ReadAddressBalance(nAType, aHash, nABal);
|
||||
nABal += entry.nValue;
|
||||
txdb.WriteAddressBalance(nAType, aHash, nABal);
|
||||
}
|
||||
}
|
||||
nBatchSize++;
|
||||
|
||||
if (nBatchSize >= 50000) {
|
||||
|
||||
Reference in New Issue
Block a user