Skip to content

Commit

Permalink
Update version to 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
BitCanna committed Mar 17, 2020
1 parent 1e92bab commit b7487c5
Show file tree
Hide file tree
Showing 19 changed files with 55 additions and 68 deletions.
11 changes: 6 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 1)
define(_CLIENT_VERSION_MINOR, 0)
define(_CLIENT_VERSION_REVISION, 1)
define(_CLIENT_VERSION_REVISION, 2)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2018)
define(_COPYRIGHT_YEAR, 2020)
AC_INIT([BitCanna],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[www.bitcanna.io],[bitcanna])
AC_CONFIG_SRCDIR([src/main.cpp])
AC_CONFIG_HEADERS([src/config/bitcanna-config.h])
Expand Down Expand Up @@ -235,7 +235,8 @@ fi
if test "x$CXXFLAGS_overridden" = "xno"; then
CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter"
fi
CPPFLAGS="$CPPFLAGS -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS -DCURL_STATICLIB"
CPPFLAGS="$CPPFLAGS -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS"
AC_SUBST(IS_WINDOWS, "no")

AC_ARG_WITH([utils],
[AS_HELP_STRING([--with-utils],
Expand Down Expand Up @@ -744,7 +745,7 @@ dnl If neither is available, abort.
dnl If sleep_for is used, boost_chrono becomes a requirement.
if test x$ax_cv_boost_chrono = xyes; then
TEMP_LIBS="$LIBS"
LIBS="$BOOST_LIBS $BOOST_CHRONO_LIB $LIBS -lcurl"
LIBS="$BOOST_LIBS $BOOST_CHRONO_LIB $LIBS"
TEMP_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Expand Down Expand Up @@ -886,7 +887,7 @@ CFLAGS="$CFLAGS $SSL_CFLAGS $CRYPTO_CFLAGS"
LIBS="$LIBS $SSL_LIBS $CRYPTO_LIBS"
AC_CHECK_HEADER([openssl/ec.h],, AC_MSG_ERROR(OpenSSL ec header missing),)
CFLAGS="$CFLAGS_TEMP"
LIBS="$LIBS_TEMP -lcurl"
LIBS="$LIBS_TEMP"

BITCOIN_QT_PATH_PROGS([PROTOC], [protoc],$protoc_bin_path)

Expand Down
2 changes: 0 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a
LIBBITCOIN_UNIVALUE=univalue/libbitcoin_univalue.a
LIBBITCOINQT=qt/libbitcoinqt.a
LIBSECP256K1=secp256k1/libsecp256k1.la
CURL_LIBS=$(srcdir)/libcurl.a $(srcdir)/libz.a

$(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*)
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F)
Expand Down Expand Up @@ -352,7 +351,6 @@ nodist_libbitcoin_util_a_SOURCES = $(srcdir)/obj/build.h
# bitcoind binary #
bitcannad_LDADD = \
$(LIBBITCOIN_SERVER) \
$(CURL_LIBS) \
$(LIBBITCOIN_COMMON) \
$(LIBBITCOIN_UNIVALUE) \
$(LIBBITCOIN_UTIL) \
Expand Down
11 changes: 0 additions & 11 deletions src/activemasternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,6 @@ bool CActiveMasternode::Dseep(CTxIn vin, CService service, CKey keyMasternode, C
continue;
}

if(mn.enabled != 4 && mn.enabled != 3) {
mn.UpdateLastSeen();
}

if(fDebug) {
LogPrintf("mn.vin -- %s\n", mn.vin.ToString().c_str());
LogPrintf("vin -- %s\n", vin.ToString().c_str());
LogPrintf("mn.vin.prevout -- %s\n", uint256(mn.vin.prevout.hash).ToString().c_str());
LogPrintf("vin.prevout -- %s\n", uint256(vin.prevout.hash).ToString().c_str());
}

if(mn.vin == vin) {
found = true;
mnVinToBroadcast = mn.vin;
Expand Down
4 changes: 2 additions & 2 deletions src/darksend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2141,10 +2141,10 @@ void ThreadCheckDarkSendPool()
vector<CMasterNode>::iterator it = vecMasternodes.begin();
//check them separately
while(it != vecMasternodes.end()) {
LogPrintf("Activity: %s:%d\n", (*it).addr.ToString().c_str(), (*it).enabled);
LogPrint("debug", "Activity: %s:%d\n", (*it).addr.ToString().c_str(), (*it).enabled);
(*it).Check();
if ((*it).enabled == 4 || (*it).enabled == 3) {
LogPrintf("Removing inactive masternode %s\n", (*it).addr.ToString().c_str());
LogPrint("debug", "Removing inactive masternode %s\n", (*it).addr.ToString().c_str());
it = vecMasternodes.erase(it);
} else {
++it;
Expand Down
7 changes: 6 additions & 1 deletion src/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,12 @@ void CDBEnv::CheckpointLSN(const std::string& strFile)
dbenv.txn_checkpoint(0, 0, 0);
if (fMockDb)
return;
dbenv.lsn_reset(strFile.c_str(), 0);
//dbenv.lsn_reset(strFile.c_str(), 0); // reference this: https://github.com/bitcoin/bitcoin/issues/7475
}

void CDBEnv::lsn_reset(const std::string& strFile)
{
dbenv.lsn_reset(strFile.c_str(),0);
}


Expand Down
1 change: 1 addition & 0 deletions src/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class CDBEnv
void Close();
void Flush(bool fShutdown);
void CheckpointLSN(const std::string& strFile);
void lsn_reset(const std::string& strFile);

void CloseDb(const std::string& strFile);
bool RemoveDb(const std::string& strFile);
Expand Down
19 changes: 1 addition & 18 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ enum BindFlags {
static const char* FEE_ESTIMATES_FILENAME = "fee_estimates.dat";
CClientUIInterface uiInterface;

string myIp = "";

//////////////////////////////////////////////////////////////////////////////
//
// Shutdown
Expand Down Expand Up @@ -504,6 +502,7 @@ std::string LicenseInfo()
"\n";
}


static void BlockNotifyCallback(const uint256& hashNewTip)
{
std::string strCmd = GetArg("-blocknotify", "");
Expand Down Expand Up @@ -1179,22 +1178,6 @@ bool AppInit2(boost::thread_group& threadGroup)
}
#endif


CURL *curl;
CURLcode res;

curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://api.ipify.org");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &myIp);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
else {
LogPrintf("ERROR! Curl init failed!\n");
}

// ********************************************************* Step 7: load block chain

fReindex = GetBoolArg("-reindex", false);
Expand Down
18 changes: 14 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ static unsigned int nMarutiryV1 = 10;
static unsigned int nMarutiryV2 = 119;
const int targetReadjustment_forkBlockHeight = 11550; //retargeting since 11550 block
const int targetFork1 = 256963; // fork for new reward values
const int targetFork2 = 710216; // for for new time drift

const int nHeightBlockReward2019 = 259112; // 10.2019-10.2020
const int nHeightBlockReward2020 = 1310312; // 10.2020-10.2021
Expand Down Expand Up @@ -236,10 +237,12 @@ unsigned int GetnMaturity(int nHeight)

int GetMinPeerProtoVersion(int nHeight)
{
if (nHeight >= targetFork1)
if (nHeight >= targetFork2)
return PROTOCOL_VERSION;
else if (nHeight >= targetFork1)
return PROTOCOL_VERSION_BEFORE_FORK2;
else
return PROTOCOL_VERSION_BEFORE_FORK;
return PROTOCOL_VERSION_BEFORE_FORK1;
}

void RegisterValidationInterface(CValidationInterface* pwalletIn)
Expand Down Expand Up @@ -3371,6 +3374,14 @@ bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool f
return true;
}

inline int64_t CalculateBlockTimeLimit(int nHeight)
{
if (nHeight >= targetFork2)
return 15; // 15s future drift for PoS
else
return 7200;
}

bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig)
{
const char * const s = block.IsProofOfStake() ? "pos" : "pow";
Expand All @@ -3383,8 +3394,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
return state.DoS(100, error("%s: invalid (%s) block header", __func__, s),
REJECT_INVALID, "bad-header", true);

// 3 minute future drift for PoS
auto const nBlockTimeLimit = GetAdjustedTime() + (block.IsProofOfStake() ? 180 : 7200);
auto const nBlockTimeLimit = GetAdjustedTime() + (block.IsProofOfStake() ? CalculateBlockTimeLimit(GetHeight()) : 7200);

LogPrint("debug", "%s: block=%s (%s %d %d)\n", __func__, block.GetHash().GetHex(), s,
block.GetBlockTime(), nBlockTimeLimit);
Expand Down
18 changes: 3 additions & 15 deletions src/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ std::map<int64_t, uint256> mapCacheBlockHashes;

std::map<NodeId, MnPingInfo> mapMnPing;

extern std::string myIp;

// manage the masternode connections
void ProcessMasternodeConnections(){
//LOCK(cs_vNodes);
Expand Down Expand Up @@ -630,8 +628,9 @@ uint256 CMasterNode::CalculateScore(int mod, int64_t nBlockHeight)
return r;
}

void CMasterNode::Check()
{
void CMasterNode::Check(bool forceCheck) {
if(!forceCheck && (GetTime() - lastTimeChecked < MASTERNODE_CHECK_SECONDS)) return;
lastTimeChecked = GetTime();
LOCK(cs_masternodes);
//once spent, stop doing the checks
if(enabled == 3 || enabled == 4) return;
Expand All @@ -647,17 +646,6 @@ void CMasterNode::Check()
return;
}

if(fDebug) LogPrintf("CMasterNode::Check(): MN %s checking, myIp: %s \n", ((CNetAddr)this->addr).ToString(), myIp);

if(FindNode(((CNetAddr)this->addr).ToString(), true) == nullptr) {
if(fDebug) LogPrintf("CMasterNode::Check(): MN %s checking IS NULL \n", ((CNetAddr)this->addr).ToString());
if(((CNetAddr)this->addr).ToString() != myIp) {
this->Disable();
if(fDebug) LogPrintf("CMasterNode::Check(): MN %s stopped by ping\n", ((CNetAddr)this->addr).ToString());
return;
}
}

if(!unitTest){
LOCK(cs_main);
/*
Expand Down
5 changes: 4 additions & 1 deletion src/masternode.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class uint256;
#define MASTERNODE_PING_WAIT_SECONDS 60
#define MASTERNODE_EXPIRATION_SECONDS (55*60*24*30*12*10) //Old 65*60
#define MASTERNODE_REMOVAL_SECONDS (60*60*24*30*12*10) //Old 70*60
#define MASTERNODE_CHECK_SECONDS 60

using namespace std;

Expand Down Expand Up @@ -79,6 +80,7 @@ class CMasterNode
std::vector<unsigned char> sig;
int64_t now; //dsee message times
int64_t lastDseep;
int64_t lastTimeChecked;
int cacheInputAge;
int cacheInputAgeBlock;
int enabled;
Expand Down Expand Up @@ -106,6 +108,7 @@ class CMasterNode
lastDseep = 0;
allowFreeTx = true;
protocolVersion = protocolVersionIn;
lastTimeChecked = GetTime() + GetRand(60); // set random check time
}

uint256 CalculateScore(int mod=1, int64_t nBlockHeight=0);
Expand All @@ -126,7 +129,7 @@ class CMasterNode
return n;
}

void Check();
void Check(bool forceCheck = false);

bool UpdatedWithin(int seconds)
{
Expand Down
3 changes: 2 additions & 1 deletion src/masternodeconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ bool CMasternodeConfig::read(std::string& strErr)

std::string strWalletFile = GetArg("-wallet", "wallet.dat");
boost::filesystem::path pathWallet = GetDataDir() / strWalletFile;
boost::filesystem::ifstream walletDat(pathWallet);

if (!streamConfig.good())
if (!streamConfig.good() || !walletDat.good())
{
FILE* configFile = fopen(pathMasternodeConfigFile.string().c_str(), "a");
if (configFile != NULL)
Expand Down
2 changes: 1 addition & 1 deletion src/qt/transactiondesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ QString TransactionDesc::toHTML(CWallet* wallet, CWalletTx& wtx, TransactionReco
strHTML.reserve(4000);
strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";

int64_t nTime = wtx.GetTxTime();
int64_t nTime = wtx.isConflicted() ? (int64_t)wtx.nTimeReceived : wtx.GetTxTime();
CAmount nCredit = wtx.GetCredit(ISMINE_ALL);
CAmount nDebit = wtx.GetDebit(ISMINE_ALL);
CAmount nNet = nCredit - nDebit;
Expand Down
2 changes: 1 addition & 1 deletion src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bool TransactionRecord::showTransaction(const CWalletTx& wtx)
QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet* wallet, const CWalletTx& wtx)
{
QList<TransactionRecord> parts;
int64_t nTime = wtx.GetTxTime();
int64_t nTime = wtx.isConflicted() ? (int64_t)wtx.nTimeReceived : wtx.GetTxTime();
CAmount nCredit = wtx.GetCredit(ISMINE_ALL);
CAmount nDebit = wtx.GetDebit(ISMINE_ALL);
CAmount nNet = nCredit - nDebit;
Expand Down
2 changes: 1 addition & 1 deletion src/rpcserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static const CRPCCommand vRPCCommands[] =
// --------------------- ------------------------ ----------------------- ---------- ---------- ---------
/* Overall control/query calls */
{"control", "getinfo", &getinfo, true, false, false}, /* uses wallet if enabled */
//{"control", "getmasternodecount", &getmasternodecount},
{"control", "getmasternodecount", &getmasternodecount},
{"control", "help", &help, true, true, false},
{"control", "stop", &stop, true, true, false},

Expand Down
2 changes: 1 addition & 1 deletion src/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void WalletTxToJSON(const CWalletTx& wtx, Object& entry)
BOOST_FOREACH (const uint256& conflict, wtx.GetConflicts())
conflicts.push_back(conflict.GetHex());
entry.push_back(Pair("walletconflicts", conflicts));
entry.push_back(Pair("time", wtx.GetTxTime()));
entry.push_back(Pair("time", wtx.isConflicted() ? (int64_t)wtx.nTimeReceived : wtx.GetTxTime()));
entry.push_back(Pair("timereceived", (int64_t)wtx.nTimeReceived));
BOOST_FOREACH (const PAIRTYPE(string, string) & item, wtx.mapValue)
entry.push_back(Pair(item.first, item.second));
Expand Down
5 changes: 3 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
* network protocol versioning
*/

static const int PROTOCOL_VERSION = 69301;
static const int PROTOCOL_VERSION_BEFORE_FORK = 69300;
static const int PROTOCOL_VERSION = 69302;
static const int PROTOCOL_VERSION_BEFORE_FORK2 = 69301;
static const int PROTOCOL_VERSION_BEFORE_FORK1 = 69300;

//! initial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209;
Expand Down
7 changes: 6 additions & 1 deletion src/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet)
wtx.nOrderPos = IncOrderPosNext();

wtx.nTimeSmart = wtx.nTimeReceived;
if (wtxIn.hashBlock != 0) {
if (wtxIn.hashBlock != 0 && !wtx.isConflicted()) {
if (mapBlockIndex.count(wtxIn.hashBlock)) {
int64_t latestNow = wtx.nTimeReceived;
int64_t latestEntry = 0;
Expand Down Expand Up @@ -1140,6 +1140,11 @@ set<uint256> CWalletTx::GetConflicts() const
return result;
}

bool CWalletTx::isConflicted() const
{
return !GetConflicts().empty();
}

void CWallet::ResendWalletTransactions()
{
// Do this infrequently and randomly to avoid giving away
Expand Down
1 change: 1 addition & 0 deletions src/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,7 @@ class CWalletTx : public CMerkleTx
void RelayWalletTransaction(std::string strCommand = "tx");

std::set<uint256> GetConflicts() const;
bool isConflicted() const;
};


Expand Down
3 changes: 2 additions & 1 deletion src/walletdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ void ThreadFlushWalletDB(const string& strFile)
bitdb.CloseDb(strFile);
bitdb.CheckpointLSN(strFile);

bitdb.mapFileUseCount.erase(mi++);
//bitdb.mapFileUseCount.erase(mi++); // reference this: https://github.com/bitcoin/bitcoin/issues/7475
LogPrint("db", "Flushed wallet.dat %dms\n", GetTimeMillis() - nStart);
}
}
Expand All @@ -903,6 +903,7 @@ bool BackupWallet(const CWallet& wallet, const string& strDest)
bitdb.CloseDb(wallet.strWalletFile);
bitdb.CheckpointLSN(wallet.strWalletFile);
bitdb.mapFileUseCount.erase(wallet.strWalletFile);
bitdb.lsn_reset(wallet.strWalletFile);

// Copy wallet.dat
std::string pathSrcStr = GetDataDir().string();
Expand Down

0 comments on commit b7487c5

Please sign in to comment.