Skip to content

Commit

Permalink
Merge #1807: [Backport] 4.2.1 backports
Browse files Browse the repository at this point in the history
dc0ed71 [BUG][GUI] Don't append cold-stake records twice (random-zebra)
91adcd7 masternode: CalculateScore and GetBlockHash accessing to chainActive without cs_main fix. (furszy)
eeb112f GetMasternodeInputAge: Missing cs_main lock (furszy)
52ec12d refactor: decouple decompose coinstake from TransactionRecord::decomposeTransaction. (furszy)
51a8389 [BUG] Properly copy fCoinStake memeber between CTxInUndo and CCoins Github-Pull: #1796 Rebased-From: acf757b (random-zebra)
5c3caa4 lock cs_main for Misbehaving (furszy)
5c629d8 openssl.org dependency download link changed (CryptoDev-Project)
11aa63c Do not try to resend transactions if the node is importing or in IBD. (furszy)
c59b62e [Core] Remove BIP30 check (random-zebra)
3f05eba include missing atomic to make CMake linux happy. (furszy)
f0cfd88 Make the cs_sendProcessing a LOCK instead of a TRY_LOCK (Matt Corallo)
d38e28c Split CNode::cs_vSend: message processing and message sending (Matt Corallo)
7561b18 Remove double brackets in addrman (Matt Corallo)
63c629b Fix AddrMan locking (Matt Corallo)
f78cec4 Make fDisconnect an std::atomic (Matt Corallo)
ec56cf5 net: fix a few cases where messages were sent rather than dropped upon disconnection (furszy)
7697085 Acquire cs_main lock before cs_wallet during wallet initialization (random-zebra)
c796593 Remove bogus assert on number of oubound connections. (Matt Corallo)
7521065 wallet: Ignore MarkConflict if block hash is not known (random-zebra)
72042ac Move disconnectBlocks logging to use __func__ instead of hardcoded method name. (furszy)
0f66764 Simplify DisconnectBlock arguments/return value (furszy)
cca4a8c Split logic to undo txin's off DisconnectBlock (furszy)
0f883e6 Cleaner disconnectBlock flow for coinbase and zerocoin txs. (furszy)
a7cbc46 Move UndoWriteToDisk() and UndoReadFromDisk() to anon namespace (random-zebra)
de5a405 Decouple CBlockUndo from CDiskBlockPos (jtimon)
671143c Decouple miner.o and txmempool.o from CTxUndo (random-zebra)
9419228 Decouple CCoins from CTxInUndo (jtimon)

Pull request description:

  Backports the following PRs to the `4.2` branch:

  #1746
  #1735
  #1767
  #1769
  #1781
  #1780
  #1775
  #1783
  #1750
  #1785
  #1796
  #1776
  #1791

ACKs for top commit:
  furszy:
    Added #1805. utACK dc0ed71.
  random-zebra:
    utACK dc0ed71

Tree-SHA512: 0e59c9e751597b1b6f9a419e117946cec468dffdb921c882a44e5770ecb1a36b7d3d25f8c7f97d48bb3d59f136492842c08969901512d957a17bfaec6aece449
  • Loading branch information
furszy committed Aug 18, 2020
2 parents af3dd41 + dc0ed71 commit 70afd43
Show file tree
Hide file tree
Showing 22 changed files with 643 additions and 504 deletions.
2 changes: 1 addition & 1 deletion depends/packages/openssl.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package=openssl
$(package)_version=1.0.1k
$(package)_download_path=https://www.openssl.org/source/old
$(package)_download_path=https://www.openssl.org/source/old/1.0.1
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=8f9faeaebad088e772f4ef5e38252d472be4d878c6b3a2718c10a4fcebe7a41c

Expand Down
53 changes: 22 additions & 31 deletions src/addrman.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ class CAddrMan
//! Return the number of (unique) addresses in all tables.
int size()
{
LOCK(cs); // TODO: Cache this in an atomic to avoid this overhead
return vRandom.size();
}

