Merge pull request #1683 from jl777/FSM

FSM
This commit is contained in:
jl777
2019-08-12 00:15:43 -11:00
committed by GitHub
3 changed files with 14 additions and 9 deletions

View File

@@ -423,7 +423,7 @@ int32_t NSPV_gettxproof(struct NSPV_txproof *ptr,int32_t vout,uint256 txid,int32
else else
{ {
ptr->height = height; ptr->height = height;
if ((pindex= komodo_chainactive(height)) != 0 && komodo_blockload(block,pindex) == 0 ) if ( (pindex= komodo_chainactive(height)) != 0 && komodo_blockload(block,pindex) == 0 )
{ {
BOOST_FOREACH(const CTransaction&tx, block.vtx) BOOST_FOREACH(const CTransaction&tx, block.vtx)
{ {
@@ -576,7 +576,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
else else
{ {
isCC = (request[len-9] != 0); isCC = (request[len-9] != 0);
iguana_rwnum(0,&request[len-4],sizeof(skipcount),&skipcount); iguana_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount);
iguana_rwnum(0,&request[len-4],sizeof(filter),&filter); iguana_rwnum(0,&request[len-4],sizeof(filter),&filter);
} }
if ( isCC != 0 ) if ( isCC != 0 )
@@ -616,7 +616,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
else else
{ {
isCC = (request[len-9] != 0); isCC = (request[len-9] != 0);
iguana_rwnum(0,&request[len-4],sizeof(skipcount),&skipcount); iguana_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount);
iguana_rwnum(0,&request[len-4],sizeof(filter),&filter); iguana_rwnum(0,&request[len-4],sizeof(filter),&filter);
} }
//if ( isCC != 0 ) //if ( isCC != 0 )

View File

@@ -7503,7 +7503,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
} }
else if (strCommand == "getnSPV") else if (strCommand == "getnSPV")
{ {
if ( KOMODO_NSPV == 0 && KOMODO_INSYNC != 0 ) if ( KOMODO_NSPV == 0 )//&& KOMODO_INSYNC != 0 )
{ {
std::vector<uint8_t> payload; std::vector<uint8_t> payload;
vRecv >> payload; vRecv >> payload;

View File

@@ -167,8 +167,11 @@ arith_uint256 oldRT_CST_RST(int32_t height,uint32_t nTime,arith_uint256 bnTarget
arith_uint256 RT_CST_RST_outer(int32_t height,uint32_t nTime,arith_uint256 bnTarget,uint32_t *ts,arith_uint256 *ct,int32_t numerator,int32_t denominator,int32_t W,int32_t past) arith_uint256 RT_CST_RST_outer(int32_t height,uint32_t nTime,arith_uint256 bnTarget,uint32_t *ts,arith_uint256 *ct,int32_t numerator,int32_t denominator,int32_t W,int32_t past)
{ {
int64_t outerK; arith_uint256 mintarget = bnTarget / arith_uint256(2); int64_t outerK; int32_t cmpval; arith_uint256 mintarget = bnTarget / arith_uint256(2);
if ( (ts[0] - ts[W]) < (T * numerator)/denominator ) cmpval = (T * numerator)/denominator;
if ( cmpval < 2 )
cmpval = 2;
if ( (ts[0] - ts[W]) < cmpval )
{ {
outerK = (K * (nTime-ts[0]) * (ts[0]-ts[W]) * denominator) / (numerator * (T * T)); outerK = (K * (nTime-ts[0]) * (ts[0]-ts[W]) * denominator) / (numerator * (T * T));
if ( outerK < K ) if ( outerK < K )
@@ -209,13 +212,14 @@ arith_uint256 RT_CST_RST_target(int32_t height,uint32_t nTime,arith_uint256 bnTa
arith_uint256 RT_CST_RST_inner(int32_t height,uint32_t nTime,arith_uint256 bnTarget,uint32_t *ts,arith_uint256 *ct,int32_t W,int32_t outeri) arith_uint256 RT_CST_RST_inner(int32_t height,uint32_t nTime,arith_uint256 bnTarget,uint32_t *ts,arith_uint256 *ct,int32_t W,int32_t outeri)
{ {
arith_uint256 mintarget; int32_t expected,elapsed,width = outeri+W; int32_t expected,elapsed,width = outeri+W; arith_uint256 mintarget,origtarget;
expected = (width+1) * T; expected = (width+1) * T;
origtarget = bnTarget;
if ( (elapsed= (ts[0] - ts[width])) < expected ) if ( (elapsed= (ts[0] - ts[width])) < expected )
{ {
mintarget = (bnTarget / arith_uint256(11)) * arith_uint256(10); mintarget = (bnTarget / arith_uint256(101)) * arith_uint256(100);
bnTarget = RT_CST_RST_target(height,nTime,bnTarget,ts,ct,W); bnTarget = RT_CST_RST_target(height,nTime,bnTarget,ts,ct,W);
if ( bnTarget > mintarget ) // force zawyflag to 1 if ( bnTarget == origtarget ) // force zawyflag to 1
bnTarget = mintarget; bnTarget = mintarget;
{ {
int32_t z; int32_t z;
@@ -397,6 +401,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
origtarget = bnTarget; origtarget = bnTarget;
if ( zflags[0] == 0 || zflags[0] == 3 ) if ( zflags[0] == 0 || zflags[0] == 3 )
{ {
// 15 51 102 162 230 303 380 460 543 627 714 803 892 983 1075 These are the 0.5% per blk numerator constants for W=2 to 16 if denominator is 100. - zawy
if ( ASSETCHAINS_BLOCKTIME >= 60 && ASSETCHAINS_BLOCKTIME < 100 ) if ( ASSETCHAINS_BLOCKTIME >= 60 && ASSETCHAINS_BLOCKTIME < 100 )
bnTarget = RT_CST_RST_outer(height,pblock->nTime,bnTarget,ts,ct,1,60,1,10); bnTarget = RT_CST_RST_outer(height,pblock->nTime,bnTarget,ts,ct,1,60,1,10);
else if ( ASSETCHAINS_BLOCKTIME >= 100 ) else if ( ASSETCHAINS_BLOCKTIME >= 100 )