Browse Source

KOMODO_EARLYTXID_HEIGHT

warmup
jl777 5 years ago
parent
commit
c267dcb282
  1. 2
      src/bitcoind.cpp
  2. 2
      src/cc/faucet.cpp
  3. 4
      src/cc/hempcoin_notes.txt
  4. 10
      src/komodo_bitcoind.h
  5. 2
      src/komodo_defs.h
  6. 2
      src/komodo_utils.h
  7. 2
      src/miner.cpp

2
src/bitcoind.cpp

@ -72,7 +72,7 @@ void WaitForShutdown(boost::thread_group* threadGroup)
// Tell the main threads to shutdown.
if (komodo_currentheight()>KOMODO_EARLYTXID_HEIGHT && KOMODO_EARLYTXID!=zeroid && ((height=tx_height(KOMODO_EARLYTXID))==0 || height>KOMODO_EARLYTXID_HEIGHT))
{
fprintf(stderr,"error: earlytx must be before block height 100 or tx does not exist\n");
fprintf(stderr,"error: earlytx must be before block height %d or tx does not exist\n",KOMODO_EARLYTXID_HEIGHT);
StartShutdown();
}
if ( ASSETCHAINS_CBOPRET != 0 )

2
src/cc/faucet.cpp

@ -159,7 +159,7 @@ int64_t AddFaucetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub
continue;
//char str[65]; fprintf(stderr,"check %s/v%d %.8f`\n",uint256_str(str,txid),vout,(double)it->second.satoshis/COIN);
// no need to prevent dup
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 )
if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{
if ( (nValue= IsFaucetvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 )
{

4
src/cc/hempcoin_notes.txt

@ -1,6 +1,6 @@
How this works:
- earlytxid must be a transaction included in the chain before block 100. The chain MUST not have any other of these type of tx before block 100, or someone may be able to change it and mess things up.
- When it gets to block 100, it takes the txid specified by the -earlytxid param (does not affect magic)
- earlytxid must be a transaction included in the chain before block KOMODO_EARLYTXID_HEIGHT. The chain MUST not have any other of these type of tx before block KOMODO_EARLYTXID_HEIGHT, or someone may be able to change it and mess things up.
- When it gets to block KOMODO_EARLYTXID_HEIGHT, it takes the txid specified by the -earlytxid param (does not affect magic)
- Looks up the transaction searches for the opreturn, then permenantly appends it to the end of ac_script in RAM.
- After every daemon restart, the first time the daemon mines a block, or receives a block that pays ac_script it will look up the op_return and save it again.
- this enables it to always reach consensus but doesnt need to constantly keep looking up the tx in the chain.

10
src/komodo_bitcoind.h

@ -2072,7 +2072,7 @@ bool komodo_appendACscriptpub()
{
CTransaction tx; uint256 blockhash;
// get transaction and check that it occured before height 100.
if ( myGetTransaction(KOMODO_EARLYTXID,tx,blockhash) && mapBlockIndex[blockhash]->GetHeight() < 100 )
if ( myGetTransaction(KOMODO_EARLYTXID,tx,blockhash) && mapBlockIndex[blockhash]->GetHeight() < KOMODO_EARLYTXID_HEIGHT )
{
for (int i = 0; i < tx.vout.size(); i++)
{
@ -2107,15 +2107,15 @@ void GetKomodoEarlytxidScriptPub()
StartShutdown();
return;
}
if ( chainActive.Height() < 100 )
if ( chainActive.Height() < KOMODO_EARLYTXID_HEIGHT )
{
fprintf(stderr, "Cannot fetch -earlytxid before block 100.\n");
fprintf(stderr, "Cannot fetch -earlytxid before block %d.\n",KOMODO_EARLYTXID_HEIGHT);
StartShutdown();
return;
}
CTransaction tx; uint256 blockhash; int32_t i;
// get transaction and check that it occured before height 100.
if ( myGetTransaction(KOMODO_EARLYTXID,tx,blockhash) && mapBlockIndex[blockhash]->GetHeight() < 100 )
if ( myGetTransaction(KOMODO_EARLYTXID,tx,blockhash) && mapBlockIndex[blockhash]->GetHeight() < KOMODO_EARLYTXID_HEIGHT )
{
for (i = 0; i < tx.vout.size(); i++)
if ( tx.vout[i].scriptPubKey[0] == OP_RETURN )
@ -2156,7 +2156,7 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height)
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
{
static bool didinit = false;
if ( !didinit && height > 100 && KOMODO_EARLYTXID != zeroid && komodo_appendACscriptpub() )
if ( !didinit && height > KOMODO_EARLYTXID_HEIGHT && KOMODO_EARLYTXID != zeroid && komodo_appendACscriptpub() )
{
fprintf(stderr, "appended CC_op_return to ASSETCHAINS_SCRIPTPUB.%s\n", ASSETCHAINS_SCRIPTPUB.c_str());
didinit = true;

2
src/komodo_defs.h

@ -17,7 +17,7 @@
#define KOMODO_DEFS_H
#include "komodo_nk.h"
#define KOMODO_EARLYTXID_HEIGHT 200
#define KOMODO_EARLYTXID_HEIGHT 100
#define ASSETCHAINS_MINHEIGHT 128
#define ASSETCHAINS_MAX_ERAS 7
#define KOMODO_ELECTION_GAP 2000

2
src/komodo_utils.h

@ -2387,7 +2387,7 @@ void komodo_args(char *argv0)
if ( strcmp("ILN",ASSETCHAINS_SYMBOL) == 0 )
{
// No CCs used on this chain yet.
// CCDISABLEALL;
CCDISABLEALL;
}
if ( strcmp("OUR",ASSETCHAINS_SYMBOL) == 0 )
{

2
src/miner.cpp

@ -665,7 +665,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
{
static bool didinit = false;
if ( !didinit && nHeight > 100 && KOMODO_EARLYTXID != zeroid && komodo_appendACscriptpub() )
if ( !didinit && nHeight > KOMODO_EARLYTXID_HEIGHT && KOMODO_EARLYTXID != zeroid && komodo_appendACscriptpub() )
{
fprintf(stderr, "appended ccopreturn to ASSETCHAINS_SCRIPTPUB.%s\n", ASSETCHAINS_SCRIPTPUB.c_str());
didinit = true;

Loading…
Cancel
Save