give this a go
This commit is contained in:
@@ -1105,25 +1105,33 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_
|
|||||||
commission must be in coinbase.vout[1] and must be >= 10000 sats
|
commission must be in coinbase.vout[1] and must be >= 10000 sats
|
||||||
PoS stake must be without txfee and in the last tx in the block at vout[0]
|
PoS stake must be without txfee and in the last tx in the block at vout[0]
|
||||||
*/
|
*/
|
||||||
|
extern int32_t ASSETCHAINS_STREAM;
|
||||||
|
|
||||||
uint64_t komodo_commission(const CBlock *pblock)
|
uint64_t komodo_commission(const CBlock *pblock)
|
||||||
{
|
{
|
||||||
int32_t i,j,n=0,txn_count; uint64_t commission,total = 0;
|
if ( ASSETCHAINS_STREAM == 0 )
|
||||||
txn_count = pblock->vtx.size();
|
|
||||||
for (i=0; i<txn_count; i++)
|
|
||||||
{
|
{
|
||||||
n = pblock->vtx[i].vout.size();
|
int32_t i,j,n=0,txn_count; uint64_t commission,total = 0;
|
||||||
for (j=0; j<n; j++)
|
txn_count = pblock->vtx.size();
|
||||||
{
|
for (i=0; i<txn_count; i++)
|
||||||
//fprintf(stderr,"(%d %.8f).%d ",i,dstr(block.vtx[i].vout[j].nValue),j);
|
{
|
||||||
if ( i != 0 || j != 1 )
|
n = pblock->vtx[i].vout.size();
|
||||||
total += pblock->vtx[i].vout[j].nValue;
|
for (j=0; j<n; j++)
|
||||||
}
|
{
|
||||||
|
//fprintf(stderr,"(%d %.8f).%d ",i,dstr(block.vtx[i].vout[j].nValue),j);
|
||||||
|
if ( i != 0 || j != 1 )
|
||||||
|
total += pblock->vtx[i].vout[j].nValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//fprintf(stderr,"txn.%d n.%d commission total %.8f -> %.8f\n",txn_count,n,dstr(total),dstr((total * ASSETCHAINS_COMMISSION) / COIN));
|
||||||
|
commission = ((total * ASSETCHAINS_COMMISSION) / COIN);
|
||||||
|
if ( commission < 10000 )
|
||||||
|
commission = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
commission = 10000;
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"txn.%d n.%d commission total %.8f -> %.8f\n",txn_count,n,dstr(total),dstr((total * ASSETCHAINS_COMMISSION) / COIN));
|
|
||||||
commission = ((total * ASSETCHAINS_COMMISSION) / COIN);
|
|
||||||
if ( commission < 10000 )
|
|
||||||
commission = 0;
|
|
||||||
return(commission);
|
return(commission);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ struct komodo_state KOMODO_STATES[34];
|
|||||||
#define _COINBASE_MATURITY 100
|
#define _COINBASE_MATURITY 100
|
||||||
int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
|
int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
|
||||||
|
|
||||||
int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1;
|
int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1;
|
||||||
int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1;
|
int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1;
|
||||||
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY;
|
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY;
|
||||||
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE;
|
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE;
|
||||||
|
|||||||
@@ -1561,6 +1561,7 @@ void komodo_args(char *argv0)
|
|||||||
ASSETCHAINS_DECAY = GetArg("-ac_decay",0);
|
ASSETCHAINS_DECAY = GetArg("-ac_decay",0);
|
||||||
ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0);
|
ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0);
|
||||||
ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey","");
|
ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey","");
|
||||||
|
ASSETCHAINS_STREAM = GetArg("-ac_stream",0);
|
||||||
if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 )
|
if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 )
|
||||||
ASSETCHAINS_STAKED = 100;
|
ASSETCHAINS_STAKED = 100;
|
||||||
if ( ASSETCHAINS_STAKED != 0 && ASSETCHAINS_PRIVATE != 0 )
|
if ( ASSETCHAINS_STAKED != 0 && ASSETCHAINS_PRIVATE != 0 )
|
||||||
@@ -1589,7 +1590,10 @@ void komodo_args(char *argv0)
|
|||||||
{
|
{
|
||||||
ASSETCHAINS_COMMISSION = 0;
|
ASSETCHAINS_COMMISSION = 0;
|
||||||
printf("ASSETCHAINS_COMMISSION needs an ASETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n");
|
printf("ASSETCHAINS_COMMISSION needs an ASETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n");
|
||||||
}
|
} else if ( ASSETCHAINS_STREAM != 0) {
|
||||||
|
ASSETCHAINS_STREAM = 0;
|
||||||
|
printf("ASSETCHAINS_STREAM needs ASSETCHAINS_OVERRIDE_PUBKEY! This parameter has been ignored! \n");
|
||||||
|
}
|
||||||
if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 )
|
if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"end.%llu blocks, reward %.8f halving.%llu blocks, decay.%llu perc %.4f%% ac_pub=[%02x...]\n",(long long)ASSETCHAINS_ENDSUBSIDY,dstr(ASSETCHAINS_REWARD),(long long)ASSETCHAINS_HALVING,(long long)ASSETCHAINS_DECAY,dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0]);
|
fprintf(stderr,"end.%llu blocks, reward %.8f halving.%llu blocks, decay.%llu perc %.4f%% ac_pub=[%02x...]\n",(long long)ASSETCHAINS_ENDSUBSIDY,dstr(ASSETCHAINS_REWARD),(long long)ASSETCHAINS_HALVING,(long long)ASSETCHAINS_DECAY,dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0]);
|
||||||
|
|||||||
16
src/main.cpp
16
src/main.cpp
@@ -1866,6 +1866,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW)
|
|||||||
//uint64_t komodo_moneysupply(int32_t height);
|
//uint64_t komodo_moneysupply(int32_t height);
|
||||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||||
extern uint32_t ASSETCHAINS_MAGIC;
|
extern uint32_t ASSETCHAINS_MAGIC;
|
||||||
|
extern int32_t ASSETCHAINS_STREAM;
|
||||||
extern uint64_t ASSETCHAINS_STAKED,ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY;
|
extern uint64_t ASSETCHAINS_STAKED,ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_LINEAR,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY;
|
||||||
extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE;
|
extern uint8_t ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE;
|
||||||
|
|
||||||
@@ -1895,7 +1896,7 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
|
|||||||
{
|
{
|
||||||
if ( ASSETCHAINS_REWARD == 0 )
|
if ( ASSETCHAINS_REWARD == 0 )
|
||||||
return(10000);
|
return(10000);
|
||||||
else if ( ASSETCHAINS_ENDSUBSIDY != 0 && nHeight >= ASSETCHAINS_ENDSUBSIDY )
|
else if ( ( ASSETCHAINS_ENDSUBSIDY != 0 && nHeight >= ASSETCHAINS_ENDSUBSIDY )|| ASSETCHAINS_STREAM != 0)
|
||||||
return(0);
|
return(0);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2961,6 +2962,19 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
if (!view.HaveJoinSplitRequirements(tx))
|
if (!view.HaveJoinSplitRequirements(tx))
|
||||||
return state.DoS(100, error("ConnectBlock(): JoinSplit requirements not met"),
|
return state.DoS(100, error("ConnectBlock(): JoinSplit requirements not met"),
|
||||||
REJECT_INVALID, "bad-txns-joinsplit-requirements-not-met");
|
REJECT_INVALID, "bad-txns-joinsplit-requirements-not-met");
|
||||||
|
|
||||||
|
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||||
|
{
|
||||||
|
if ( ASSETCHAINS_STREAM != 0 )
|
||||||
|
{
|
||||||
|
if ( block.vtx.size() == 1 && block.vtx[0].vout.size() == 2 && pindex->nHeight > ASSETCHAINS_MINHEIGHT)
|
||||||
|
{
|
||||||
|
return state.DoS(100, error("ConnectBlock(): There are no TX in this block, it is invalid!"),
|
||||||
|
REJECT_INVALID, "bad-block-no-transactions");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fAddressIndex || fSpentIndex)
|
if (fAddressIndex || fSpentIndex)
|
||||||
{
|
{
|
||||||
for (size_t j = 0; j < tx.vin.size(); j++) {
|
for (size_t j = 0; j < tx.vin.size(); j++) {
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams,
|
|||||||
|
|
||||||
#include "komodo_defs.h"
|
#include "komodo_defs.h"
|
||||||
|
|
||||||
extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE;
|
extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE;
|
||||||
extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED;
|
extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED;
|
||||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||||
extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY;
|
extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY;
|
||||||
@@ -428,7 +428,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount)
|
|||||||
txNew.vin[0].scriptSig = CScript() << nHeight << OP_0;
|
txNew.vin[0].scriptSig = CScript() << nHeight << OP_0;
|
||||||
|
|
||||||
pblock->vtx[0] = txNew;
|
pblock->vtx[0] = txNew;
|
||||||
if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block)) != 0 )
|
if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_STREAM != 0) && (commission= komodo_commission((CBlock*)&pblocktemplate->block)) != 0 )
|
||||||
{
|
{
|
||||||
int32_t i; uint8_t *ptr;
|
int32_t i; uint8_t *ptr;
|
||||||
txNew.vout.resize(2);
|
txNew.vout.resize(2);
|
||||||
@@ -606,7 +606,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&
|
|||||||
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,int32_t gpucount)
|
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,int32_t gpucount)
|
||||||
{
|
{
|
||||||
CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i;
|
CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i;
|
||||||
if ( nHeight == 1 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
|
if ( (nHeight == 1 || ASSETCHAINS_STREAM != 0 ) && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
|
||||||
{
|
{
|
||||||
scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG;
|
scriptPubKey = CScript() << ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY) << OP_CHECKSIG;
|
||||||
}
|
}
|
||||||
@@ -615,7 +615,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,in
|
|||||||
//fprintf(stderr,"use notary pubkey\n");
|
//fprintf(stderr,"use notary pubkey\n");
|
||||||
scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG;
|
scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (!reservekey.GetReservedKey(pubkey))
|
if (!reservekey.GetReservedKey(pubkey))
|
||||||
{
|
{
|
||||||
|
|||||||
48
src/pow.cpp
48
src/pow.cpp
@@ -20,31 +20,39 @@
|
|||||||
#include "librustzcash.h"
|
#include "librustzcash.h"
|
||||||
#endif // ENABLE_RUST
|
#endif // ENABLE_RUST
|
||||||
uint32_t komodo_chainactive_timestamp();
|
uint32_t komodo_chainactive_timestamp();
|
||||||
|
extern int32_t ASSETCHAINS_STREAM;
|
||||||
|
|
||||||
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
||||||
{
|
{
|
||||||
unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact();
|
if ( ASSETCHAINS_STREAM == 0)
|
||||||
// Genesis block
|
{
|
||||||
if (pindexLast == NULL )
|
unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact();
|
||||||
return nProofOfWorkLimit;
|
// Genesis block
|
||||||
|
if (pindexLast == NULL )
|
||||||
|
return nProofOfWorkLimit;
|
||||||
|
|
||||||
// Find the first block in the averaging interval
|
// Find the first block in the averaging interval
|
||||||
const CBlockIndex* pindexFirst = pindexLast;
|
const CBlockIndex* pindexFirst = pindexLast;
|
||||||
arith_uint256 bnTot {0};
|
arith_uint256 bnTot {0};
|
||||||
for (int i = 0; pindexFirst && i < params.nPowAveragingWindow; i++) {
|
for (int i = 0; pindexFirst && i < params.nPowAveragingWindow; i++) {
|
||||||
arith_uint256 bnTmp;
|
arith_uint256 bnTmp;
|
||||||
bnTmp.SetCompact(pindexFirst->nBits);
|
bnTmp.SetCompact(pindexFirst->nBits);
|
||||||
bnTot += bnTmp;
|
bnTot += bnTmp;
|
||||||
pindexFirst = pindexFirst->pprev;
|
pindexFirst = pindexFirst->pprev;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check we have enough blocks
|
||||||
|
if (pindexFirst == NULL)
|
||||||
|
return nProofOfWorkLimit;
|
||||||
|
|
||||||
|
arith_uint256 bnAvg {bnTot / params.nPowAveragingWindow};
|
||||||
|
|
||||||
|
return CalculateNextWorkRequired(bnAvg, pindexLast->GetMedianTimePast(), pindexFirst->GetMedianTimePast(), params);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 537857807;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check we have enough blocks
|
|
||||||
if (pindexFirst == NULL)
|
|
||||||
return nProofOfWorkLimit;
|
|
||||||
|
|
||||||
arith_uint256 bnAvg {bnTot / params.nPowAveragingWindow};
|
|
||||||
|
|
||||||
return CalculateNextWorkRequired(bnAvg, pindexLast->GetMedianTimePast(), pindexFirst->GetMedianTimePast(), params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg,
|
unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg,
|
||||||
|
|||||||
Reference in New Issue
Block a user