Skip to content

Commit 2aa6329

Browse files
committed
Enable customising node policy for datacarrier data size with a -datacarriersize option
1 parent 2ffdf21 commit 2aa6329

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/init.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "miner.h"
1818
#include "net.h"
1919
#include "rpcserver.h"
20+
#include "script/standard.h"
2021
#include "txdb.h"
2122
#include "ui_interface.h"
2223
#include "util.h"
@@ -345,6 +346,7 @@ std::string HelpMessage(HelpMessageMode mode)
345346

346347
strUsage += "\n" + _("Node relay options:") + "\n";
347348
strUsage += " -datacarrier " + strprintf(_("Relay and mine data carrier transactions (default: %u)"), 1) + "\n";
349+
strUsage += " -datacarriersize " + strprintf(_("Maximum size of data in data carrier transactions we relay and mine (default: %u)"), MAX_OP_RETURN_RELAY) + "\n";
348350

349351
strUsage += "\n" + _("Block creation options:") + "\n";
350352
strUsage += " -blockminsize=<n> " + strprintf(_("Set minimum block size in bytes (default: %u)"), 0) + "\n";
@@ -702,6 +704,7 @@ bool AppInit2(boost::thread_group& threadGroup)
702704
#endif // ENABLE_WALLET
703705

704706
fIsBareMultisigStd = GetArg("-permitbaremultisig", true) != 0;
707+
nMaxDatacarrierBytes = GetArg("-datacarriersize", nMaxDatacarrierBytes);
705708

706709
// ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log
707710

src/script/standard.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ using namespace std;
1515

1616
typedef vector<unsigned char> valtype;
1717

18+
unsigned nMaxDatacarrierBytes = MAX_OP_RETURN_RELAY;
19+
1820
CScriptID::CScriptID(const CScript& in) : uint160(in.size() ? Hash160(in.begin(), in.end()) : 0) {}
1921

2022
const char* GetTxnOutputType(txnouttype t)
@@ -139,8 +141,8 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
139141
}
140142
else if (opcode2 == OP_SMALLDATA)
141143
{
142-
// small pushdata, <= MAX_OP_RETURN_RELAY bytes
143-
if (vch1.size() > MAX_OP_RETURN_RELAY)
144+
// small pushdata, <= nMaxDatacarrierBytes
145+
if (vch1.size() > nMaxDatacarrierBytes)
144146
break;
145147
}
146148
else if (opcode1 != opcode2 || vch1 != vch2)

src/script/standard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class CScriptID : public uint160
2626
};
2727

2828
static const unsigned int MAX_OP_RETURN_RELAY = 40; // bytes
29+
extern unsigned nMaxDatacarrierBytes;
2930

3031
// Mandatory script verification flags that all new blocks must comply with for
3132
// them to be valid. (but old blocks may not comply with) Currently just P2SH,

0 commit comments

Comments
 (0)