Browse Source

Merge pull request #57 from jl777/dev

dev update
pull/4/head
ca333 7 years ago
committed by GitHub
parent
commit
4ea96514c7
  1. 15
      README.md
  2. 2
      src/assetchains.old
  3. 2
      src/bitcoind.cpp
  4. 10
      src/compat.h
  5. 14
      src/init.cpp
  6. 3
      src/komodo.h
  7. 13
      src/komodo_bitcoind.h
  8. 3
      src/komodo_events.h
  9. 12
      src/komodo_gateway.h
  10. 66
      src/komodo_interest.h
  11. 4
      src/komodo_kv.h
  12. 2
      src/komodo_pax.h
  13. 2
      src/komodo_structs.h
  14. 14
      src/komodo_utils.h
  15. 9
      src/main.cpp
  16. 4
      src/metrics.cpp
  17. 16
      src/net.cpp
  18. 2
      src/net.h
  19. 18
      src/netbase.cpp
  20. 2
      src/netbase.h
  21. 2
      src/protocol.cpp
  22. 6
      src/random.cpp
  23. 4
      src/rpcblockchain.cpp
  24. 6
      src/support/pagelocker.cpp
  25. 2
      src/test/alert_tests.cpp
  26. 30
      src/util.cpp
  27. 6
      src/util.h
  28. 2
      src/wallet/db.cpp

15
README.md

