From b927fb353541d233455356e8bcaca54be1b438c9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 22 Oct 2016 10:37:11 -0300 Subject: [PATCH] test --- src/komodo.h | 26 ++++++++++++++++++++++++-- src/komodo_interest.h | 27 +++------------------------ 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index c8104efaa..8656d6e6d 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -21,7 +21,6 @@ #include #include "uthash.h" -#define KOMODO_INTEREST ((uint64_t)0.05 * COIN) #include "komodo_interest.h" #define KOMODO_TESTNET_EXPIRATION 60000 @@ -244,11 +243,34 @@ int32_t komodo_threshold(int32_t height,uint64_t signedmask) for (i=0; i (numnotaries >> 1) || (wt > numnotaries/5 && (signedmask & 3) != 0) ) + if ( wt > (numnotaries >> 1) || (wt > 7 && (signedmask & 3) != 0) ) return(1); // N/2+1 || N/3 + devsig else return(0); } +uint32_t komodo_txtime(uint256 hash) +{ + CTransaction tx; + uint256 hashBlock; + if (!GetTransaction(hash, tx, hashBlock, true)) + { + //printf("null GetTransaction\n"); + return(tx.nLockTime); + } + /*if (!hashBlock.IsNull()) { + BlockMap::iterator mi = mapBlockIndex.find(hashBlock); + if (mi != mapBlockIndex.end() && (*mi).second) + { + CBlockIndex* pindex = (*mi).second; + if (chainActive.Contains(pindex)) + return(pindex->GetBlockTime()); + } + //printf("cant find in iterator\n"); + }*/ + //printf("null hashBlock\n"); + return(0); +} + void komodo_nutxoadd(int32_t addflag,int32_t height,int32_t notaryid,uint256 txhash,uint64_t voutmask,int32_t numvouts) { struct nutxo_entry *np; diff --git a/src/komodo_interest.h b/src/komodo_interest.h index f95540274..83d238b39 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -1,31 +1,10 @@ -uint32_t komodo_txtime(uint256 hash) -{ - CTransaction tx; - uint256 hashBlock; - if (!GetTransaction(hash, tx, hashBlock, true)) - { - //printf("null GetTransaction\n"); - return(tx.nLockTime); - } - /*if (!hashBlock.IsNull()) { - BlockMap::iterator mi = mapBlockIndex.find(hashBlock); - if (mi != mapBlockIndex.end() && (*mi).second) - { - CBlockIndex* pindex = (*mi).second; - if (chainActive.Contains(pindex)) - return(pindex->GetBlockTime()); - } - //printf("cant find in iterator\n"); - }*/ - //printf("null hashBlock\n"); - return(0); -} + + +#define KOMODO_INTEREST ((uint64_t)0.05 * COIN) uint64_t komodo_interest(uint64_t nValue,uint32_t nLockTime,uint32_t tiptime) { int32_t minutes; uint64_t interest = 0; - if ( tiptime == 0 ) - tiptime = chainActive.Tip()->nTime; if ( nLockTime >= LOCKTIME_THRESHOLD && tiptime != 0 && nLockTime < tiptime && nValue >= COIN ) { minutes = (tiptime - nLockTime) / 60;