Skip to content

Commit

Permalink
Merge pull request #340 from jl777/beta
Browse files Browse the repository at this point in the history
Beta
  • Loading branch information
jl777 authored Mar 22, 2017
2 parents fcb8fc1 + 373f2e0 commit 61dd95a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 29 deletions.
64 changes: 36 additions & 28 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,18 +706,48 @@ bool IsStandardTx(const CTransaction& tx, string& reason)
return true;
}

int32_t komodo_validate_interest(const CTransaction& tx)
{
int32_t i,txheight=0; uint32_t prevblocktime=0,locktime; uint64_t value=0;
if ( ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD )
{
locktime = komodo_interest_args(&txheight,&prevblocktime,&value,tx.GetHash(),0);
if ( prevblocktime == 0 )
{
static uint32_t counter0;
prevblocktime = chainActive.Tip()->nTime;
if ( counter0++ < 100 )
fprintf(stderr,"error getting prevblocktime, set to tiptime.%u\n",prevblocktime);
}
if ( (int64_t)tx.nLockTime < prevblocktime-3600 )
{
if ( prevblocktime > 1490159171 || (txheight == 0 && prevblocktime >= 1490159171) ) // 246748
{
static uint32_t counter;
if ( counter++ < 100 )
fprintf(stderr,"komodo_validate_interest reject.%d locktime %u/%u vs nBlockTime %u prevblocktime.%u\n",txheight,(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,prevblocktime);
return(-1);
} else fprintf(stderr,"validateinterest grandfather.%d locktime %u vs nBlockTime %u\n",(int32_t)txheight,tx.nLockTime,(uint32_t)prevblocktime);
}
}
return(0);
}

bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime,int flags)
{
int32_t i;
if (tx.nLockTime == 0)
return true;
if ( ASSETCHAINS_SYMBOL[0] == 0 && flags == STANDARD_LOCKTIME_VERIFY_FLAGS && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD && (int64_t)tx.nLockTime < nBlockTime-3600 )
if ( ASSETCHAINS_SYMBOL[0] == 0 && flags == STANDARD_LOCKTIME_VERIFY_FLAGS && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD )//&& (int64_t)tx.nLockTime < nBlockTime-3600 )
{
if ( komodo_validate_interest(tx) < 0 )
return(false);
/*
if ( nBlockTime >= 1490159171 ) // 246748
{
fprintf(stderr,"[%d] IsFinalTx reject.%d locktime %u vs nBlockTime %u\n",(int32_t)(tx.nLockTime-nBlockTime),(int32_t)nBlockHeight,tx.nLockTime,(uint32_t)nBlockTime);
return(false); // need to prevent pastdating tx
} else fprintf(stderr,"IsFinalTx grandfather.%d locktime %u vs nBlockTime %u\n",(int32_t)nBlockHeight,tx.nLockTime,(uint32_t)nBlockTime);
} else fprintf(stderr,"IsFinalTx grandfather.%d locktime %u vs nBlockTime %u\n",(int32_t)nBlockHeight,tx.nLockTime,(uint32_t)nBlockTime);*/
}
if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime))
return true;
Expand Down Expand Up @@ -864,35 +894,13 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in
return nSigOps;
}

int32_t komodo_validate_interest(const CTransaction& tx)
{
int32_t i,txheight=0; uint32_t tiptime=0,locktime; uint64_t value=0;
if ( ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD )
{
locktime = komodo_interest_args(&txheight,&tiptime,&value,tx.GetHash(),0);
if ( tiptime == 0 )
tiptime = chainActive.Tip()->nTime;
if ( (int64_t)tx.nLockTime < tiptime-3600 )
{
if ( tiptime > 1490159171 || (txheight == 0 && tiptime >= 1490159171) ) // 246748
{
static uint32_t counter;
if ( counter++ < 100 )
fprintf(stderr,"komodo_validate_interest reject.%d locktime %u/%u vs nBlockTime %u tiptime.%u\n",txheight,(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,tiptime);
return(-1);
}
}
}
return(0);
}

bool CheckTransaction(const CTransaction& tx, CValidationState &state,libzcash::ProofVerifier& verifier)
{
static uint256 array[15]; int32_t j,k,n;
if ( *(int32_t *)&array[0] == 0 )
komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array)));
if ( komodo_validate_interest(tx) < 0 )
return(false);
//if ( komodo_validate_interest(tx) < 0 )
// return(false);
n = tx.vin.size();
for (j=0; j<n; j++)
{
Expand Down Expand Up @@ -1152,7 +1160,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
// be mined yet.
if (!CheckFinalTx(tx, STANDARD_LOCKTIME_VERIFY_FLAGS))
{
fprintf(stderr,"AcceptToMemoryPool non-final\n");
fprintf(stderr,"AcceptToMemoryPool reject non-final\n");
return state.DoS(0, false, REJECT_NONSTANDARD, "non-final");
}
// is it already in the memory pool?
Expand Down Expand Up @@ -3308,7 +3316,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST)
? pindexPrev->GetMedianTimePast()
: block.GetBlockTime();
if (!IsFinalTx(tx, nHeight, nLockTimeCutoff,0)) {
if (!IsFinalTx(tx, nHeight, nLockTimeCutoff,STANDARD_LOCKTIME_VERIFY_FLAGS)) {
return state.DoS(10, error("%s: contains a non-final transaction", __func__), REJECT_INVALID, "bad-txns-nonfinal");
}
}
Expand Down
2 changes: 1 addition & 1 deletion 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 59
#define ROUNDROBIN_DELAY 60
extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE;
extern char ASSETCHAINS_SYMBOL[16];
extern std::string NOTARY_PUBKEY;
Expand Down

0 comments on commit 61dd95a

Please sign in to comment.