From 70fb62aebbd19e9bed1d3988b9ba8dc627766833 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 17 Jan 2017 10:50:36 +0200 Subject: [PATCH 01/38] fix RWM3UrsRP4WtH6DTetm5KmUyBASvFCV6wH --- src/REVS.snapshot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/REVS.snapshot b/src/REVS.snapshot index 68a85514b..06c57a1f1 100644 --- a/src/REVS.snapshot +++ b/src/REVS.snapshot @@ -5443,7 +5443,7 @@ fiat/revs sendtoaddress RURYZ8FhS5oJ1h1xuv78EXe8rA32SiM4Dy 304.32862968 fiat/revs sendtoaddress RGba6AJogyFQGuMAzD1czE67KR6eW5PV2k 304.98070893 fiat/revs sendtoaddress RXMtwrMXyimRU5CWSdtWzHwWmcCeAc62ua 306.73973391 fiat/revs sendtoaddress RYEmXCS9D2qR71XKzzWbsiAMZGg5E2UWt3 307.15599818 -fiat/revs sendtoaddress RWM3UrsRP4WtH6DTetm5KmUyBASvFCV6wH 313.40690770 +fiat/revs sendtoaddress RWM3UrsRP4WtH6DTetm5KmUyBASvFCV6wH 3005.5069077 fiat/revs sendtoaddress RL4hFVzdntZQ2DM59QXZc619boZV45YFdk 316.05434626 fiat/revs sendtoaddress RG3vbi2TJp9jeqn8qDSnL1W5eFUeTGQJmu 317.33569076 fiat/revs sendtoaddress RQYgriDwRUuUbfw3E1AecAHZXryGSx1BdN 337.23469627 From 2f5fa4823acf097d947550fbee6de0b1300d0cb6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 17 Jan 2017 11:16:56 +0200 Subject: [PATCH 02/38] pause between assetchains --- src/assetchains | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/assetchains b/src/assetchains index ac817bde3..0533ed4cb 100755 --- a/src/assetchains +++ b/src/assetchains @@ -4,48 +4,90 @@ source pubkey.txt echo $pubkey ./komodod -pubkey=$pubkey -ac_name=REVS -ac_supply=1300000 -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=SUPERNET -ac_supply=816061 -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=DEX -ac_supply=999999 -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=PANGEA -ac_supply=999999 -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=JUMBLR -ac_supply=999999 -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=BET -ac_supply=999999 -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=CRYPTO -ac_supply=999999 -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=HODL -ac_supply=9999999 -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=SHARK -ac_supply=1401 -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=BOTS -ac_supply=999999 -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=MGW -ac_supply=999999 -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=MVP -ac_supply=1000000 -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=EUR -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=JPY -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=GBP -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=AUD -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=CAD -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=CHF -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=NZD -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=CNY -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=RUB -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=MXN -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=BRL -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=INR -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=HKD -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=TRY -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=ZAR -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=PLN -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=NOK -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=SEK -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=DKK -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=CZK -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=HUF -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=ILS -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=KRW -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=MYR -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=PHP -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=RON -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=SGD -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=THB -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=BGN -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=IDR -addnode=78.47.196.146 $1 -gen & +sleep 10 ./komodod -pubkey=$pubkey -ac_name=HRK -addnode=78.47.196.146 $1 -gen & - From 112dc7b154cfee57bd0233a8847996edc8cf460f Mon Sep 17 00:00:00 2001 From: Joel Barker Date: Tue, 17 Jan 2017 12:51:38 +0000 Subject: [PATCH 03/38] added script to make static binaries for mac --- README-mac.md | 3 +++ makeDistrib.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 makeDistrib.sh diff --git a/README-mac.md b/README-mac.md index f6b6f8a10..c085cb617 100644 --- a/README-mac.md +++ b/README-mac.md @@ -26,6 +26,9 @@ cd komodo git checkout dev ./zcutil/build-mac.sh ``` + +To build a distributable version of komodo then run the makeDistrib.sh script after building. + When you are done building, you need to do a few things in the [Configuration](https://github.com/zcash/zcash/wiki/1.0-User-Guide#configuration) section of the Zcash User Guide differently because we are on the Mac. All instances of `~/.zcash` need to be replaced by `~/Library/Application\ Support/Zcash` The fetch-params.sh script, however, has already been altered to fetch the proving keys into the correct directory to conform to Mac specific naming conventions. diff --git a/makeDistrib.sh b/makeDistrib.sh new file mode 100755 index 000000000..ad72fbb16 --- /dev/null +++ b/makeDistrib.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +TMP_DIR=~/tmp/komodo + +# make a tmp directory +mkdir -p $TMP_DIR +echo "making $TMP_DIR" + +binaries=("komodo-cli" "komodod") + +for binary in "${binaries[@]}"; +do + echo "copying $binary to $TMP_DIR" + + cp src/$binary $TMP_DIR + + # find the dylibs to copy for komodod + DYLIBS=`otool -L $TMP_DIR/$binary | grep "/usr/local" | awk -F' ' '{ print $1 }'` + echo "copying $DYLIBS to $TMP_DIR" + + # copy the dylibs to the tmpdir + for dylib in $DYLIBS; do cp -rf $dylib $TMP_DIR/; done + + # modify komodod to point to dylibs + echo "modifying $binary to use local libraries" + for dylib in $DYLIBS; do install_name_tool -change $dylib @executable_path/`basename $dylib` $TMP_DIR/$binary; done; +done + + + + + + + + From eea23236bd7232167a0483802fe629cf62b5b56e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 13:04:53 +0200 Subject: [PATCH 04/38] ma60 paxprice --- src/REVS.snapshot | 2 +- src/komodo_pax.h | 20 +++++++++++++++++++- src/komodo_utils.h | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/REVS.snapshot b/src/REVS.snapshot index 06c57a1f1..d150a91c1 100644 --- a/src/REVS.snapshot +++ b/src/REVS.snapshot @@ -5587,7 +5587,7 @@ fiat/revs sendtoaddress RWU752dM2s3sjpPZCaWpihUEYmbL6m7Pne 2537.07064054 fiat/revs sendtoaddress RTCq8NorFo4bNwUTNnyKg9YwYgxH49SbbY 2556.94031291 fiat/revs sendtoaddress RNiUNTzDtBgQyA64txPH3W7gMXAjJriM1T 2597.18712886 fiat/revs sendtoaddress RHuJvZphT6ZhKP3hxCRDDsCnNmCMtDy43r 2603.59182293 -fiat/revs sendtoaddress RKxJ7a2J8faQ7VD5dAyFFjMU9DxMDFqv3D 2692.10000000 +fiat/revs sendtoaddress RKxJ7a2J8faQ7VD5dAyFFjMU9DxMDFqv3D 1.10000000 fiat/revs sendtoaddress RGyC2cGKrTbv1zQq4f6fbMc2byCNdUAwBX 2700.00000000 fiat/revs sendtoaddress RWJPh9C4WQGuT8UDMXb4u278Teqzcq3zQt 2784.22122603 fiat/revs sendtoaddress RNjNREuiLJ3D5eWGqLcsMvjno5RBsBxqKN 2894.22787069 diff --git a/src/komodo_pax.h b/src/komodo_pax.h index cc835dc05..85212e593 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -451,7 +451,7 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha return(0); } -uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) +uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,tolerance,den,densum,sum=0,votes[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],btcusds[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtcs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtc,btcusd; *seedp = komodo_seed(height); @@ -491,6 +491,24 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin return(komodo_paxcorrelation(votes,numvotes,*seedp) * basevolume / 100000); } +uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) +{ + int32_t i,nonz=0; uint64_t price,seed,sum = 0; + for (i=0; i<64; i++) + { + if ( (price= komodo_paxpriceB(&seed,height-i,base,rel,basevolume)) != 0 ) + { + sum += price; + nonz++; + } + if ( height < 150000 ) + break; + } + if ( nonz != 0 ) + sum /= nonz; + return(sum); +} + int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel) { int32_t baseid=-1,relid=-1,i,num = 0; uint32_t *ptr; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 81a116eda..57171e2cb 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1533,6 +1533,8 @@ void komodo_args() fclose(fp); //printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS); } else printf("couldnt open.(%s)\n",fname); + if ( IS_KOMODO_NOTARY == 0 ) + break; } } //fprintf(stderr,"%s chain params initialized\n",ASSETCHAINS_SYMBOL); From 49db2cbbe10ab1f641fd96c99ac044cd21c41c52 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 13:35:32 +0200 Subject: [PATCH 05/38] test --- src/komodo_pax.h | 2 +- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 85212e593..159980cd7 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -501,7 +501,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin sum += price; nonz++; } - if ( height < 150000 ) + if ( height < 1500 ) // set to future height break; } if ( nonz != 0 ) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 604391023..9a9bd637c 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2510,7 +2510,7 @@ uint64_t komodo_interestsum() BOOST_FOREACH(const COutput& out,vecOutputs) { CAmount nValue = out.tx->vout[out.i].nValue; - if ( out.tx->nLockTime != 0 ) + if ( out.tx->nLockTime != 0 && out.fSpendable != 0 ) { BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock()); CBlockIndex *tipindex,*pindex = it->second; From e87f553f7d33e3992db57c9219b8be19abfa6997 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 13:46:36 +0200 Subject: [PATCH 06/38] test --- src/komodo_events.h | 2 +- src/komodo_pax.h | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index d8aafb333..14a9478af 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -40,7 +40,7 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig { struct komodo_event_notarized N; if ( komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid) != 0 ) - printf("%s error validating notarization\n",ASSETCHAINS_SYMBOL); + printf("[%s] error validating notarization ht.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,height,notarizedheight); else { memset(&N,0,sizeof(N)); diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 159980cd7..3c06a5958 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -451,7 +451,7 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha return(0); } -uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) +uint64_t komodo_paxpriceC(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,tolerance,den,densum,sum=0,votes[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],btcusds[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtcs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtc,btcusd; *seedp = komodo_seed(height); @@ -491,12 +491,28 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui return(komodo_paxcorrelation(votes,numvotes,*seedp) * basevolume / 100000); } +uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) +{ + int32_t i,nonz=0; uint64_t price,seed,sum = 0; + for (i=0; i<2; i++) + { + if ( (price= komodo_paxpriceC(&seed,height-i,base,rel,basevolume)) != 0 ) + { + sum += price; + nonz++; + } + } + if ( nonz != 0 ) + sum /= nonz; + return(sum); +} + uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t i,nonz=0; uint64_t price,seed,sum = 0; - for (i=0; i<64; i++) + for (i=0; i<2; i++) { - if ( (price= komodo_paxpriceB(&seed,height-i,base,rel,basevolume)) != 0 ) + if ( (price= komodo_paxpriceB(&seed,height-i*16,base,rel,basevolume)) != 0 ) { sum += price; nonz++; From a8dabad5e6121fcce8fe3155799666d9edd8231c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 13:51:58 +0200 Subject: [PATCH 07/38] test --- src/komodo_pax.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 3c06a5958..595e8480a 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -494,7 +494,7 @@ uint64_t komodo_paxpriceC(uint64_t *seedp,int32_t height,char *base,char *rel,ui uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t i,nonz=0; uint64_t price,seed,sum = 0; - for (i=0; i<2; i++) + for (i=0; i<3; i++) { if ( (price= komodo_paxpriceC(&seed,height-i,base,rel,basevolume)) != 0 ) { @@ -510,9 +510,9 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t i,nonz=0; uint64_t price,seed,sum = 0; - for (i=0; i<2; i++) + for (i=0; i<3; i++) { - if ( (price= komodo_paxpriceB(&seed,height-i*16,base,rel,basevolume)) != 0 ) + if ( (price= komodo_paxpriceB(&seed,height-i*17,base,rel,basevolume)) != 0 ) { sum += price; nonz++; From b21d816c5f62eacf99fc4618c69f3c000c55f18f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 13:55:30 +0200 Subject: [PATCH 08/38] test --- src/komodo_pax.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 595e8480a..ed4ef4d8d 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -494,7 +494,7 @@ uint64_t komodo_paxpriceC(uint64_t *seedp,int32_t height,char *base,char *rel,ui uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t i,nonz=0; uint64_t price,seed,sum = 0; - for (i=0; i<3; i++) + for (i=0; i<2; i++) { if ( (price= komodo_paxpriceC(&seed,height-i,base,rel,basevolume)) != 0 ) { From d5a61fcabb6be8802ce2d289a8d083b06e9e7d4d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 14:00:28 +0200 Subject: [PATCH 09/38] test --- src/komodo_pax.h | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index ed4ef4d8d..b2ac8cad0 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -451,7 +451,7 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha return(0); } -uint64_t komodo_paxpriceC(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) +uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,tolerance,den,densum,sum=0,votes[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],btcusds[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtcs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtc,btcusd; *seedp = komodo_seed(height); @@ -491,28 +491,12 @@ uint64_t komodo_paxpriceC(uint64_t *seedp,int32_t height,char *base,char *rel,ui return(komodo_paxcorrelation(votes,numvotes,*seedp) * basevolume / 100000); } -uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) -{ - int32_t i,nonz=0; uint64_t price,seed,sum = 0; - for (i=0; i<2; i++) - { - if ( (price= komodo_paxpriceC(&seed,height-i,base,rel,basevolume)) != 0 ) - { - sum += price; - nonz++; - } - } - if ( nonz != 0 ) - sum /= nonz; - return(sum); -} - uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t i,nonz=0; uint64_t price,seed,sum = 0; - for (i=0; i<3; i++) + for (i=0; i<16; i++) { - if ( (price= komodo_paxpriceB(&seed,height-i*17,base,rel,basevolume)) != 0 ) + if ( (price= komodo_paxpriceB(&seed,height-i,base,rel,basevolume)) != 0 ) { sum += price; nonz++; From bba30a43a5998b1e9aa9211136a097b008c8d905 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 14:05:01 +0200 Subject: [PATCH 10/38] test --- src/komodo_pax.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index b2ac8cad0..700546453 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -429,7 +429,7 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha height -= 10; if ( (baseid= komodo_baseid(base)) >= 0 && (relid= komodo_baseid(rel)) >= 0 ) { - portable_mutex_lock(&komodo_mutex); + //portable_mutex_lock(&komodo_mutex); for (i=NUM_PRICES-1; i>=0; i--) { ptr = &PVALS[36 * i]; @@ -440,13 +440,13 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha *kmdbtcp = ptr[MAX_CURRENCIES + 1] / 539; *btcusdp = ptr[MAX_CURRENCIES + 2] / 539; } - portable_mutex_unlock(&komodo_mutex); + //portable_mutex_unlock(&komodo_mutex); if ( kmdbtc != 0 && btcusd != 0 ) return(komodo_paxcalc(&ptr[1],baseid,relid,basevolume,kmdbtc,btcusd)); else return(0); } } - portable_mutex_unlock(&komodo_mutex); + //portable_mutex_unlock(&komodo_mutex); } //else printf("paxprice invalid base.%s %d, rel.%s %d\n",base,baseid,rel,relid); return(0); } @@ -494,7 +494,8 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t i,nonz=0; uint64_t price,seed,sum = 0; - for (i=0; i<16; i++) + portable_mutex_lock(&komodo_mutex); + for (i=0; i<64; i++) { if ( (price= komodo_paxpriceB(&seed,height-i,base,rel,basevolume)) != 0 ) { @@ -504,6 +505,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin if ( height < 1500 ) // set to future height break; } + portable_mutex_unlock(&komodo_mutex); if ( nonz != 0 ) sum /= nonz; return(sum); From e08169c4b32ff4a031b8172ee5d45da0bf16e928 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 14:18:28 +0200 Subject: [PATCH 11/38] test --- src/komodo_pax.h | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 700546453..063a12636 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -451,6 +451,32 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha return(0); } +int32_t komodo_kmdbtcusd(int32_t rwflag,uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height) +{ + static uint64_t *KMDBTCS,*BTCUSDS; static int32_t maxheight; int32_t incr = 10000; + if ( height >= maxheight ) + { + KMDBTCS = realloc(KMDBTCS,((incr + maxheight) * sizeof(*KMDBTCS))); + memset(&KMDBTCS[maxheight],0,(incr * sizeof(*KMDBTCS))); + BTCUSDS = realloc(BTCUSDS,((incr + maxheight) * sizeof(*BTCUSDS))); + memset(&BTCUSDS[maxheight],0,(incr * sizeof(*BTCUSDS))); + maxheight += incr; + } + if ( rwflag == 0 ) + { + *kmdbtcp = KMDBTCS[height]; + *btcusdp = BTCUSDS[height]; + } + else + { + KMDBTCS[height] = *kmdbtcp; + BTCUSDS[height] = *btcusdp; + } + if ( *kmdbtcp != 0 && *btcusdp != 0 ) + return(0); + else return(-1); +} + uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,tolerance,den,densum,sum=0,votes[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],btcusds[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtcs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtc,btcusd; @@ -467,15 +493,19 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui } numvotes = (int32_t)(sizeof(Peggy_inds)/sizeof(*Peggy_inds)); memset(votes,0,sizeof(votes)); - memset(btcusds,0,sizeof(btcusds)); - memset(kmdbtcs,0,sizeof(kmdbtcs)); - for (i=0; i Date: Wed, 18 Jan 2017 14:29:36 +0200 Subject: [PATCH 12/38] test --- src/komodo_pax.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 063a12636..86a07adbb 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -493,7 +493,7 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui } numvotes = (int32_t)(sizeof(Peggy_inds)/sizeof(*Peggy_inds)); memset(votes,0,sizeof(votes)); - if ( komodo_kmdbtcusd(0,&kmdbtc,&btcusd,height) < 0 ) + //if ( komodo_kmdbtcusd(0,&kmdbtc,&btcusd,height) < 0 ) { memset(btcusds,0,sizeof(btcusds)); memset(kmdbtcs,0,sizeof(kmdbtcs)); @@ -504,7 +504,7 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui } kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,*seedp) * 539; btcusd = komodo_paxcorrelation(btcusds,numvotes,*seedp) * 539; - komodo_kmdbtcusd(1,&kmdbtc,&btcusd,height); + //komodo_kmdbtcusd(1,&kmdbtc,&btcusd,height); } for (i=nonz=0; i> 1)) * SATOSHIDEN) / price; + if ( diff < 0 ) + diff = -diff; + if ( diff < (SATOSHIDEN / 1000) ) + break; + } } portable_mutex_unlock(&komodo_mutex); if ( nonz != 0 ) From acd6ccf4629427e6b08febf8a787021842b1a64f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 14:35:55 +0200 Subject: [PATCH 13/38] test --- src/komodo_pax.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 86a07adbb..1653a381e 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -523,7 +523,7 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { - int32_t i,nonz=0; uint64_t price,seed,sum = 0; + int32_t i,nonz=0; int64_t diff; uint64_t price,seed,sum = 0; portable_mutex_lock(&komodo_mutex); for (i=0; i<64; i++) { @@ -532,8 +532,8 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin sum += price; nonz++; } - if ( height < KOMODO_MAINNET_START ) - break; + //if ( height < KOMODO_MAINNET_START ) + // break; if ( i == 1 && nonz == 2 ) { diff = ((price - (sum >> 1)) * SATOSHIDEN) / price; From c9da2420936d803cc4cedc11d88f6979340b28e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 14:37:35 +0200 Subject: [PATCH 14/38] test --- src/komodo_pax.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 1653a381e..9c90a6649 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -456,9 +456,9 @@ int32_t komodo_kmdbtcusd(int32_t rwflag,uint64_t *kmdbtcp,uint64_t *btcusdp,int3 static uint64_t *KMDBTCS,*BTCUSDS; static int32_t maxheight; int32_t incr = 10000; if ( height >= maxheight ) { - KMDBTCS = realloc(KMDBTCS,((incr + maxheight) * sizeof(*KMDBTCS))); + KMDBTCS = (uint64_t *)realloc(KMDBTCS,((incr + maxheight) * sizeof(*KMDBTCS))); memset(&KMDBTCS[maxheight],0,(incr * sizeof(*KMDBTCS))); - BTCUSDS = realloc(BTCUSDS,((incr + maxheight) * sizeof(*BTCUSDS))); + BTCUSDS = (uint64_t *)realloc(BTCUSDS,((incr + maxheight) * sizeof(*BTCUSDS))); memset(&BTCUSDS[maxheight],0,(incr * sizeof(*BTCUSDS))); maxheight += incr; } @@ -493,7 +493,7 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui } numvotes = (int32_t)(sizeof(Peggy_inds)/sizeof(*Peggy_inds)); memset(votes,0,sizeof(votes)); - //if ( komodo_kmdbtcusd(0,&kmdbtc,&btcusd,height) < 0 ) + if ( komodo_kmdbtcusd(0,&kmdbtc,&btcusd,height) < 0 ) { memset(btcusds,0,sizeof(btcusds)); memset(kmdbtcs,0,sizeof(kmdbtcs)); @@ -504,7 +504,7 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui } kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,*seedp) * 539; btcusd = komodo_paxcorrelation(btcusds,numvotes,*seedp) * 539; - //komodo_kmdbtcusd(1,&kmdbtc,&btcusd,height); + komodo_kmdbtcusd(1,&kmdbtc,&btcusd,height); } for (i=nonz=0; i Date: Wed, 18 Jan 2017 14:43:23 +0200 Subject: [PATCH 15/38] test --- src/komodo_pax.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 9c90a6649..401de3019 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -453,9 +453,11 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha int32_t komodo_kmdbtcusd(int32_t rwflag,uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height) { - static uint64_t *KMDBTCS,*BTCUSDS; static int32_t maxheight; int32_t incr = 10000; + static uint64_t *KMDBTCS,*BTCUSDS; static int32_t maxheight = -1; int32_t incr = 10000; if ( height >= maxheight ) { + if ( height >= maxheight+incr ) + incr = (height - (maxheight+incr) + 1000); KMDBTCS = (uint64_t *)realloc(KMDBTCS,((incr + maxheight) * sizeof(*KMDBTCS))); memset(&KMDBTCS[maxheight],0,(incr * sizeof(*KMDBTCS))); BTCUSDS = (uint64_t *)realloc(BTCUSDS,((incr + maxheight) * sizeof(*BTCUSDS))); From f6f2beb9a527fdeaa7fb91087ea77f73476ab200 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 14:46:35 +0200 Subject: [PATCH 16/38] test --- src/komodo_pax.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 401de3019..3c1e0aee8 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -456,6 +456,7 @@ int32_t komodo_kmdbtcusd(int32_t rwflag,uint64_t *kmdbtcp,uint64_t *btcusdp,int3 static uint64_t *KMDBTCS,*BTCUSDS; static int32_t maxheight = -1; int32_t incr = 10000; if ( height >= maxheight ) { + printf("height.%d maxheight.%d incr.%d\n",height,maxheight,incr); if ( height >= maxheight+incr ) incr = (height - (maxheight+incr) + 1000); KMDBTCS = (uint64_t *)realloc(KMDBTCS,((incr + maxheight) * sizeof(*KMDBTCS))); From 703cc8c9bb351ac58f38985ffb9f97babb4e86d2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 14:48:03 +0200 Subject: [PATCH 17/38] test --- src/komodo_pax.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 3c1e0aee8..329d26e10 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -453,7 +453,7 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha int32_t komodo_kmdbtcusd(int32_t rwflag,uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height) { - static uint64_t *KMDBTCS,*BTCUSDS; static int32_t maxheight = -1; int32_t incr = 10000; + static uint64_t *KMDBTCS,*BTCUSDS; static int32_t maxheight = 0; int32_t incr = 10000; if ( height >= maxheight ) { printf("height.%d maxheight.%d incr.%d\n",height,maxheight,incr); From 86600f3bdf3e32a90aea5401c31a858ac312427e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 14:53:00 +0200 Subject: [PATCH 18/38] test --- src/komodo_pax.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 329d26e10..4a881d856 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -542,7 +542,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin diff = ((price - (sum >> 1)) * SATOSHIDEN) / price; if ( diff < 0 ) diff = -diff; - if ( diff < (SATOSHIDEN / 1000) ) + if ( diff < (SATOSHIDEN / 333) ) break; } } From 108542828359c8602c3b1536a74fa61296c67cb1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 14:54:25 +0200 Subject: [PATCH 19/38] test --- src/komodo_pax.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 4a881d856..e6452bc9c 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -527,6 +527,8 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t i,nonz=0; int64_t diff; uint64_t price,seed,sum = 0; + if ( height > chainActive.Tip()->nHeight ) + return(0); portable_mutex_lock(&komodo_mutex); for (i=0; i<64; i++) { From 5218a9c4392fa4987e082b09ec6340891d5d4f6d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 14:57:48 +0200 Subject: [PATCH 20/38] test --- src/komodo_pax.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index e6452bc9c..a07d17b0e 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -530,7 +530,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin if ( height > chainActive.Tip()->nHeight ) return(0); portable_mutex_lock(&komodo_mutex); - for (i=0; i<64; i++) + for (i=0; i<32; i++) { if ( (price= komodo_paxpriceB(&seed,height-i,base,rel,basevolume)) != 0 ) { @@ -544,13 +544,24 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin diff = ((price - (sum >> 1)) * SATOSHIDEN) / price; if ( diff < 0 ) diff = -diff; + printf("%lld ",(long long)diff); if ( diff < (SATOSHIDEN / 333) ) break; } + else if ( i == 3 && nonz == 4 ) + { + diff = ((price - (sum >> 2)) * SATOSHIDEN) / price; + if ( diff < 0 ) + diff = -diff; + printf("%lld ",(long long)diff); + if ( diff < (SATOSHIDEN / 500) ) + break; + } } portable_mutex_unlock(&komodo_mutex); if ( nonz != 0 ) sum /= nonz; + printf("-> %lld\n",(long long)sum); return(sum); } From 1f2ae07564b85cbfe6b455c04a41128294271207 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 15:01:38 +0200 Subject: [PATCH 21/38] test --- src/komodo_pax.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index a07d17b0e..352408cfd 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -527,7 +527,7 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t i,nonz=0; int64_t diff; uint64_t price,seed,sum = 0; - if ( height > chainActive.Tip()->nHeight ) + if ( chainActive.Tip() != 0 && height > chainActive.Tip()->nHeight ) return(0); portable_mutex_lock(&komodo_mutex); for (i=0; i<32; i++) From e8bd824b16d128fdf0c198a9b900cd5baf3aeae8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 15:06:25 +0200 Subject: [PATCH 22/38] test --- src/komodo_pax.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 352408cfd..070ef4eba 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -536,27 +536,27 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin { sum += price; nonz++; + if ( i == 1 && nonz == 2 ) + { + diff = ((price - (sum >> 1)) * SATOSHIDEN) / price; + if ( diff < 0 ) + diff = -diff; + if ( diff < (SATOSHIDEN / 333) ) + break; + else printf("(%llu %llu).%lld ",price,sum>>1,diff); + } + else if ( i == 3 && nonz == 4 ) + { + diff = ((price - (sum >> 2)) * SATOSHIDEN) / price; + if ( diff < 0 ) + diff = -diff; + if ( diff < (SATOSHIDEN / 500) ) + break; + else printf("(%llu %llu).%lld ",price,sum>>2,diff); + } } //if ( height < KOMODO_MAINNET_START ) // break; - if ( i == 1 && nonz == 2 ) - { - diff = ((price - (sum >> 1)) * SATOSHIDEN) / price; - if ( diff < 0 ) - diff = -diff; - printf("%lld ",(long long)diff); - if ( diff < (SATOSHIDEN / 333) ) - break; - } - else if ( i == 3 && nonz == 4 ) - { - diff = ((price - (sum >> 2)) * SATOSHIDEN) / price; - if ( diff < 0 ) - diff = -diff; - printf("%lld ",(long long)diff); - if ( diff < (SATOSHIDEN / 500) ) - break; - } } portable_mutex_unlock(&komodo_mutex); if ( nonz != 0 ) From 7bdc3386a77d221117bafa886a30c3043ad4a3f9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 15:08:03 +0200 Subject: [PATCH 23/38] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 070ef4eba..28f2497b3 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -543,7 +543,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin diff = -diff; if ( diff < (SATOSHIDEN / 333) ) break; - else printf("(%llu %llu).%lld ",price,sum>>1,diff); + else printf("(%llu %llu).%lld ",(long long)price,(long long)(sum>>1),(long long)diff); } else if ( i == 3 && nonz == 4 ) { @@ -552,7 +552,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin diff = -diff; if ( diff < (SATOSHIDEN / 500) ) break; - else printf("(%llu %llu).%lld ",price,sum>>2,diff); + else printf("(%llu %llu).%lld ",(long long)price,(long long)(sum>>2),(long long)diff); } } //if ( height < KOMODO_MAINNET_START ) From f63b4a4660c322fb3df14f64571ce184b2f4915c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 15:13:16 +0200 Subject: [PATCH 24/38] test --- src/komodo_pax.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 28f2497b3..f19b65817 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -538,19 +538,19 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin nonz++; if ( i == 1 && nonz == 2 ) { - diff = ((price - (sum >> 1)) * SATOSHIDEN) / price; + diff = ((price - (sum >> 1)) * 10000) / price; if ( diff < 0 ) diff = -diff; - if ( diff < (SATOSHIDEN / 333) ) + if ( diff < 50 ) break; else printf("(%llu %llu).%lld ",(long long)price,(long long)(sum>>1),(long long)diff); } else if ( i == 3 && nonz == 4 ) { - diff = ((price - (sum >> 2)) * SATOSHIDEN) / price; + diff = ((price - (sum >> 2)) * 10000) / price; if ( diff < 0 ) diff = -diff; - if ( diff < (SATOSHIDEN / 500) ) + if ( diff < 40 ) break; else printf("(%llu %llu).%lld ",(long long)price,(long long)(sum>>2),(long long)diff); } From d19f6c0e02793b781efd23f52654303908e1c6ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 15:18:56 +0200 Subject: [PATCH 25/38] test --- src/komodo_pax.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index f19b65817..60bf523cf 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -538,21 +538,21 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin nonz++; if ( i == 1 && nonz == 2 ) { - diff = ((price - (sum >> 1)) * 10000) / price; + diff = (((int64_t)price - (sum >> 1)) * 10000) / price; if ( diff < 0 ) diff = -diff; + printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>1),(long long)(((int64_t)price - (sum >> 1)) * 10000),(long long)diff); if ( diff < 50 ) break; - else printf("(%llu %llu).%lld ",(long long)price,(long long)(sum>>1),(long long)diff); } else if ( i == 3 && nonz == 4 ) { - diff = ((price - (sum >> 2)) * 10000) / price; + diff = (((int64_t)price - (sum >> 2)) * 10000) / price; if ( diff < 0 ) diff = -diff; + printf("(%llu %llu).%lld ",(long long)price,(long long)(sum>>2),(long long)diff); if ( diff < 40 ) break; - else printf("(%llu %llu).%lld ",(long long)price,(long long)(sum>>2),(long long)diff); } } //if ( height < KOMODO_MAINNET_START ) From 395fae6b5dbe216dea628248d0dfd0df8d597db3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 15:23:10 +0200 Subject: [PATCH 26/38] test --- src/komodo_pax.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 60bf523cf..ec7026fb6 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -538,19 +538,21 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin nonz++; if ( i == 1 && nonz == 2 ) { - diff = (((int64_t)price - (sum >> 1)) * 10000) / price; + diff = (((int64_t)price - (sum >> 1)) * 10000); if ( diff < 0 ) diff = -diff; + diff /= price; printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>1),(long long)(((int64_t)price - (sum >> 1)) * 10000),(long long)diff); if ( diff < 50 ) break; } else if ( i == 3 && nonz == 4 ) { - diff = (((int64_t)price - (sum >> 2)) * 10000) / price; + diff = (((int64_t)price - (sum >> 2)) * 10000); if ( diff < 0 ) diff = -diff; - printf("(%llu %llu).%lld ",(long long)price,(long long)(sum>>2),(long long)diff); + diff /= price; + printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>2),(long long) (((int64_t)price - (sum >> 2)) * 10000),(long long)diff); if ( diff < 40 ) break; } From e24bce329e860ed43f096c5c37ecae49ef859789 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 15:25:19 +0200 Subject: [PATCH 27/38] test --- src/komodo_pax.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index ec7026fb6..bc6108868 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -542,7 +542,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin if ( diff < 0 ) diff = -diff; diff /= price; - printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>1),(long long)(((int64_t)price - (sum >> 1)) * 10000),(long long)diff); + //printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>1),(long long)(((int64_t)price - (sum >> 1)) * 10000),(long long)diff); if ( diff < 50 ) break; } @@ -552,7 +552,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin if ( diff < 0 ) diff = -diff; diff /= price; - printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>2),(long long) (((int64_t)price - (sum >> 2)) * 10000),(long long)diff); + //printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>2),(long long) (((int64_t)price - (sum >> 2)) * 10000),(long long)diff); if ( diff < 40 ) break; } @@ -563,7 +563,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin portable_mutex_unlock(&komodo_mutex); if ( nonz != 0 ) sum /= nonz; - printf("-> %lld\n",(long long)sum); + //printf("-> %lld\n",(long long)sum); return(sum); } From f12b4a5989ff8236c106a1259c1535a13445e9ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 15:27:11 +0200 Subject: [PATCH 28/38] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index bc6108868..c6200d048 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -543,7 +543,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin diff = -diff; diff /= price; //printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>1),(long long)(((int64_t)price - (sum >> 1)) * 10000),(long long)diff); - if ( diff < 50 ) + if ( diff < 20 ) break; } else if ( i == 3 && nonz == 4 ) @@ -553,7 +553,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin diff = -diff; diff /= price; //printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>2),(long long) (((int64_t)price - (sum >> 2)) * 10000),(long long)diff); - if ( diff < 40 ) + if ( diff < 25 ) break; } } From d854fae228a28ea923e01ad33b4643601793464b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 15:30:52 +0200 Subject: [PATCH 29/38] test --- src/komodo_pax.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index c6200d048..722a99c57 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -456,7 +456,7 @@ int32_t komodo_kmdbtcusd(int32_t rwflag,uint64_t *kmdbtcp,uint64_t *btcusdp,int3 static uint64_t *KMDBTCS,*BTCUSDS; static int32_t maxheight = 0; int32_t incr = 10000; if ( height >= maxheight ) { - printf("height.%d maxheight.%d incr.%d\n",height,maxheight,incr); + //printf("height.%d maxheight.%d incr.%d\n",height,maxheight,incr); if ( height >= maxheight+incr ) incr = (height - (maxheight+incr) + 1000); KMDBTCS = (uint64_t *)realloc(KMDBTCS,((incr + maxheight) * sizeof(*KMDBTCS))); @@ -543,7 +543,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin diff = -diff; diff /= price; //printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>1),(long long)(((int64_t)price - (sum >> 1)) * 10000),(long long)diff); - if ( diff < 20 ) + if ( diff < 10 ) break; } else if ( i == 3 && nonz == 4 ) @@ -553,7 +553,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin diff = -diff; diff /= price; //printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>2),(long long) (((int64_t)price - (sum >> 2)) * 10000),(long long)diff); - if ( diff < 25 ) + if ( diff < 15 ) break; } } From 4f8c77e95cffc56f0e5bffda0a4dbbfad80b361d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 15:35:03 +0200 Subject: [PATCH 30/38] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 722a99c57..abd85d5f8 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -530,7 +530,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin if ( chainActive.Tip() != 0 && height > chainActive.Tip()->nHeight ) return(0); portable_mutex_lock(&komodo_mutex); - for (i=0; i<32; i++) + for (i=0; i<64; i++) { if ( (price= komodo_paxpriceB(&seed,height-i,base,rel,basevolume)) != 0 ) { @@ -553,7 +553,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin diff = -diff; diff /= price; //printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>2),(long long) (((int64_t)price - (sum >> 2)) * 10000),(long long)diff); - if ( diff < 15 ) + if ( diff < 9 ) break; } } From 6b9b9aca38103206b4cd5ba0335ff34eb5b84aa5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 15:41:13 +0200 Subject: [PATCH 31/38] test --- src/komodo_pax.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index abd85d5f8..f112bbd46 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -530,7 +530,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin if ( chainActive.Tip() != 0 && height > chainActive.Tip()->nHeight ) return(0); portable_mutex_lock(&komodo_mutex); - for (i=0; i<64; i++) + for (i=0; i<32; i++) { if ( (price= komodo_paxpriceB(&seed,height-i,base,rel,basevolume)) != 0 ) { @@ -542,8 +542,8 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin if ( diff < 0 ) diff = -diff; diff /= price; - //printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>1),(long long)(((int64_t)price - (sum >> 1)) * 10000),(long long)diff); - if ( diff < 10 ) + printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>1),(long long)(((int64_t)price - (sum >> 1)) * 10000),(long long)diff); + if ( diff < 33 ) break; } else if ( i == 3 && nonz == 4 ) @@ -552,8 +552,8 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin if ( diff < 0 ) diff = -diff; diff /= price; - //printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>2),(long long) (((int64_t)price - (sum >> 2)) * 10000),(long long)diff); - if ( diff < 9 ) + printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>2),(long long) (((int64_t)price - (sum >> 2)) * 10000),(long long)diff); + if ( diff < 20 ) break; } } From bebd2d5c80bb9beb742b17f489e85310c85c8fe5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 15:44:15 +0200 Subject: [PATCH 32/38] test --- src/komodo_pax.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index f112bbd46..dc0d2b804 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -563,7 +563,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin portable_mutex_unlock(&komodo_mutex); if ( nonz != 0 ) sum /= nonz; - //printf("-> %lld\n",(long long)sum); + printf("-> %lld %s/%s\n",(long long)sum,base,rel); return(sum); } From fd801c67b3d48d42943128785af3374c2406b192 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 15:48:49 +0200 Subject: [PATCH 33/38] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index dc0d2b804..f3d1f7262 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -536,7 +536,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin { sum += price; nonz++; - if ( i == 1 && nonz == 2 ) + if ( 0 && i == 1 && nonz == 2 ) { diff = (((int64_t)price - (sum >> 1)) * 10000); if ( diff < 0 ) @@ -563,7 +563,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin portable_mutex_unlock(&komodo_mutex); if ( nonz != 0 ) sum /= nonz; - printf("-> %lld %s/%s\n",(long long)sum,base,rel); + printf("-> %lld %s/%s i.%d\n",(long long)sum,base,rel,i); return(sum); } From 93139074297f24e6d8e5ecbcb244ea2c58111a6d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 15:53:47 +0200 Subject: [PATCH 34/38] test --- src/komodo_pax.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index f3d1f7262..625768082 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -530,7 +530,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin if ( chainActive.Tip() != 0 && height > chainActive.Tip()->nHeight ) return(0); portable_mutex_lock(&komodo_mutex); - for (i=0; i<32; i++) + for (i=0; i<17; i++) { if ( (price= komodo_paxpriceB(&seed,height-i,base,rel,basevolume)) != 0 ) { @@ -546,7 +546,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin if ( diff < 33 ) break; } - else if ( i == 3 && nonz == 4 ) + else if ( 0 && i == 3 && nonz == 4 ) { diff = (((int64_t)price - (sum >> 2)) * 10000); if ( diff < 0 ) @@ -563,7 +563,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin portable_mutex_unlock(&komodo_mutex); if ( nonz != 0 ) sum /= nonz; - printf("-> %lld %s/%s i.%d\n",(long long)sum,base,rel,i); + //printf("-> %lld %s/%s i.%d ht.%d\n",(long long)sum,base,rel,i,height); return(sum); } From e5c73f9a1c222cd48cf42d32ac5c43df41f74046 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Jan 2017 22:11:10 +0200 Subject: [PATCH 35/38] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 625768082..c12544cb0 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -496,7 +496,7 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui } numvotes = (int32_t)(sizeof(Peggy_inds)/sizeof(*Peggy_inds)); memset(votes,0,sizeof(votes)); - if ( komodo_kmdbtcusd(0,&kmdbtc,&btcusd,height) < 0 ) + //if ( komodo_kmdbtcusd(0,&kmdbtc,&btcusd,height) < 0 ) { memset(btcusds,0,sizeof(btcusds)); memset(kmdbtcs,0,sizeof(kmdbtcs)); @@ -507,7 +507,7 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui } kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,*seedp) * 539; btcusd = komodo_paxcorrelation(btcusds,numvotes,*seedp) * 539; - komodo_kmdbtcusd(1,&kmdbtc,&btcusd,height); + //komodo_kmdbtcusd(1,&kmdbtc,&btcusd,height); } for (i=nonz=0; i Date: Wed, 18 Jan 2017 22:16:30 +0200 Subject: [PATCH 36/38] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index c12544cb0..625768082 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -496,7 +496,7 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui } numvotes = (int32_t)(sizeof(Peggy_inds)/sizeof(*Peggy_inds)); memset(votes,0,sizeof(votes)); - //if ( komodo_kmdbtcusd(0,&kmdbtc,&btcusd,height) < 0 ) + if ( komodo_kmdbtcusd(0,&kmdbtc,&btcusd,height) < 0 ) { memset(btcusds,0,sizeof(btcusds)); memset(kmdbtcs,0,sizeof(kmdbtcs)); @@ -507,7 +507,7 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui } kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,*seedp) * 539; btcusd = komodo_paxcorrelation(btcusds,numvotes,*seedp) * 539; - //komodo_kmdbtcusd(1,&kmdbtc,&btcusd,height); + komodo_kmdbtcusd(1,&kmdbtc,&btcusd,height); } for (i=nonz=0; i Date: Wed, 18 Jan 2017 22:18:26 +0200 Subject: [PATCH 37/38] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 625768082..c12544cb0 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -496,7 +496,7 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui } numvotes = (int32_t)(sizeof(Peggy_inds)/sizeof(*Peggy_inds)); memset(votes,0,sizeof(votes)); - if ( komodo_kmdbtcusd(0,&kmdbtc,&btcusd,height) < 0 ) + //if ( komodo_kmdbtcusd(0,&kmdbtc,&btcusd,height) < 0 ) { memset(btcusds,0,sizeof(btcusds)); memset(kmdbtcs,0,sizeof(kmdbtcs)); @@ -507,7 +507,7 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui } kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,*seedp) * 539; btcusd = komodo_paxcorrelation(btcusds,numvotes,*seedp) * 539; - komodo_kmdbtcusd(1,&kmdbtc,&btcusd,height); + //komodo_kmdbtcusd(1,&kmdbtc,&btcusd,height); } for (i=nonz=0; i Date: Wed, 18 Jan 2017 23:26:17 +0200 Subject: [PATCH 38/38] test --- src/komodo_pax.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index c12544cb0..79f01aefe 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -496,7 +496,7 @@ uint64_t komodo_paxpriceB(uint64_t *seedp,int32_t height,char *base,char *rel,ui } numvotes = (int32_t)(sizeof(Peggy_inds)/sizeof(*Peggy_inds)); memset(votes,0,sizeof(votes)); - //if ( komodo_kmdbtcusd(0,&kmdbtc,&btcusd,height) < 0 ) + //if ( komodo_kmdbtcusd(0,&kmdbtc,&btcusd,height) < 0 ) crashes when via passthru GUI use { memset(btcusds,0,sizeof(btcusds)); memset(kmdbtcs,0,sizeof(kmdbtcs)); @@ -557,8 +557,8 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin break; } } - //if ( height < KOMODO_MAINNET_START ) - // break; + if ( height < 165000 ) + break; } portable_mutex_unlock(&komodo_mutex); if ( nonz != 0 )