Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beta update #9

Merged
merged 56 commits into from
Mar 16, 2017
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
1d474f8
Syntax
Mar 14, 2017
e157400
Test
Mar 14, 2017
dde5cc7
Test
Mar 14, 2017
52859ac
Test
Mar 15, 2017
9ee4367
Test
Mar 15, 2017
c10c5d1
Test
Mar 15, 2017
ad84148
Test
Mar 15, 2017
a9a0671
Test
Mar 15, 2017
8f9d472
Test
Mar 15, 2017
0349195
Test
Mar 15, 2017
7d935b7
Test
Mar 15, 2017
1dcfdab
Test
Mar 15, 2017
e9b84be
Merge pull request #268 from jl777/dev
jl777 Mar 15, 2017
1b3cd99
Test
Mar 15, 2017
396b9d1
Merge pull request #269 from jl777/dev
jl777 Mar 15, 2017
13b5818
Test
Mar 15, 2017
229f934
Merge pull request #270 from jl777/dev
jl777 Mar 15, 2017
dd14cff
Test
Mar 15, 2017
1049be8
Test
Mar 15, 2017
7b11fe5
Test
Mar 15, 2017
320a2e3
Test
Mar 15, 2017
d7da66b
Test
Mar 15, 2017
cb15e75
Test
Mar 15, 2017
07408ac
Test
Mar 15, 2017
7381536
Test
Mar 15, 2017
e60221f
Test
Mar 15, 2017
4797fad
Test
Mar 15, 2017
f766a0c
Test
Mar 15, 2017
71baa19
Test
Mar 15, 2017
8e21196
Test
Mar 15, 2017
66e9fad
Test
Mar 15, 2017
5b5af60
Test
Mar 15, 2017
6c14000
Test
Mar 15, 2017
0c3a7ab
Test
Mar 15, 2017
09905a3
Test
Mar 15, 2017
a4ce58c
Test
Mar 15, 2017
6dbeea7
Test
Mar 15, 2017
4350833
Test
Mar 15, 2017
23fe876
Test
Mar 15, 2017
fa3d890
Test
Mar 15, 2017
c7ac445
Test
Mar 15, 2017
be320c2
Test
Mar 15, 2017
6966ce4
Test
Mar 15, 2017
ffa1c33
Test
Mar 15, 2017
a592277
Test
Mar 15, 2017
770185e
Test
Mar 15, 2017
c9cb8ba
Test
Mar 15, 2017
480e3b4
Test
Mar 15, 2017
1d5d7a7
Test
Mar 15, 2017
392fbdd
Test
Mar 15, 2017
0d996b3
Test
Mar 15, 2017
61e3ca3
Test
Mar 15, 2017
bc859ce
Test
Mar 15, 2017
d4487f0
Test
Mar 15, 2017
5484ec2
Test
Mar 15, 2017
2533d8a
Merge pull request #273 from jl777/dev
jl777 Mar 16, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions src/komodo_pax.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ uint64_t komodo_paxcalc(int32_t height,uint32_t *pvals,int32_t baseid,int32_t re
//fprintf(stderr,"ht.%d kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",height,(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)));
//fprintf(stderr,"usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %llu %llu\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)),(long long)price);
//fprintf(stderr,"usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %llu\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)));
//price = (uint64_t)((long long)MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]));
} else price = (MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100));
return(price);
} //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd);
Expand Down Expand Up @@ -497,7 +496,7 @@ int32_t komodo_kmdbtcusd(int32_t rwflag,uint64_t *kmdbtcp,uint64_t *btcusdp,int3
else return(-1);
}

uint64_t komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume)
uint64_t _komodo_paxpriceB(uint64_t seed,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;
if ( basevolume > KOMODO_PAXMAX )
Expand Down Expand Up @@ -546,6 +545,38 @@ uint64_t komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint
return(komodo_paxcorrelation(votes,numvotes,seed) * basevolume / 100000);
}

uint64_t komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume)
{
uint64_t baseusd,basekmd,usdkmd; int32_t baseid = komodo_baseid(base);
if ( height >= 236000 && strcmp(rel,"kmd") == 0 )
{
usdkmd = _komodo_paxpriceB(seed,height,(char *)"USD",(char *)"KMD",SATOSHIDEN);
if ( strcmp("usd",base) == 0 )
return(komodo_paxvol(basevolume,usdkmd) * 10);
baseusd = _komodo_paxpriceB(seed,height,base,(char *)"USD",SATOSHIDEN);
basekmd = (komodo_paxvol(basevolume,baseusd) * usdkmd) / 10000000;
//if ( strcmp("KMD",base) == 0 )
// printf("baseusd.%llu usdkmd.%llu %llu\n",(long long)baseusd,(long long)usdkmd,(long long)basekmd);
return(basekmd);
} else return(_komodo_paxpriceB(seed,height,base,rel,basevolume));
}

/*uint64_t komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume)
{
uint64_t baseusd,basekmd,usdkmd; int32_t baseid = komodo_baseid(base);
//if ( strcmp(rel,"KMD") != 0 || baseid < 0 || MINDENOMS[baseid] == MINDENOMS[USD] )
// return(_komodo_paxpriceB(seed,height,base,rel,basevolume));
//else
{
baseusd = _komodo_paxpriceB(seed,height,base,(char *)"USD",SATOSHIDEN);
usdkmd = _komodo_paxpriceB(seed,height,(char *)"USD",(char *)"KMD",SATOSHIDEN);
basekmd = (komodo_paxvol(basevolume,baseusd) * usdkmd) / 10000000;
if ( strcmp("KMD",base) == 0 )
printf("baseusd.%llu usdkmd.%llu %llu\n",(long long)baseusd,(long long)usdkmd,(long long)basekmd);
return(basekmd);
}
}*/

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;
Expand Down
4 changes: 2 additions & 2 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams,

#define ASSETCHAINS_MINHEIGHT 100
#define KOMODO_ELECTION_GAP 2000
#define ROUNDROBIN_DELAY 58
#define ROUNDROBIN_DELAY 59
extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE;
extern char ASSETCHAINS_SYMBOL[16];
extern std::string NOTARY_PUBKEY;
Expand Down Expand Up @@ -728,7 +728,7 @@ void static BitcoinMiner(CWallet *pwallet)
int32_t nseconds = Mining_start+ROUNDROBIN_DELAY-time(NULL);
if ( nseconds > 0 )
sleep(nseconds);
MilliSleep((rand() % 700) + 1);
MilliSleep((rand() % 1700) + 1);
}
KOMODO_CHOSEN_ONE = 1;
// Found a solution
Expand Down