Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ BITCOIN_CORE_H = \
utilasmap.h \
utilmemory.h \
utilmoneystr.h \
utilstring.h \
utiltime.h \
validation.h \
validationinterface.h \
Expand Down Expand Up @@ -587,6 +588,7 @@ libdash_util_a_SOURCES = \
utilmoneystr.cpp \
utilstrencodings.cpp \
utiltime.cpp \
utilstring.cpp \
$(BITCOIN_CORE_H)

if GLIBC_BACK_COMPAT
Expand Down
8 changes: 8 additions & 0 deletions src/base58.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <hash.h>
#include <uint256.h>
#include <utilstrencodings.h>
#include <utilstring.h>

#include <assert.h>
#include <stdint.h>
Expand Down Expand Up @@ -127,6 +129,9 @@ std::string EncodeBase58(const std::vector<unsigned char>& vch)

bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet)
{
if (!ValidAsCString(str)) {
return false;
}
return DecodeBase58(str.c_str(), vchRet);
}

Expand Down Expand Up @@ -158,6 +163,9 @@ bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet)

bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet)
{
if (!ValidAsCString(str)) {
return false;
}
return DecodeBase58Check(str.c_str(), vchRet);
}

4 changes: 1 addition & 3 deletions src/bench/prevector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
struct nontrivial_t {
int x;
nontrivial_t() :x(-1) {}
ADD_SERIALIZE_METHODS
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {READWRITE(x);}
SERIALIZE_METHODS(nontrivial_t, obj) { READWRITE(obj.x); }
};
static_assert(!IS_TRIVIALLY_CONSTRUCTIBLE<nontrivial_t>::value,
"expected nontrivial_t to not be trivially constructible");
Expand Down
3 changes: 2 additions & 1 deletion src/blockencodings.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,13 @@ class CBlockHeaderAndShortTxIDs {

friend class PartiallyDownloadedBlock;

static const int SHORTTXIDS_LENGTH = 6;
protected:
std::vector<uint64_t> shorttxids;
std::vector<PrefilledTransaction> prefilledtxn;

public:
static constexpr int SHORTTXIDS_LENGTH = 6;

CBlockHeader header;

// Dummy for deserialization
Expand Down
10 changes: 1 addition & 9 deletions src/bloom.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,7 @@ class CBloomFilter
CBloomFilter(const unsigned int nElements, const double nFPRate, const unsigned int nTweak, unsigned char nFlagsIn);
CBloomFilter() : isFull(true), isEmpty(false), nHashFuncs(0), nTweak(0), nFlags(0) {}

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE(vData);
READWRITE(nHashFuncs);
READWRITE(nTweak);
READWRITE(nFlags);
}
SERIALIZE_METHODS(CBloomFilter, obj) { READWRITE(obj.vData, obj.nHashFuncs, obj.nTweak, obj.nFlags); }

void insert(const std::vector<unsigned char>& vKey);
void insert(const COutPoint& outpoint);
Expand Down
18 changes: 4 additions & 14 deletions src/bls/bls_ies.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,9 @@ class CBLSIESEncryptedBlob
uint256 GetIV(size_t idx) const;

public:
ADD_SERIALIZE_METHODS

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
SERIALIZE_METHODS(CBLSIESEncryptedBlob, obj)
{
READWRITE(ephemeralPubKey);
READWRITE(ivSeed);
READWRITE(data);
READWRITE(obj.ephemeralPubKey, obj.ivSeed, obj.data);
}

public:
Expand Down Expand Up @@ -98,14 +93,9 @@ class CBLSIESMultiRecipientBlobs
bool Decrypt(size_t idx, const CBLSSecretKey& sk, Blob& blobRet) const;

public:
ADD_SERIALIZE_METHODS

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
SERIALIZE_METHODS(CBLSIESMultiRecipientBlobs, obj)
{
READWRITE(ephemeralPubKey);
READWRITE(ivSeed);
READWRITE(blobs);
READWRITE(obj.ephemeralPubKey, obj.ivSeed, obj.blobs);
}
};

