Browse Source

changed field types in some structures to equivalent unambiguous types

Conflicts:
	src/core.cpp

Rebased-By: Wladimir J. van der Laan
Github-Pull: #4180
pull/145/head
Kamil Domanski 10 years ago
committed by Wladimir J. van der Laan
parent
commit
9f3d476779
No known key found for this signature in database GPG Key ID: 74810B012346C9A6
  1. 4
      src/core.cpp
  2. 48
      src/core.h

4
src/core.cpp

@ -12,14 +12,14 @@ std::string COutPoint::ToString() const
return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10), n);
}
CTxIn::CTxIn(COutPoint prevoutIn, CScript scriptSigIn, unsigned int nSequenceIn)
CTxIn::CTxIn(COutPoint prevoutIn, CScript scriptSigIn, uint32_t nSequenceIn)
{
prevout = prevoutIn;
scriptSig = scriptSigIn;
nSequence = nSequenceIn;
}
CTxIn::CTxIn(uint256 hashPrevTx, unsigned int nOut, CScript scriptSigIn, unsigned int nSequenceIn)
CTxIn::CTxIn(uint256 hashPrevTx, uint32_t nOut, CScript scriptSigIn, uint32_t nSequenceIn)
{
prevout = COutPoint(hashPrevTx, nOut);
scriptSig = scriptSigIn;

48
src/core.h

@ -26,13 +26,13 @@ class COutPoint
{
public:
uint256 hash;
unsigned int n;
uint32_t n;
COutPoint() { SetNull(); }
COutPoint(uint256 hashIn, unsigned int nIn) { hash = hashIn; n = nIn; }
COutPoint(uint256 hashIn, uint32_t nIn) { hash = hashIn; n = nIn; }
IMPLEMENT_SERIALIZE( READWRITE(FLATDATA(*this)); )
void SetNull() { hash = 0; n = (unsigned int) -1; }
bool IsNull() const { return (hash == 0 && n == (unsigned int) -1); }
void SetNull() { hash = 0; n = (uint32_t) -1; }
bool IsNull() const { return (hash == 0 && n == (uint32_t) -1); }
friend bool operator<(const COutPoint& a, const COutPoint& b)
{
@ -57,12 +57,12 @@ class CInPoint
{
public:
const CTransaction* ptx;
unsigned int n;
uint32_t n;
CInPoint() { SetNull(); }
CInPoint(const CTransaction* ptxIn, unsigned int nIn) { ptx = ptxIn; n = nIn; }
void SetNull() { ptx = NULL; n = (unsigned int) -1; }
bool IsNull() const { return (ptx == NULL && n == (unsigned int) -1); }
CInPoint(const CTransaction* ptxIn, uint32_t nIn) { ptx = ptxIn; n = nIn; }
void SetNull() { ptx = NULL; n = (uint32_t) -1; }
bool IsNull() const { return (ptx == NULL && n == (uint32_t) -1); }
};
/** An input of a transaction. It contains the location of the previous
@ -74,15 +74,15 @@ class CTxIn
public:
COutPoint prevout;
CScript scriptSig;
unsigned int nSequence;
uint32_t nSequence;
CTxIn()
{
nSequence = std::numeric_limits<unsigned int>::max();
}
explicit CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), unsigned int nSequenceIn=std::numeric_limits<unsigned int>::max());
CTxIn(uint256 hashPrevTx, unsigned int nOut, CScript scriptSigIn=CScript(), unsigned int nSequenceIn=std::numeric_limits<unsigned int>::max());
explicit CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=std::numeric_limits<unsigned int>::max());
CTxIn(uint256 hashPrevTx, uint32_t nOut, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=std::numeric_limits<uint32_t>::max());
IMPLEMENT_SERIALIZE
(
@ -93,7 +93,7 @@ public:
bool IsFinal() const
{
return (nSequence == std::numeric_limits<unsigned int>::max());
return (nSequence == std::numeric_limits<uint32_t>::max());
}
friend bool operator==(const CTxIn& a, const CTxIn& b)
@ -217,17 +217,17 @@ private:
void UpdateHash() const;
public:
static const int CURRENT_VERSION=1;
static const int32_t CURRENT_VERSION=1;
// The local variables are made const to prevent unintended modification
// without updating the cached hash value. However, CTransaction is not
// actually immutable; deserialization and assignment are implemented,
// and bypass the constness. This is safe, as they update the entire
// structure, including the hash.
const int nVersion;
const int32_t nVersion;
const std::vector<CTxIn> vin;
const std::vector<CTxOut> vout;
const unsigned int nLockTime;
const uint32_t nLockTime;
/** Construct a CTransaction that qualifies as IsNull() */
CTransaction();
@ -238,11 +238,11 @@ public:
CTransaction& operator=(const CTransaction& tx);
IMPLEMENT_SERIALIZE(
READWRITE(*const_cast<int*>(&this->nVersion));
READWRITE(*const_cast<int32_t*>(&this->nVersion));
nVersion = this->nVersion;
READWRITE(*const_cast<std::vector<CTxIn>*>(&vin));
READWRITE(*const_cast<std::vector<CTxOut>*>(&vout));
READWRITE(*const_cast<unsigned int*>(&nLockTime));
READWRITE(*const_cast<uint32_t*>(&nLockTime));
if (fRead)
UpdateHash();
)
@ -284,10 +284,10 @@ public:
/** A mutable version of CTransaction. */
struct CMutableTransaction
{
int nVersion;
int32_t nVersion;
std::vector<CTxIn> vin;
std::vector<CTxOut> vout;
unsigned int nLockTime;
uint32_t nLockTime;
CMutableTransaction();
CMutableTransaction(const CTransaction& tx);
@ -399,13 +399,13 @@ class CBlockHeader
{
public:
// header
static const int CURRENT_VERSION=2;
int nVersion;
static const int32_t CURRENT_VERSION=2;
int32_t nVersion;
uint256 hashPrevBlock;
uint256 hashMerkleRoot;
unsigned int nTime;
unsigned int nBits;
unsigned int nNonce;
uint32_t nTime;
uint32_t nBits;
uint32_t nNonce;
CBlockHeader()
{

Loading…
Cancel
Save