Skip to content

Commit

Permalink
Refactoring to Core/TxMempool
Browse files Browse the repository at this point in the history
  • Loading branch information
metaspartan committed Nov 20, 2017
1 parent 34b38bb commit 28d6e90
Show file tree
Hide file tree
Showing 23 changed files with 1,985 additions and 1,413 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#############################################################################
# Makefile for building: Denarius
# Generated by qmake (2.01a) (Qt 4.8.6) on: Mon Oct 9 01:16:04 2017
# Generated by qmake (2.01a) (Qt 4.8.6) on: Sun Nov 19 16:20:39 2017
# Project: denarius-qt.pro
# Template: app
# Command: c:\Qt\4.8.6\bin\qmake.exe USE_UPNP=1 USE_QRCODE=1 -o Makefile denarius-qt.pro
Expand Down
1,156 changes: 669 additions & 487 deletions Makefile.Debug

Large diffs are not rendered by default.

1,156 changes: 669 additions & 487 deletions Makefile.Release

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions denarius-qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,13 @@ HEADERS += src/qt/bitcoingui.h \
src/richlistdb.h \
src/richlistdata.h \
src/main.h \
src/core.h \
src/miner.h \
src/net.h \
src/key.h \
src/db.h \
src/txdb.h \
src/txmempool.h \
src/walletdb.h \
src/script.h \
src/stealth.h \
Expand Down Expand Up @@ -348,13 +350,15 @@ SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
src/key.cpp \
src/script.cpp \
src/main.cpp \
src/core.cpp \
src/miner.cpp \
src/init.cpp \
src/net.cpp \
src/irc.cpp \
src/checkpoints.cpp \
src/addrman.cpp \
src/db.cpp \
src/txmempool.cpp \
src/walletdb.cpp \
src/qt/clientmodel.cpp \
src/qt/guiutil.cpp \
Expand Down
2 changes: 2 additions & 0 deletions src/coincontrol.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef COINCONTROL_H
#define COINCONTROL_H

#include "core.h"

/** Coin Control Features. */
class CCoinControl
{
Expand Down
6 changes: 6 additions & 0 deletions src/core.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2013 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "core.h"
210 changes: 210 additions & 0 deletions src/core.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2013 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_CORE_H
#define BITCOIN_CORE_H

#include "uint256.h"
#include "serialize.h"
#include "util.h"
#include "script.h"

#include <stdio.h>

class CScript;
class CTransaction;

/** An outpoint - a combination of a transaction hash and an index n into its vout */
class COutPoint
{
public:
uint256 hash;
unsigned int n;

COutPoint() { SetNull(); }
COutPoint(uint256 hashIn, unsigned int 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); }

friend bool operator<(const COutPoint& a, const COutPoint& b)
{
return (a.hash < b.hash || (a.hash == b.hash && a.n < b.n));
}

friend bool operator==(const COutPoint& a, const COutPoint& b)
{
return (a.hash == b.hash && a.n == b.n);
}

friend bool operator!=(const COutPoint& a, const COutPoint& b)
{
return !(a == b);
}

std::string ToString() const
{
return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10).c_str(), n);
}
};

/** An inpoint - a combination of a transaction and an index n into its vin */
class CInPoint
{
public:
CTransaction* ptx;
unsigned int n;

CInPoint() { SetNull(); }
CInPoint(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); }
};

/** An input of a transaction. It contains the location of the previous
* transaction's output that it claims and a signature that matches the
* output's public key.
*/
class CTxIn
{
public:
COutPoint prevout;
CScript scriptSig;
CScript prevPubKey;
unsigned int 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())
{
prevout = prevoutIn;
scriptSig = scriptSigIn;
nSequence = nSequenceIn;
}

explicit CTxIn(uint256 hashPrevTx, unsigned int nOut, CScript scriptSigIn=CScript(), unsigned int nSequenceIn=std::numeric_limits<unsigned int>::max())
{
prevout = COutPoint(hashPrevTx, nOut);
scriptSig = scriptSigIn;
nSequence = nSequenceIn;
}

IMPLEMENT_SERIALIZE
(
READWRITE(prevout);
READWRITE(scriptSig);
READWRITE(nSequence);
)

bool IsFinal() const
{
return (nSequence == std::numeric_limits<unsigned int>::max());
}

friend bool operator==(const CTxIn& a, const CTxIn& b)
{
return (a.prevout == b.prevout &&
a.scriptSig == b.scriptSig &&
a.nSequence == b.nSequence);
}

friend bool operator!=(const CTxIn& a, const CTxIn& b)
{
return !(a == b);
}

std::string ToString() const
{
std::string str;
str += "CTxIn(";
str += prevout.ToString();
if (prevout.IsNull())
str += strprintf(", coinbase %s", HexStr(scriptSig).c_str());
else
str += strprintf(", scriptSig=%s", scriptSig.ToString().substr(0,24).c_str());
if (nSequence != std::numeric_limits<unsigned int>::max())
str += strprintf(", nSequence=%u", nSequence);
str += ")";
return str;
}
};




/** An output of a transaction. It contains the public key that the next input
* must be able to sign with to claim it.
*/
class CTxOut
{
public:
int64_t nValue;
CScript scriptPubKey;

CTxOut()
{
SetNull();
}

CTxOut(int64_t nValueIn, CScript scriptPubKeyIn)
{
nValue = nValueIn;
scriptPubKey = scriptPubKeyIn;
}

IMPLEMENT_SERIALIZE
(
READWRITE(nValue);
READWRITE(scriptPubKey);
)

void SetNull()
{
nValue = -1;
scriptPubKey.clear();
}

bool IsNull() const
{
return (nValue == -1);
}

void SetEmpty()
{
nValue = 0;
scriptPubKey.clear();
}

bool IsEmpty() const
{
return (nValue == 0 && scriptPubKey.empty());
}

uint256 GetHash() const
{
return SerializeHash(*this);
}

friend bool operator==(const CTxOut& a, const CTxOut& b)
{
return (a.nValue == b.nValue &&
a.scriptPubKey == b.scriptPubKey);
}

friend bool operator!=(const CTxOut& a, const CTxOut& b)
{
return !(a == b);
}

std::string ToString() const
{
if (IsEmpty()) return "CTxOut(empty)";
return strprintf("CTxOut(nValue=%s, scriptPubKey=%s)", FormatMoney(nValue).c_str(), scriptPubKey.ToString().c_str());
}
};

#endif
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void Shutdown(void* parg)

SecureMsgShutdown();

nTransactionsUpdated++;
mempool.AddTransactionsUpdated(1);
// CTxDB().Close();
bitdb.Flush(false);
StopNode();
Expand Down
Loading

0 comments on commit 28d6e90

Please sign in to comment.