Expand Down
20 changes: 5 additions & 15 deletions src/cachemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,9 @@ struct CacheItem
K key;
V value;

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
SERIALIZE_METHODS(CacheItem, obj)
{
READWRITE(key);
READWRITE(value);
READWRITE(obj.key, obj.value);
}
};

Expand Down Expand Up @@ -154,16 +150,10 @@ class CacheMap
return *this;
}

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
SERIALIZE_METHODS(CacheMap, obj)
{
READWRITE(nMaxSize);
READWRITE(listItems);
if(ser_action.ForRead()) {
RebuildIndex();
}
READWRITE(obj.nMaxSize, obj.listItems);
SER_READ(obj, obj.RebuildIndex());
}

private:
Expand Down
12 changes: 3 additions & 9 deletions src/cachemultimap.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,10 @@ class CacheMultiMap
return *this;
}

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
SERIALIZE_METHODS(CacheMultiMap, obj)
{
READWRITE(nMaxSize);
READWRITE(listItems);
if(ser_action.ForRead()) {
RebuildIndex();
}
READWRITE(obj.nMaxSize, obj.listItems);
SER_READ(obj, obj.RebuildIndex());
}

private:
Expand Down
9 changes: 3 additions & 6 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,9 @@ struct CDiskBlockPos
int nFile;
unsigned int nPos;

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE(VARINT(nFile, VarIntMode::NONNEGATIVE_SIGNED));
READWRITE(VARINT(nPos));
SERIALIZE_METHODS(CDiskBlockPos, obj)
{
READWRITE(VARINT(obj.nFile, VarIntMode::NONNEGATIVE_SIGNED), VARINT(obj.nPos));
}

CDiskBlockPos() {
Expand Down
54 changes: 15 additions & 39 deletions src/coinjoin/coinjoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,13 @@ class CCoinJoinStatusUpdate
nStatusUpdate(nStatusUpdate),
nMessageID(nMessageID) {};

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
SERIALIZE_METHODS(CCoinJoinStatusUpdate, obj)
{
READWRITE(nSessionID);
READWRITE(nState);
READWRITE(obj.nSessionID, obj.nState);
if (s.GetVersion() <= 702015) {
READWRITE(nEntriesCount);
READWRITE(obj.nEntriesCount);
}
READWRITE(nStatusUpdate);
READWRITE(nMessageID);
READWRITE(obj.nStatusUpdate, obj.nMessageID);
}
};

Expand Down Expand Up @@ -152,13 +147,9 @@ class CCoinJoinAccept
nDenom(nDenom),
txCollateral(txCollateral){};

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
SERIALIZE_METHODS(CCoinJoinAccept, obj)
{
READWRITE(nDenom);
READWRITE(txCollateral);
READWRITE(obj.nDenom, obj.txCollateral);
}

friend bool operator==(const CCoinJoinAccept& a, const CCoinJoinAccept& b)
Expand Down Expand Up @@ -193,14 +184,9 @@ class CCoinJoinEntry
{
}

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
SERIALIZE_METHODS(CCoinJoinEntry, obj)
{
READWRITE(vecTxDSIn);
READWRITE(txCollateral);
READWRITE(vecTxOut);
READWRITE(obj.vecTxDSIn, obj.txCollateral, obj.vecTxOut);
}

bool AddScriptSig(const CTxIn& txin);
Expand Down Expand Up @@ -241,17 +227,11 @@ class CCoinJoinQueue
{
}

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
SERIALIZE_METHODS(CCoinJoinQueue, obj)
{
READWRITE(nDenom);
READWRITE(masternodeOutpoint);
READWRITE(nTime);
READWRITE(fReady);
READWRITE(obj.nDenom, obj.masternodeOutpoint, obj.nTime, obj.fReady);
if (!(s.GetType() & SER_GETHASH)) {
READWRITE(vchSig);
READWRITE(obj.vchSig);
}
}