@ -39,10 +39,25 @@ sudo apt-get install build-essential pkg-config libcurl3-gnutls-dev libc6-dev li
Komodo
------
We have a release process that goes through several stages before it reaches master. This allows the most conservative users just use the master branch, which is only updated after the other branches have signed off on a release.
99% of the activity is in the dev branch, this is where I am testing each change one by one and there are literally thousands of updates. Only use this branch if you really want to be on the bleeding edge. I try to keep things stable, but there are times where necessarily there are bugs in the dev branch, since I am actively developing and debugging here. A good rule is to wait for at least 4 hours from the last update before using the dev branch (unless you know what you are doing)
After things look good in the dev branch, it is propagated to the beta branch, this is the version the notary nodes use. They are knowledegable command line server guys and so they have a keen eye for anything that wasnt caught during the dev cycle.
After the notary nodes verify things are working and the latest release is deemed stable, it is propagated to the dPoW branch. From here an automated Jenkins process builds it for all OS, and since the notary nodes are all unix, it is possible for some issues to be caught at this stage. The dPoW branch is what goes into the GUI installers.
After the GUI are updated and released and it is verified that no significant support issues were created, the master branch is finally updated.
Master branch: exchanges and users that build from the repo without changing branches
dPoW branch: autobuild into GUI installers, unix, osx, windows
beta branch: notary nodes, command line unix
dev branch: bleeding edge, possibly wont even compile, multiple updates per hour
```
git clone https://github.com/jl777/komodo
cd komodo
#you might want to: git checkout <branch>; git pull
./zcutil/fetch-params.sh
# -j8 uses 8 threads - replace 8 with number of threads you want to use
./zcutil/build.sh -j8

2
src/assetchains.old

@ -1,6 +1,6 @@
#!/bin/bash
set -x
delay=10
delay=60
source pubkey.txt
echo $pubkey

2
src/bitcoind.cpp

@ -173,7 +173,7 @@ bool AppInit(int argc, char* argv[])
exit(1);
}
#ifndef WIN32
#ifndef _WIN32
fDaemon = GetBoolArg("-daemon", false);
if (fDaemon)
{

10
src/compat.h

@ -10,7 +10,7 @@
#include "config/bitcoin-config.h"
#endif
#ifdef WIN32
#ifdef _WIN32
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
@ -46,7 +46,7 @@
#include <unistd.h>
#endif
#ifdef WIN32
#ifdef _WIN32
#define MSG_DONTWAIT 0
#else
typedef u_int SOCKET;
@ -64,7 +64,7 @@ typedef u_int SOCKET;
#define SOCKET_ERROR -1
#endif
#ifdef WIN32
#ifdef _WIN32
#ifndef S_IRUSR
#define S_IRUSR 0400
#define S_IWUSR 0200
@ -78,7 +78,7 @@ typedef u_int SOCKET;
#define MSG_NOSIGNAL 0
#endif
#ifndef WIN32
#ifndef _WIN32
// PRIO_MAX is not defined on Solaris
#ifndef PRIO_MAX
#define PRIO_MAX 20
@ -94,7 +94,7 @@ size_t strnlen( const char *start, size_t max_len);
#endif // HAVE_DECL_STRNLEN
bool static inline IsSelectableSocket(SOCKET s) {
#ifdef WIN32
#ifdef _WIN32
return true;
#else
return (s < FD_SETSIZE);

14
src/init.cpp

@ -40,7 +40,7 @@
#include <stdint.h>
#include <stdio.h>
#ifndef WIN32
#ifndef _WIN32
#include <signal.h>
#endif
@ -74,7 +74,7 @@ bool fFeeEstimatesInitialized = false;
static CZMQNotificationInterface* pzmqNotificationInterface = NULL;
#endif
#ifdef WIN32
#ifdef _WIN32
// Win32 LevelDB doesn't use file descriptors, and the ones used for
// accessing block files don't count towards the fd_set size limit
// anyway.
@ -236,7 +236,7 @@ void Shutdown()
}
#endif
#ifndef WIN32
#ifndef _WIN32
try {
boost::filesystem::remove(GetPidFile());
} catch (const boost::filesystem::filesystem_error& e) {
@ -334,7 +334,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-maxorphantx=<n>", strprintf(_("Keep at most <n> unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS));
strUsage += HelpMessageOpt("-par=<n>", strprintf(_("Set the number of script verification threads (%u to %d, 0 = auto, <0 = leave that many cores free, default: %d)"),
-(int)boost::thread::hardware_concurrency(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS));
#ifndef WIN32
#ifndef _WIN32
strUsage += HelpMessageOpt("-pid=<file>", strprintf(_("Specify pid file (default: %s)"), "komodod.pid"));
#endif
strUsage += HelpMessageOpt("-prune=<n>", strprintf(_("Reduce storage requirements by pruning (deleting) old blocks. This mode disables wallet support and is incompatible with -txindex. "
@ -716,7 +716,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// Disable confusing "helpful" text message on abort, Ctrl-C
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
#endif
#ifdef WIN32
#ifdef _WIN32
// Enable Data Execution Prevention (DEP)
// Minimum supported OS versions: WinXP SP3, WinVista >= SP1, Win Server 2008
// A failure is non-critical and needs no further attention!
@ -733,7 +733,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
if (!SetupNetworking())
return InitError("Error: Initializing networking failed");
#ifndef WIN32
#ifndef _WIN32
if (GetBoolArg("-sysperms", false)) {
#ifdef ENABLE_WALLET
if (!GetBoolArg("-disablewallet", false))
@ -1047,7 +1047,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Komodo is probably already running.") + " %s.", strDataDir, e.what()));
}
#ifndef WIN32
#ifndef _WIN32
CreatePidFile(GetPidFile(), getpid());
#endif
if (GetBoolArg("-shrinkdebugfile", !fDebug))

3
src/komodo.h

@ -547,7 +547,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
numvalid = bitweight(signedmask);
if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries/5)) )
{
printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts);
if ( height > 500000 )
printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts);
notarized = 1;
}
if ( NOTARY_PUBKEY33[0] != 0 && ASSETCHAINS_SYMBOL[0] == 0 )

13
src/komodo_bitcoind.h

@ -431,7 +431,10 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t
if ( strcmp(dest,"KMD") == 0 )
{
if ( KMDUSERPASS[0] != 0 )
jsonstr = komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,7771);
{
if ( ASSETCHAINS_SYMBOL[0] != 0 )
jsonstr = komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,7771);
}
//else jsonstr = _dex_getrawtransaction();
else return(0); // need universal way to issue DEX* API, since notaries mine most blocks, this ok
}
@ -476,7 +479,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t
return(retval);
}
uint256 komodo_getblockhash(int32_t height)
/*uint256 komodo_getblockhash(int32_t height)
{
uint256 hash; char params[128],*hexstr,*jsonstr; cJSON *result; int32_t i; uint8_t revbuf[32];
memset(&hash,0,sizeof(hash));
@ -502,12 +505,12 @@ uint256 komodo_getblockhash(int32_t height)
return(hash);
}
uint256 _komodo_getblockhash(int32_t height);
uint256 _komodo_getblockhash(int32_t height);*/
uint64_t komodo_seed(int32_t height)
{
uint64_t seed = 0;
if ( 0 ) // problem during init time, seeds are needed for loading blockindex, so null seeds...
/*if ( 0 ) // problem during init time, seeds are needed for loading blockindex, so null seeds...
{
uint256 hash,zero; CBlockIndex *pindex;
memset(&hash,0,sizeof(hash));
@ -524,7 +527,7 @@ uint64_t komodo_seed(int32_t height)
printf(" seed.%d\n",height);
seed = arith_uint256(hash.GetHex()).GetLow64();
}
else
else*/
{
seed = (height << 13) ^ (height << 2);
seed <<= 21;

3
src/komodo_events.h

@ -42,10 +42,11 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig
if ( komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid) != 0 )
{
if ( height > 50000 )
printf("[%s] error validating notarization ht.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,height,notarizedheight);
printf("[%s] error validating notarization ht.%d notarized_height.%d, if on a pruned %s node this can be ignored\n",ASSETCHAINS_SYMBOL,height,notarizedheight,dest);
}
else
{
//fprintf(stderr,"validated %s ht.%d notarized %d\n",ASSETCHAINS_SYMBOL,height,notarizedheight);
memset(&N,0,sizeof(N));
N.blockhash = notarized_hash;
N.desttxid = notarized_desttxid;

12
src/komodo_gateway.h

@ -1147,7 +1147,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
{
if ( baseids[i] < 0 )
{
printf("%d of %d illegal baseid.%d\n",i,n,baseids[i]);
static uint32_t counter;
if ( counter++ < 3 )
printf("%d of %d illegal baseid.%d, this can be ignored\n",i,n,baseids[i]);
continue;
}
bitcoin_address(coinaddr,60,&rmd160s[i*20],20);
@ -1351,7 +1353,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
void komodo_passport_iteration()
{
static long lastpos[34]; static char userpass[33][1024]; static uint32_t lasttime;
static long lastpos[34]; static char userpass[33][1024]; static uint32_t lasttime,callcounter;
int32_t maxseconds = 10;
FILE *fp; int32_t baseid,limit,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[16],dest[16]; uint32_t buf[3],starttime; cJSON *infoobj,*result; uint64_t RTmask = 0;
//printf("PASSPORT.(%s)\n",ASSETCHAINS_SYMBOL);
@ -1365,12 +1367,12 @@ void komodo_passport_iteration()
if ( ASSETCHAINS_SYMBOL[0] == 0 )
{
refid = 33;
limit = 1000000;
limit = 10000000;
jumblr_iteration();
}
else
{
limit = 10000;
limit = 10000000;
refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; // illegal base -> baseid.-1 -> 0
if ( refid == 0 )
{
@ -1384,6 +1386,8 @@ void komodo_passport_iteration()
return;
}*/
starttime = (uint32_t)time(NULL);
if ( callcounter++ < 1 )
limit = 10000;
if ( 0 && starttime == lasttime )
{
usleep(1000);

66
src/komodo_interest.h

@ -13,13 +13,18 @@
* *
******************************************************************************/
#define SATOSHIDEN ((uint64_t)100000000L)
#define dstr(x) ((double)(x) / SATOSHIDEN)
#define KOMODO_INTEREST ((uint64_t)(0.05 * COIN)) // 5%
int64_t MAX_MONEY = 200000000 * 100000000LL;
uint64_t komodo_earned_interest(int32_t height,int64_t paidinterest)
{
static uint64_t *interests; static int32_t maxheight;
uint64_t total; int32_t ind,incr = 100000;
uint64_t total; int32_t ind,incr = 10000;
// need to make interests persistent before 2030, or just hardfork interest/mining rewards disable after MAX_MONEY is exceeded
return(0);
if ( height >= maxheight )
{
if ( interests == 0 )
@ -36,16 +41,20 @@ uint64_t komodo_earned_interest(int32_t height,int64_t paidinterest)
}
ind = (height << 1);
if ( paidinterest < 0 ) // request
{
return(interests[ind]);
}
else
{
if ( interests[ind + 1] != paidinterest )
if ( interests[ind + 1] != paidinterest ) // need to handle skips like at 80000
{
//fprintf(stderr,"interests.%d %.8f %.8f vs paidinterest %.8f\n",height,dstr(interests[ind]),dstr(interests[ind+1]),dstr(paidinterest));
interests[ind + 1] = paidinterest;
if ( height == 0 )
interests[ind] = interests[ind + 1];
else interests[ind] = interests[ind - 2] + interests[ind + 1];
total = interests[ind];
if ( height <= 1 )
interests[ind] = 0;
else interests[ind] = interests[ind - 2] + interests[ind - 1];
total = interests[ind] + paidinterest;
//fprintf(stderr,"reset interests[height.%d to maxheight.%d] <- %.8f\n",height,maxheight,dstr(total));
for (++height; height<maxheight; height++)
{
ind = (height << 1);
@ -53,6 +62,7 @@ uint64_t komodo_earned_interest(int32_t height,int64_t paidinterest)
interests[ind + 1] = 0;
}
}
//else fprintf(stderr,"interests.%d %.8f %.8f\n",height,dstr(interests[ind]),dstr(interests[ind+1]));
}
return(0);
}
@ -64,9 +74,30 @@ uint64_t komodo_moneysupply(int32_t height)
else return(COIN * 100000000 + (height-1) * 3 + komodo_earned_interest(height,-1));
}
uint64_t _komodo_interestnew(uint64_t nValue,uint32_t nLockTime,uint32_t tiptime)
{
int32_t minutes; uint64_t interest = 0;
if ( (minutes= (tiptime - nLockTime) / 60) >= 60 )
{
if ( minutes > 365 * 24 * 60 )
minutes = 365 * 24 * 60;
minutes -= 59;
interest = ((nValue / 10512000) * minutes);
}
return(interest);
}
uint64_t komodo_interestnew(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime)
{
uint64_t interest = 0;
if ( komodo_moneysupply(txheight) < MAX_MONEY && nLockTime >= LOCKTIME_THRESHOLD && tiptime != 0 && nLockTime < tiptime && nValue >= 10*COIN )
interest = _komodo_interestnew(nValue,nLockTime,tiptime);
return(interest);
}
uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime)
{
int32_t minutes,exception; uint64_t numerator,denominator,interest = 0; uint32_t activation;
int32_t minutes,exception; uint64_t interestnew,numerator,denominator,interest = 0; uint32_t activation;
activation = 1491350400; // 1491350400 5th April
if ( ASSETCHAINS_SYMBOL[0] != 0 )
return(0);
@ -109,13 +140,24 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin
numerator = (nValue / 20); // assumes 5%!
if ( txheight < 250000 )
interest = (numerator / denominator);
else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60);
else if ( txheight < 1000000 )
{
interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60);
interestnew = _komodo_interestnew(nValue,nLockTime,tiptime);
if ( interest < interestnew )
printf("path0 current interest %.8f vs new %.8f for ht.%d %.8f locktime.%u tiptime.%u\n",dstr(interest),dstr(interestnew),txheight,dstr(nValue),nLockTime,tiptime);
}
else interest = _komodo_interestnew(nValue,nLockTime,tiptime);
}
else
else if ( txheight < 1000000 )
{
numerator = (nValue * KOMODO_INTEREST);
interest = (numerator / denominator) / COIN;
interestnew = _komodo_interestnew(nValue,nLockTime,tiptime);
if ( interest < interestnew )
printf("path0 current interest %.8f vs new %.8f for ht.%d %.8f locktime.%u tiptime.%u\n",dstr(interest),dstr(interestnew),txheight,dstr(nValue),nLockTime,tiptime);
}
else interest = _komodo_interestnew(nValue,nLockTime,tiptime);
}
else
{
@ -132,12 +174,16 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin
interest = (numerator / denominator) / COIN;
else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN;
}
else
else if ( txheight < 1000000 )
{
numerator = (nValue / 20); // assumes 5%!
interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60));
//fprintf(stderr,"interest %llu %.8f <- numerator.%llu minutes.%d\n",(long long)interest,(double)interest/COIN,(long long)numerator,(int32_t)minutes);
interestnew = _komodo_interestnew(nValue,nLockTime,tiptime);
if ( interest < interestnew )//|| (interestnew < 0.9999*interest && (interest-interestnew) > 50000) )
printf("path1 current interest %.8f vs new %.8f for ht.%d %.8f locktime.%u tiptime.%u\n",dstr(interest),dstr(interestnew),txheight,dstr(nValue),nLockTime,tiptime);
}
else interest = _komodo_interestnew(nValue,nLockTime,tiptime);
}
if ( 0 && numerator == (nValue * KOMODO_INTEREST) )
fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu) prod.%llu\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes));

4
src/komodo_kv.h

@ -106,7 +106,9 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
key = &opretbuf[13];
if ( keylen+13 > opretlen )
{
printf("komodo_kvupdate: keylen.%d + 13 > opretlen.%d\n",keylen,opretlen);
static uint32_t counter;
if ( counter++ < 3 )
printf("komodo_kvupdate: keylen.%d + 13 > opretlen.%d, this can be ignored\n",keylen,opretlen);
return;
}
valueptr = &key[keylen];

2
src/komodo_pax.h

@ -233,7 +233,7 @@ int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize)
{
static uint32_t lastcrc;
FILE *fp; char fname[512]; uint32_t crc32,check,timestamp; int32_t i,n=0,retval,fsize,len=0; uint8_t data[8192];
#ifdef WIN32
#ifdef _WIN32
sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"komodofeed");
#else
sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),(char *)"komodofeed");

2
src/komodo_structs.h

@ -16,7 +16,7 @@
#include "uthash.h"
#include "utlist.h"
/*#ifdef WIN32
/*#ifdef _WIN32
#define PACKED
#else
#define PACKED __attribute__((packed))

14
src/komodo_utils.h

@ -1305,7 +1305,7 @@ void komodo_statefname(char *fname,char *symbol,char *str)
}
else
{
#ifdef WIN32
#ifdef _WIN32
strcat(fname,"\\");
#else
strcat(fname,"/");
@ -1315,7 +1315,7 @@ void komodo_statefname(char *fname,char *symbol,char *str)
{
strcat(fname,symbol);
//printf("statefname.(%s) -> (%s)\n",symbol,fname);
#ifdef WIN32
#ifdef _WIN32
strcat(fname,"\\");
#else
strcat(fname,"/");
@ -1347,7 +1347,7 @@ void komodo_configfile(char *symbol,uint16_t port)
password[i*2] = 0;
sprintf(buf,"%s.conf",symbol);
BITCOIND_PORT = port;
#ifdef WIN32
#ifdef _WIN32
sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),buf);
#else
sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),buf);
@ -1371,7 +1371,7 @@ void komodo_configfile(char *symbol,uint16_t port)
}
}
strcpy(fname,GetDataDir().string().c_str());
#ifdef WIN32
#ifdef _WIN32
while ( fname[strlen(fname)-1] != '\\' )
fname[strlen(fname)-1] = 0;
strcat(fname,"komodo.conf");
@ -1576,12 +1576,12 @@ void komodo_args(char *argv0)
for (iter=0; iter<2; iter++)
{
strcpy(fname,GetDataDir().string().c_str());
#ifdef WIN32
#ifdef _WIN32
while ( fname[strlen(fname)-1] != '\\' )
fname[strlen(fname)-1] = 0;
if ( iter == 0 )
strcat(fname,".komodo\\komodo.conf");
else strcat(fname,".bitcoin\\bitcoin.conf");
strcat(fname,"Komodo\\komodo.conf");
else strcat(fname,"Bitcoin\\bitcoin.conf");
#else
while ( fname[strlen(fname)-1] != '/' )
fname[strlen(fname)-1] = 0;

9
src/main.cpp

@ -2365,7 +2365,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
return false;
control.Add(vChecks);
}
komodo_earned_interest(pindex->nHeight,sum);
if ( ASSETCHAINS_SYMBOL[0] == 0 )
komodo_earned_interest(pindex->nHeight,sum);
CTxUndo undoDummy;
if (i > 0) {
blockundo.vtxundo.push_back(CTxUndo());
@ -4977,7 +4978,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
pfrom->PushMessage("headers", vHeaders);
}
else if ( NOTARY_PUBKEY33[0] != 0 )
fprintf(stderr,"you can ignore redundant getheaders from peer.%d %d prev.%d\n",(int32_t)pfrom->id,(int32_t)(pindex ? pindex->nHeight : -1),pfrom->lasthdrsreq);
{
static uint32_t counter;
if ( counter++ < 3 )
fprintf(stderr,"you can ignore redundant getheaders from peer.%d %d prev.%d\n",(int32_t)pfrom->id,(int32_t)(pindex ? pindex->nHeight : -1),pfrom->lasthdrsreq);
}
}

4
src/metrics.cpp

@ -411,7 +411,7 @@ void ThreadShowMetricsScreen()
// Get current window size
if (isTTY) {
#ifdef WIN32
#ifdef _WIN32
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
cols = csbi.srWindow.Right - csbi.srWindow.Left + 1;
@ -421,7 +421,7 @@ void ThreadShowMetricsScreen()
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != -1 && w.ws_col != 0) {
cols = w.ws_col;
}
#endif
#endif
}
if (isScreen) {

16
src/net.cpp

@ -17,7 +17,7 @@
#include "ui_interface.h"
#include "crypto/common.h"
#ifdef WIN32
#ifdef _WIN32
#include <string.h>
#else
#include <fcntl.h>
@ -42,7 +42,7 @@
// Fix for ancient MinGW versions, that don't have defined these in ws2tcpip.h.
// Todo: Can be removed when our pull-tester is upgraded to a modern MinGW version.
#ifdef WIN32
#ifdef _WIN32
#ifndef PROTECTION_LEVEL_UNRESTRICTED
#define PROTECTION_LEVEL_UNRESTRICTED 10
#endif
@ -930,7 +930,7 @@ static void AcceptConnection(const ListenSocket& hListenSocket) {
// According to the internet TCP_NODELAY is not carried into accepted sockets
// on all platforms. Set it again here just to be sure.
int set = 1;
#ifdef WIN32
#ifdef _WIN32
setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (const char*)&set, sizeof(int));
#else
setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (void*)&set, sizeof(int));
@ -1727,7 +1727,7 @@ bool BindListenPort(const CService &addrBind, string& strError, bool fWhiteliste
}
#ifndef WIN32
#ifndef _WIN32
#ifdef SO_NOSIGPIPE
// Different way of disabling SIGPIPE on BSD
setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int));
@ -1753,13 +1753,13 @@ bool BindListenPort(const CService &addrBind, string& strError, bool fWhiteliste
// and enable it by default or not. Try to enable it, if possible.
if (addrBind.IsIPv6()) {
#ifdef IPV6_V6ONLY
#ifdef WIN32
#ifdef _WIN32
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&nOne, sizeof(int));
#else
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&nOne, sizeof(int));
#endif
#endif
#ifdef WIN32
#ifdef _WIN32
int nProtLevel = PROTECTION_LEVEL_UNRESTRICTED;
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_PROTECTION_LEVEL, (const char*)&nProtLevel, sizeof(int));
#endif
@ -1800,7 +1800,7 @@ void static Discover(boost::thread_group& threadGroup)
if (!fDiscover)
return;
#ifdef WIN32
#ifdef _WIN32
// Get local host IP
char pszHostName[256] = "";
if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR)
@ -1945,7 +1945,7 @@ public:
delete pnodeLocalHost;
pnodeLocalHost = NULL;
#ifdef WIN32
#ifdef _WIN32
// Shutdown Windows Sockets
WSACleanup();
#endif

2
src/net.h

@ -22,7 +22,7 @@
#include <deque>
#include <stdint.h>
#ifndef WIN32
#ifndef _WIN32
#include <arpa/inet.h>
#endif

18
src/netbase.cpp

@ -26,7 +26,7 @@
#include <netdb.h>
#endif
#ifndef WIN32
#ifndef _WIN32
#if HAVE_INET_PTON
#include <arpa/inet.h>
#endif
@ -129,7 +129,7 @@ bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, unsign
aiHint.ai_socktype = SOCK_STREAM;
aiHint.ai_protocol = IPPROTO_TCP;
aiHint.ai_family = AF_UNSPEC;
#ifdef WIN32
#ifdef _WIN32
aiHint.ai_flags = fAllowLookup ? 0 : AI_NUMERICHOST;
#else
aiHint.ai_flags = fAllowLookup ? AI_ADDRCONFIG : AI_NUMERICHOST;
@ -454,7 +454,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
#endif
//Disable Nagle's algorithm
#ifdef WIN32
#ifdef _WIN32
setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (const char*)&set, sizeof(int));
#else
setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (void*)&set, sizeof(int));
@ -488,7 +488,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
return false;
}
socklen_t nRetSize = sizeof(nRet);
#ifdef WIN32
#ifdef _WIN32
if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, (char*)(&nRet), &nRetSize) == SOCKET_ERROR)
#else
if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, &nRet, &nRetSize) == SOCKET_ERROR)
@ -505,7 +505,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
return false;
}
}
#ifdef WIN32
#ifdef _WIN32
else if (WSAGetLastError() != WSAEISCONN)
#else
else
@ -1348,7 +1348,7 @@ bool operator<(const CSubNet& a, const CSubNet& b)
return (a.network < b.network || (a.network == b.network && memcmp(a.netmask, b.netmask, 16) < 0));
}
#ifdef WIN32
#ifdef _WIN32
std::string NetworkErrorString(int err)
{
char buf[256];
@ -1386,7 +1386,7 @@ bool CloseSocket(SOCKET& hSocket)
{
if (hSocket == INVALID_SOCKET)
return false;
#ifdef WIN32
#ifdef _WIN32
int ret = closesocket(hSocket);
#else
int ret = close(hSocket);
@ -1398,7 +1398,7 @@ bool CloseSocket(SOCKET& hSocket)
bool SetSocketNonBlocking(SOCKET& hSocket, bool fNonBlocking)
{
if (fNonBlocking) {
#ifdef WIN32
#ifdef _WIN32
u_long nOne = 1;
if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR) {
#else
@ -1409,7 +1409,7 @@ bool SetSocketNonBlocking(SOCKET& hSocket, bool fNonBlocking)
return false;
}
} else {
#ifdef WIN32
#ifdef _WIN32
u_long nZero = 0;
if (ioctlsocket(hSocket, FIONBIO, &nZero) == SOCKET_ERROR) {
#else

2
src/netbase.h

@ -22,7 +22,7 @@ extern bool fNameLookup;
/** -timeout default */
static const int DEFAULT_CONNECT_TIMEOUT = 5000;
#ifdef WIN32
#ifdef _WIN32
// In MSVC, this is defined as a macro, undefine it to prevent a compile and link error
#undef SetPort
#endif

2
src/protocol.cpp

@ -8,7 +8,7 @@
#include "util.h"
#include "utilstrencodings.h"
#ifndef WIN32
#ifndef _WIN32
# include <arpa/inet.h>
#endif

6
src/random.cpp

@ -6,7 +6,7 @@
#include "random.h"
#include "support/cleanse.h"
#ifdef WIN32
#ifdef _WIN32
#include "compat.h" // for Windows API
#endif
#include "serialize.h" // for begin_ptr(vec)
@ -15,7 +15,7 @@
#include <limits>
#ifndef WIN32
#ifndef _WIN32
#include <sys/time.h>
#endif
@ -24,7 +24,7 @@
static inline int64_t GetPerformanceCounter()
{
int64_t nCounter = 0;
#ifdef WIN32
#ifdef _WIN32
QueryPerformanceCounter((LARGE_INTEGER*)&nCounter);
#else
timeval t;

4
src/rpcblockchain.cpp

@ -309,7 +309,7 @@ UniValue getblockhash(const UniValue& params, bool fHelp)
return pblockindex->GetBlockHash().GetHex();
}
uint256 _komodo_getblockhash(int32_t nHeight)
/*uint256 _komodo_getblockhash(int32_t nHeight)
{
uint256 hash;
LOCK(cs_main);
@ -323,7 +323,7 @@ uint256 _komodo_getblockhash(int32_t nHeight)
printf(" blockhash.%d\n",nHeight);
} else memset(&hash,0,sizeof(hash));
return(hash);
}
}*/
UniValue getblockheader(const UniValue& params, bool fHelp)
{

6
src/support/pagelocker.cpp

@ -8,7 +8,7 @@
#include "config/bitcoin-config.h"
#endif
#ifdef WIN32
#ifdef _WIN32
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
@ -49,7 +49,7 @@ static inline size_t GetSystemPageSize()
bool MemoryPageLocker::Lock(const void* addr, size_t len)
{
#ifdef WIN32
#ifdef _WIN32
return VirtualLock(const_cast<void*>(addr), len) != 0;
#else
return mlock(addr, len) == 0;
@ -58,7 +58,7 @@ bool MemoryPageLocker::Lock(const void* addr, size_t len)
bool MemoryPageLocker::Unlock(const void* addr, size_t len)
{
#ifdef WIN32
#ifdef _WIN32
return VirtualUnlock(const_cast<void*>(addr), len) != 0;
#else
return munlock(addr, len) == 0;

2
src/test/alert_tests.cpp

@ -340,7 +340,7 @@ BOOST_AUTO_TEST_CASE(AlertNotify)
// Windows built-in echo semantics are different than posixy shells. Quotes and
// whitespace are printed literally.
#ifndef WIN32
#ifndef _WIN32
BOOST_CHECK_EQUAL(r[0], "Alert 1");
BOOST_CHECK_EQUAL(r[1], "Alert 2, cancels 1");
BOOST_CHECK_EQUAL(r[2], "Alert 2, cancels 1");

30
src/util.cpp

@ -23,7 +23,7 @@
#include <pthread_np.h>
#endif
#ifndef WIN32
#ifndef _WIN32
// for posix_fallocate
#ifdef __linux__
@ -335,7 +335,7 @@ void ParseParameters(int argc, const char* const argv[])
strValue = str.substr(is_index+1);
str = str.substr(0, is_index);
}
#ifdef WIN32
#ifdef _WIN32
boost::to_lower(str);
if (boost::algorithm::starts_with(str, "/"))
str = "-" + str.substr(1);
@ -419,7 +419,7 @@ std::string HelpMessageOpt(const std::string &option, const std::string &message
static std::string FormatException(const std::exception* pex, const char* pszThread)
{
#ifdef WIN32
#ifdef _WIN32
char pszModule[MAX_PATH] = "";
GetModuleFileNameA(NULL, pszModule, sizeof(pszModule));
#else
@ -455,7 +455,7 @@ boost::filesystem::path GetDefaultDataDir()
// Windows >= Vista: C:\Users\Username\AppData\Roaming\Zcash
// Mac: ~/Library/Application Support/Zcash
// Unix: ~/.zcash
#ifdef WIN32
#ifdef _WIN32
// Windows
if ( symbol[0] == 0 )
return GetSpecialFolderPath(CSIDL_APPDATA) / "Komodo";
@ -502,7 +502,7 @@ static boost::filesystem::path ZC_GetBaseParamsDir()
// Windows >= Vista: C:\Users\Username\AppData\Roaming\ZcashParams
// Mac: ~/Library/Application Support/ZcashParams
// Unix: ~/.zcash-params
#ifdef WIN32
#ifdef _WIN32
// Windows
return GetSpecialFolderPath(CSIDL_APPDATA) / "ZcashParams";
#else
@ -648,7 +648,7 @@ void ReadConfigFile(map<string, string>& mapSettingsRet,
//fprintf(stderr,"from conf file %s RPC %u, used to be %u\n",ASSETCHAINS_SYMBOL,BITCOIND_PORT,BITCOIND_PORT);
}
#ifndef WIN32
#ifndef _WIN32
boost::filesystem::path GetPidFile()
{
boost::filesystem::path pathPidFile(GetArg("-pid", "komodod.pid"));
@ -669,13 +669,13 @@ void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
{
#ifdef WIN32
#ifdef _WIN32
return MoveFileExA(src.string().c_str(), dest.string().c_str(),
MOVEFILE_REPLACE_EXISTING) != 0;
#else
int rc = std::rename(src.string().c_str(), dest.string().c_str());
return (rc == 0);
#endif /* WIN32 */
#endif /* _WIN32 */
}
/**
@ -700,7 +700,7 @@ bool TryCreateDirectory(const boost::filesystem::path& p)
void FileCommit(FILE *fileout)
{
fflush(fileout); // harmless if redundantly called
#ifdef WIN32
#ifdef _WIN32
HANDLE hFile = (HANDLE)_get_osfhandle(_fileno(fileout));
FlushFileBuffers(hFile);
#else
@ -815,7 +815,7 @@ void ShrinkDebugFile()
fclose(file);
}
#ifdef WIN32
#ifdef _WIN32
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate)
{
namespace fs = boost::filesystem;
@ -838,7 +838,7 @@ boost::filesystem::path GetTempPath() {
#else
// TODO: remove when we don't support filesystem v2 anymore
boost::filesystem::path path;
#ifdef WIN32
#ifdef _WIN32
char pszPath[MAX_PATH] = "";
if (GetTempPathA(MAX_PATH, pszPath))
@ -898,7 +898,7 @@ void SetupEnvironment()
bool SetupNetworking()
{
#ifdef WIN32
#ifdef _WIN32
// Initialize Windows Sockets
WSADATA wsadata;
int ret = WSAStartup(MAKEWORD(2,2), &wsadata);
@ -910,15 +910,15 @@ bool SetupNetworking()
void SetThreadPriority(int nPriority)
{
#ifdef WIN32
#ifdef _WIN32
SetThreadPriority(GetCurrentThread(), nPriority);
#else // WIN32
#else // _WIN32
#ifdef PRIO_THREAD
setpriority(PRIO_THREAD, 0, nPriority);
#else // PRIO_THREAD
setpriority(PRIO_PROCESS, 0, nPriority);
#endif // PRIO_THREAD
#endif // WIN32
#endif // _WIN32
}
std::string PrivacyInfo()

6
src/util.h

@ -124,7 +124,7 @@ boost::filesystem::path GetDefaultDataDir();
const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);
void ClearDatadirCache();
boost::filesystem::path GetConfigFile();
#ifndef WIN32
#ifndef _WIN32
boost::filesystem::path GetPidFile();
void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
#endif
@ -133,7 +133,7 @@ public:
missing_zcash_conf() : std::runtime_error("Missing komodo.conf") { }
};
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
#ifdef WIN32
#ifdef _WIN32
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
#endif
boost::filesystem::path GetTempPath();
@ -150,7 +150,7 @@ std::string LicenseInfo();
inline bool IsSwitchChar(char c)
{
#ifdef WIN32
#ifdef _WIN32
return c == '-' || c == '/';
#else
return c == '-';

2
src/wallet/db.cpp

@ -13,7 +13,7 @@
#include <stdint.h>
#ifndef WIN32
#ifndef _WIN32
#include <sys/stat.h>
#endif

Loading…
Cancel
Save