Skip to content

Commit

Permalink
Merge 7219 via txrepl_fullrbf
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr committed Nov 11, 2017
3 parents f027c27 + 706edc4 + 04b9a3b commit 4b6e83d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/init.cpp
Expand Up @@ -1137,8 +1137,16 @@ bool AppInitParameterInteraction()
// Minimal effort at forwards compatibility
std::string strReplacementModeList = gArgs.GetArg("-mempoolreplacement", ""); // default is impossible
std::vector<std::string> vstrReplacementModes;
boost::split(vstrReplacementModes, strReplacementModeList, boost::is_any_of(","));
boost::split(vstrReplacementModes, strReplacementModeList, boost::is_any_of(",+"));
fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "fee") != vstrReplacementModes.end());
if (fEnableReplacement) {
fReplacementHonourOptOut = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "-optin") == vstrReplacementModes.end());
if (!fReplacementHonourOptOut) {
nLocalServices = ServiceFlags(nLocalServices | NODE_REPLACE_BY_FEE);
}
} else {
fReplacementHonourOptOut = true;
}
}

if (gArgs.IsArgSet("-vbparams")) {
Expand Down
2 changes: 2 additions & 0 deletions src/protocol.h
Expand Up @@ -275,6 +275,8 @@ enum ServiceFlags : uint64_t {
// collisions and other cases where nodes may be advertising a service they
// do not actually support. Other service bits should be allocated via the
// BIP process.

NODE_REPLACE_BY_FEE = (1 << 26),
};

/** A CService with information about it as peer */
Expand Down
3 changes: 3 additions & 0 deletions src/qt/guiutil.cpp
Expand Up @@ -939,6 +939,9 @@ QString formatServicesStr(quint64 mask)
case NODE_XTHIN:
strList.append("XTHIN");
break;
case NODE_REPLACE_BY_FEE:
strList.append("REPLACE_BY_FEE?");
break;
default:
strList.append(QString("%1[%2]").arg("UNKNOWN").arg(check));
}
Expand Down
5 changes: 5 additions & 0 deletions src/validation.cpp
Expand Up @@ -81,6 +81,7 @@ size_t nCoinCacheUsage = 5000 * 300;
uint64_t nPruneTarget = 0;
int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE;
bool fEnableReplacement = DEFAULT_ENABLE_REPLACEMENT;
bool fReplacementHonourOptOut = DEFAULT_REPLACEMENT_HONOUR_OPTOUT;

uint256 hashAssumeValid;
arith_uint256 nMinimumChainWork;
Expand Down Expand Up @@ -550,6 +551,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
bool fReplacementOptOut = true;
if (fEnableReplacement)
{
if (fReplacementHonourOptOut) {
for (const CTxIn &_txin : ptxConflicting->vin)
{
if (_txin.nSequence <= MAX_BIP125_RBF_SEQUENCE)
Expand All @@ -558,6 +560,9 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
break;
}
}
} else {
fReplacementOptOut = false;
}
}
if (fReplacementOptOut) {
return state.Invalid(false, REJECT_DUPLICATE, "txn-mempool-conflict");
Expand Down
2 changes: 2 additions & 0 deletions src/validation.h
Expand Up @@ -136,6 +136,7 @@ static const unsigned int DEFAULT_BANSCORE_THRESHOLD = 100;
static const bool DEFAULT_PERSIST_MEMPOOL = true;
/** Default for -mempoolreplacement */
static const bool DEFAULT_ENABLE_REPLACEMENT = true;
static const bool DEFAULT_REPLACEMENT_HONOUR_OPTOUT = true;
/** Default for using fee filter */
static const bool DEFAULT_FEEFILTER = true;

Expand Down Expand Up @@ -180,6 +181,7 @@ extern CAmount maxTxFee;
/** If the tip is older than this (in seconds), the node is considered to be in initial block download. */
extern int64_t nMaxTipAge;
extern bool fEnableReplacement;
extern bool fReplacementHonourOptOut;

/** Block hash whose ancestors we will assume to have valid scripts without checking them. */
extern uint256 hashAssumeValid;
Expand Down

0 comments on commit 4b6e83d

Please sign in to comment.