Expand Down Expand Up @@ -317,17 +297,13 @@ class CCoinJoinBroadcastTx
{
}

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
SERIALIZE_METHODS(CCoinJoinBroadcastTx, obj)
{
READWRITE(tx);
READWRITE(masternodeOutpoint);
READWRITE(obj.tx, obj.masternodeOutpoint);
if (!(s.GetType() & SER_GETHASH)) {
READWRITE(vchSig);
READWRITE(obj.vchSig);
}
READWRITE(sigTime);
READWRITE(obj.sigTime);
}

friend bool operator==(const CCoinJoinBroadcastTx& a, const CCoinJoinBroadcastTx& b)
Expand Down
13 changes: 4 additions & 9 deletions src/evo/cbtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,12 @@ class CCbTx
uint256 merkleRootQuorums;

public:
ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
SERIALIZE_METHODS(CCbTx, obj)
{
READWRITE(nVersion);
READWRITE(nHeight);
READWRITE(merkleRootMNList);
READWRITE(obj.nVersion, obj.nHeight, obj.merkleRootMNList);

if (nVersion >= 2) {
READWRITE(merkleRootQuorums);
if (obj.nVersion >= 2) {
READWRITE(obj.merkleRootQuorums);
}
}

Expand Down
50 changes: 23 additions & 27 deletions src/evo/deterministicmns.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,24 @@ class CDeterministicMNState
s >> *this;
}

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
{
READWRITE(nRegisteredHeight);
READWRITE(nLastPaidHeight);
READWRITE(nPoSePenalty);
READWRITE(nPoSeRevivedHeight);
READWRITE(nPoSeBanHeight);
READWRITE(nRevocationReason);
READWRITE(confirmedHash);
READWRITE(confirmedHashWithProRegTxHash);
READWRITE(keyIDOwner);
READWRITE(pubKeyOperator);
READWRITE(keyIDVoting);
READWRITE(addr);
READWRITE(scriptPayout);
READWRITE(scriptOperatorPayout);
SERIALIZE_METHODS(CDeterministicMNState, obj)
{
READWRITE(
obj.nRegisteredHeight,
obj.nLastPaidHeight,
obj.nPoSePenalty,
obj.nPoSeRevivedHeight,
obj.nPoSeBanHeight,
obj.nRevocationReason,
obj.confirmedHash,
obj.confirmedHashWithProRegTxHash,
obj.keyIDOwner,
obj.pubKeyOperator,
obj.keyIDVoting,
obj.addr,
obj.scriptPayout,
obj.scriptOperatorPayout
);
}

void ResetOperatorFields()
Expand Down Expand Up @@ -182,13 +181,10 @@ class CDeterministicMNStateDiff
#undef DMN_STATE_DIFF_LINE
}

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
SERIALIZE_METHODS(CDeterministicMNStateDiff, obj)
{
READWRITE(VARINT(fields));
#define DMN_STATE_DIFF_LINE(f) if (fields & Field_##f) READWRITE(state.f);
READWRITE(VARINT(obj.fields));
#define DMN_STATE_DIFF_LINE(f) if (obj.fields & Field_##f) READWRITE(obj.state.f);
DMN_STATE_DIFF_ALL_FIELDS
#undef DMN_STATE_DIFF_LINE
}
Expand Down Expand Up @@ -247,7 +243,7 @@ class CDeterministicMN
template<typename Stream>
void Serialize(Stream& s) const
{
NCONST_PTR(this)->SerializationOp(s, CSerActionSerialize(), false);
const_cast<CDeterministicMN*>(this)->SerializationOp(s, CSerActionSerialize(), false);
}

template<typename Stream>
Expand Down Expand Up @@ -338,7 +334,7 @@ class CDeterministicMNList
template<typename Stream>
void Serialize(Stream& s) const
{
NCONST_PTR(this)->SerializationOpBase(s, CSerActionSerialize());
const_cast<CDeterministicMNList*>(this)->SerializationOpBase(s, CSerActionSerialize());
// Serialize the map as a vector
WriteCompactSize(s, mnMap.size());
for (const auto& p : mnMap) {
Expand Down
Loading