Skip to content

Commit

Permalink
Merge pull request #54 from konez2k/201908-patch
Browse files Browse the repository at this point in the history
201908 patch
  • Loading branch information
konez2k authored Aug 8, 2019
2 parents 081f2fe + c1a9747 commit c18227b
Show file tree
Hide file tree
Showing 18 changed files with 58,559 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ src/qt/test/moc*.cpp
*.dmg

*.json.h
!invalid_outpoints.json.h
*.raw.h

#libtool object files
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 1)
define(_CLIENT_VERSION_MINOR, 3)
define(_CLIENT_VERSION_REVISION, 1)
define(_CLIENT_VERSION_BUILD, 5)
define(_CLIENT_VERSION_REVISION, 2)
define(_CLIENT_VERSION_BUILD, 3)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2019)
AC_INIT([BitGreen Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[www.bitg.org],[bitgreen])
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ BITCOIN_CORE_H = \
httprpc.h \
httpserver.h \
init.h \
invalid.h \
invalid_outpoints.json.h \
kernel.h \
swifttx.h \
key.h \
Expand Down Expand Up @@ -302,6 +304,7 @@ libbitcoin_common_a_SOURCES = \
core_read.cpp \
core_write.cpp \
hash.cpp \
invalid.cpp \
key.cpp \
keystore.cpp \
netbase.cpp \
Expand Down
3 changes: 3 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class CMainParams : public CChainParams
nMinerThreads = 0;
nTargetTimespan = 1 * 60; // BitGreen: 1 day
nTargetSpacing = 2 * 60; // BitGreen: 2 minutes
nStakingMinInput = 200 * COIN;
nMaturity = 10;
nMasternodeCountDrift = 20;

Expand Down Expand Up @@ -222,6 +223,7 @@ class CTestNetParams : public CMainParams
nMinerThreads = 0;
nTargetTimespan = 1 * 60; // BitGreen: 1 day
nTargetSpacing = 2 * 60; // BitGreen: 1 minute
nStakingMinInput = 0;
nLastPOWBlock = 200;
nMaturity = 15;
nMasternodeCountDrift = 4;
Expand Down Expand Up @@ -295,6 +297,7 @@ class CRegTestParams : public CTestNetParams
nMinerThreads = 1;
nTargetTimespan = 24 * 60 * 60; // BitGreen: 1 day
nTargetSpacing = 1 * 60; // BitGreen: 1 minute
nStakingMinInput = 0;
bnProofOfWorkLimit = ~arith_uint256(0) >> 1;
nLastPOWBlock = 250;
nMaturity = 10;
Expand Down
2 changes: 2 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class CChainParams
bool RequireStandard() const { return fRequireStandard; }
int64_t TargetTimespan() const { return nTargetTimespan; }
int64_t TargetSpacing() const { return nTargetSpacing; }
CAmount StakingMinInput() const { return nStakingMinInput; }
int64_t Interval() const { return nTargetTimespan / nTargetSpacing; }
int LAST_POW_BLOCK() const { return nLastPOWBlock; }
int COINBASE_MATURITY() const { return nMaturity; }
Expand Down Expand Up @@ -114,6 +115,7 @@ class CChainParams
int nToCheckBlockUpgradeMajority;
int64_t nTargetTimespan;
int64_t nTargetSpacing;
CAmount nStakingMinInput;
int nLastPOWBlock;
int nMasternodeCountDrift;
int nMaturity;
Expand Down
4 changes: 4 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "compat/sanity.h"
#include "httpserver.h"
#include "httprpc.h"
#include "invalid.h"
#include "key.h"
#include "main.h"
#include "masternode-budget.h"
Expand Down Expand Up @@ -1411,6 +1412,9 @@ bool AppInit2()
break;
}

// Populate list of invalid outpoints
invalid_out::LoadOutpoints();

uiInterface.InitMessage(_("Verifying blocks..."));

if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 4), GetArg("-checkblocks", 100))) {
Expand Down
63 changes: 63 additions & 0 deletions src/invalid.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright (c) 2019 The BitGreen Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "invalid.h"
#include "invalid_outpoints.json.h"

#include "util.h"

namespace invalid_out
{
std::set<COutPoint> setInvalidOutPoints;

UniValue read_json(const std::string& jsondata)
{
UniValue v;

if (!v.read(jsondata) || !v.isArray())
return UniValue(UniValue::VARR);

return v.get_array();
}

bool LoadOutpoints()
{
UniValue v = read_json(LoadInvalidOutPoints());

if (v.empty()) {
return false;
}

int count;
for (unsigned int idx = 0; idx < v.size(); idx++) {
const UniValue &val = v[idx];
const UniValue &o = val.get_obj();

const UniValue &vTxid = find_value(o, "txid");
if (!vTxid.isStr())
return false;

uint256 txid = uint256(vTxid.get_str());
if (txid == 0)
return false;

const UniValue &vN = find_value(o, "n");
if (!vN.isNum())
return false;

auto n = static_cast<uint32_t>(vN.get_int());
COutPoint out(txid, n);
setInvalidOutPoints.insert(out);
count++;
}

LogPrintf("%s(): loaded %d outpoints.\n", __func__, count);
return true;
}

bool ContainsOutPoint(const COutPoint& out)
{
return static_cast<bool>(setInvalidOutPoints.count(out));
}
}
22 changes: 22 additions & 0 deletions src/invalid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2019 The BitGreen Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITGREEN_INVALID_H
#define BITGREEN_INVALID_H

#include <univalue/include/univalue.h>
#include <primitives/transaction.h>

namespace invalid_out
{
extern std::set<COutPoint> setInvalidOutPoints;

UniValue read_json(const std::string& jsondata);

bool ContainsOutPoint(const COutPoint& out);
bool LoadOutpoints();
bool LoadSerials();
}

#endif //BITGREEN_INVALID_H
Loading

0 comments on commit c18227b

Please sign in to comment.