Expand All @@ -499,13 +500,11 @@ class CAddrMan
//! Add a single address.
bool Add(const CAddress& addr, const CNetAddr& source, int64_t nTimePenalty = 0)
{
LOCK(cs);
bool fRet = false;
{
LOCK(cs);
Check();
fRet |= Add_(addr, source, nTimePenalty);
Check();
}
Check();
fRet |= Add_(addr, source, nTimePenalty);
Check();
if (fRet)
LogPrint(BCLog::ADDRMAN, "Added %s from %s: %i tried, %i new\n", addr.ToStringIPPort(), source.ToString(), nTried, nNew);
return fRet;
Expand All @@ -514,14 +513,12 @@ class CAddrMan
//! Add multiple addresses.
bool Add(const std::vector<CAddress>& vAddr, const CNetAddr& source, int64_t nTimePenalty = 0)
{
LOCK(cs);
int nAdd = 0;
{
LOCK(cs);
Check();
for (std::vector<CAddress>::const_iterator it = vAddr.begin(); it != vAddr.end(); it++)
nAdd += Add_(*it, source, nTimePenalty) ? 1 : 0;
Check();
}
Check();
for (std::vector<CAddress>::const_iterator it = vAddr.begin(); it != vAddr.end(); it++)
nAdd += Add_(*it, source, nTimePenalty) ? 1 : 0;
Check();
if (nAdd)
LogPrint(BCLog::ADDRMAN, "Added %i addresses from %s: %i tried, %i new\n", nAdd, source.ToString(), nTried, nNew);
return nAdd > 0;
Expand All @@ -530,23 +527,19 @@ class CAddrMan
//! Mark an entry as accessible.
void Good(const CService& addr, int64_t nTime = GetAdjustedTime())
{
{
LOCK(cs);
Check();
Good_(addr, nTime);
Check();
}
LOCK(cs);
Check();
Good_(addr, nTime);
Check();
}

//! Mark an entry as connection attempted to.
void Attempt(const CService& addr, bool fCountFailure, int64_t nTime = GetAdjustedTime())
{
{
LOCK(cs);
Check();
Attempt_(addr, fCountFailure, nTime);
Check();
}
LOCK(cs);
Check();
Attempt_(addr, fCountFailure, nTime);
Check();
}

/**
Expand Down Expand Up @@ -581,12 +574,10 @@ class CAddrMan
//! Mark an entry as currently-connected-to.
void Connected(const CService& addr, int64_t nTime = GetAdjustedTime())
{
{
LOCK(cs);
Check();
Connected_(addr, nTime);
Check();
}
LOCK(cs);
Check();
Connected_(addr, nTime);
Check();
}

void SetServices(const CService& addr, ServiceFlags nServices)
Expand Down
2 changes: 1 addition & 1 deletion src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ enum BlockStatus {
*/
BLOCK_VALID_TRANSACTIONS = 3,

//! Outputs do not overspend inputs, no double spends, coinbase output ok, immature coinbase spends, BIP30.
//! Outputs do not overspend inputs, no double spends, coinbase output ok, immature coinbase spends.
//! Implies all parents are also at least CHAIN.
BLOCK_VALID_CHAIN = 4,

Expand Down
24 changes: 3 additions & 21 deletions src/coins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,21 @@ void CCoins::CalcMaskSize(unsigned int& nBytes, unsigned int& nNonzeroBytes) con
nBytes += nLastUsedByte;
}

bool CCoins::Spend(const COutPoint& out, CTxInUndo& undo)
bool CCoins::Spend(uint32_t nPos)
{
if (out.n >= vout.size())
if (nPos >= vout.size() || vout[nPos].IsNull())
return false;
if (vout[out.n].IsNull())
return false;
undo = CTxInUndo(vout[out.n]);
vout[out.n].SetNull();
vout[nPos].SetNull();
Cleanup();
if (vout.size() == 0) {
undo.nHeight = nHeight;
undo.fCoinBase = fCoinBase;
undo.fCoinStake = fCoinStake;
undo.nVersion = this->nVersion;
}
return true;
}

bool CCoins::Spend(int nPos)
{
CTxInUndo undo;
COutPoint out(UINT256_ZERO, nPos);
return Spend(out, undo);
}


bool CCoinsView::GetCoins(const uint256& txid, CCoins& coins) const { return false; }
bool CCoinsView::HaveCoins(const uint256& txid) const { return false; }
uint256 CCoinsView::GetBestBlock() const { return UINT256_ZERO; }
bool CCoinsView::BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock) { return false; }
bool CCoinsView::GetStats(CCoinsStats& stats) const { return false; }


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); }
Expand Down
6 changes: 1 addition & 5 deletions src/coins.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "script/standard.h"
#include "serialize.h"
#include "uint256.h"
#include "undo.h"

#include <assert.h>
#include <stdint.h>
Expand Down Expand Up @@ -241,11 +240,8 @@ class CCoins
Cleanup();
}

//! mark an outpoint spent, and construct undo information
bool Spend(const COutPoint& out, CTxInUndo& undo);

//! mark a vout spent
bool Spend(int nPos);
bool Spend(uint32_t nPos);

//! check whether a particular output is still available
bool IsAvailable(unsigned int nPos) const
Expand Down
Loading

0 comments on commit 70afd43

Please sign in to comment.