-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,519 additions
and
1,391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2014-2020 The Gridcoin developers | ||
// Distributed under the MIT/X11 software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#include <string> | ||
|
||
#include "gridcoin/support/xml.h" | ||
#include "gridcoin/tx_message.h" | ||
|
||
std::string GetMessage(const CTransaction& tx) | ||
{ | ||
if (tx.nVersion <= 1) { | ||
return ExtractXML(tx.hashBoinc, "<MESSAGE>", "</MESSAGE>"); | ||
} | ||
|
||
if (tx.vContracts.empty()) { | ||
return std::string(); | ||
} | ||
|
||
if (tx.vContracts.front().m_type != GRC::ContractType::MESSAGE) { | ||
return std::string(); | ||
} | ||
|
||
const auto payload = tx.vContracts.front().SharePayloadAs<GRC::TxMessage>(); | ||
|
||
return payload->m_message; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (c) 2019-2020 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef BITCOIN_INDEX_DISKTXPOS_H | ||
#define BITCOIN_INDEX_DISKTXPOS_H | ||
|
||
#include <serialize.h> | ||
#include "tinyformat.h" | ||
|
||
/** Position on disk for a particular transaction. */ | ||
class CDiskTxPos | ||
{ | ||
public: | ||
unsigned int nFile; | ||
unsigned int nBlockPos; | ||
unsigned int nTxPos; | ||
|
||
ADD_SERIALIZE_METHODS; | ||
|
||
template <typename Stream, typename Operation> | ||
inline void SerializationOp(Stream& s, Operation ser_action) | ||
{ | ||
READWRITE(nFile); | ||
READWRITE(nBlockPos); | ||
READWRITE(nTxPos); | ||
} | ||
|
||
CDiskTxPos() | ||
{ | ||
SetNull(); | ||
} | ||
|
||
CDiskTxPos(unsigned int nFileIn, unsigned int nBlockPosIn, unsigned int nTxPosIn) | ||
{ | ||
nFile = nFileIn; | ||
nBlockPos = nBlockPosIn; | ||
nTxPos = nTxPosIn; | ||
} | ||
|
||
void SetNull() { nFile = (unsigned int) -1; nBlockPos = 0; nTxPos = 0; } | ||
bool IsNull() const { return (nFile == (unsigned int) -1); } | ||
|
||
friend bool operator==(const CDiskTxPos& a, const CDiskTxPos& b) | ||
{ | ||
return (a.nFile == b.nFile && | ||
a.nBlockPos == b.nBlockPos && | ||
a.nTxPos == b.nTxPos); | ||
} | ||
|
||
friend bool operator!=(const CDiskTxPos& a, const CDiskTxPos& b) | ||
{ | ||
return !(a == b); | ||
} | ||
|
||
std::string ToString() const | ||
{ | ||
if (IsNull()) | ||
return "null"; | ||
else | ||
return strprintf("(nFile=%u, nBlockPos=%u, nTxPos=%u)", nFile, nBlockPos, nTxPos); | ||
} | ||
}; | ||
|
||
#endif // BITCOIN_INDEX_DISKTXPOS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (c) 2017-2018 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef BITCOIN_INDEX_TXINDEX_H | ||
#define BITCOIN_INDEX_TXINDEX_H | ||
|
||
/** A txdb record that contains the disk location of a transaction and the | ||
* locations of transactions that spend its outputs. vSpent is really only | ||
* used as a flag, but having the location is very helpful for debugging. | ||
*/ | ||
class CTxIndex | ||
{ | ||
public: | ||
CDiskTxPos pos; | ||
std::vector<CDiskTxPos> vSpent; | ||
|
||
CTxIndex() | ||
{ | ||
SetNull(); | ||
} | ||
|
||
CTxIndex(const CDiskTxPos& posIn, unsigned int nOutputs) | ||
{ | ||
pos = posIn; | ||
vSpent.resize(nOutputs); | ||
} | ||
|
||
ADD_SERIALIZE_METHODS; | ||
|
||
template <typename Stream, typename Operation> | ||
inline void SerializationOp(Stream& s, Operation ser_action) | ||
{ | ||
if (!(s.GetType() & SER_GETHASH)) { | ||
int nVersion = s.GetVersion(); | ||
READWRITE(nVersion); | ||
} | ||
|
||
READWRITE(pos); | ||
READWRITE(vSpent); | ||
} | ||
|
||
void SetNull() | ||
{ | ||
pos.SetNull(); | ||
vSpent.clear(); | ||
} | ||
|
||
bool IsNull() | ||
{ | ||
return pos.IsNull(); | ||
} | ||
|
||
friend bool operator==(const CTxIndex& a, const CTxIndex& b) | ||
{ | ||
return (a.pos == b.pos && | ||
a.vSpent == b.vSpent); | ||
} | ||
|
||
friend bool operator!=(const CTxIndex& a, const CTxIndex& b) | ||
{ | ||
return !(a == b); | ||
} | ||
}; | ||
|
||
#endif // BITCOIN_INDEX_TXINDEX_H |
Oops, something went wrong.