Merge pull request #420 from jl777/dev

new MESH
This commit is contained in:
jl777
2017-04-27 11:07:10 +03:00
committed by GitHub
5 changed files with 23 additions and 16 deletions

View File

@@ -19,7 +19,7 @@ echo $pubkey
./komodod -pubkey=$pubkey -ac_name=WLC -ac_supply=210000000 -addnode=148.251.190.89 $1 -gen &
./komodod -pubkey=$pubkey -ac_name=KV -ac_supply=1000000 -addnode=78.47.196.146 $1 -gen &
./komodod -pubkey=$pubkey -ac_name=CEAL -ac_supply=366666666 -addnode=78.47.196.146 $1 -gen &
./komodod -pubkey=$pubkey -ac_name=MESH -ac_supply=1000007 -addnode=78.47.196.146 $1 -gen &
./komodod -pubkey=$pubkey -ac_name=MESH -ac_supply=1000006 -addnode=78.47.196.146 $1 -gen &
sleep $delay
./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 &

View File

@@ -553,6 +553,7 @@ uint32_t komodo_txtime(uint256 hash)
void komodo_disconnect(CBlockIndex *pindex,CBlock& block)
{
char symbol[16],dest[16]; struct komodo_state *sp;
//fprintf(stderr,"disconnect ht.%d\n",pindex->nHeight);
komodo_init(pindex->nHeight);
if ( (sp= komodo_stateptr(symbol,dest)) != 0 )
{

View File

@@ -1565,7 +1565,7 @@ bool IsInitialBlockDownload()
if ( ASSETCHAINS_SYMBOL[0] == 0 )
state = ((chainActive.Height() < ptr->nHeight - 24*60) ||
ptr->GetBlockTime() < (GetTime() - chainParams.MaxTipAge()));
else state = (chainActive.Height() < ptr->nHeight - 3);
else state = (chainActive.Height() < ptr->nHeight - 10);
//fprintf(stderr,"state.%d ht.%d vs %d, t.%u %u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->nHeight,(int32_t)ptr->GetBlockTime(),(uint32_t)(GetTime() - chainParams.MaxTipAge()));
if (!state)
{
@@ -2231,6 +2231,7 @@ static int64_t nTimeTotal = 0;
bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck)
{
const CChainParams& chainparams = Params();
//fprintf(stderr,"connectblock ht.%d\n",(int32_t)pindex->nHeight);
AssertLockHeld(cs_main);
/*<<<<<<< HEA
// Check it again in case a previous version let a bad block in
@@ -2659,6 +2660,7 @@ bool static DisconnectTip(CValidationState &state) {
SyncWithWallets(tx, NULL);
}
// Update cached incremental witnesses
//fprintf(stderr,"chaintip false\n");
GetMainSignals().ChainTip(pindexDelete, &block, newTree, false);
return true;
}
@@ -2729,6 +2731,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
SyncWithWallets(tx, pblock);
}
// Update cached incremental witnesses
//fprintf(stderr,"chaintip true\n");
GetMainSignals().ChainTip(pindexNew, pblock, oldTree, true);
int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1;

View File

@@ -106,7 +106,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams,
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams);
}
#define ASSETCHAINS_MINHEIGHT 100
#define ASSETCHAINS_MINHEIGHT 128
#define KOMODO_ELECTION_GAP 2000
#define ROUNDROBIN_DELAY 61
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;
@@ -451,6 +451,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
return pblocktemplate.release();
}
/*
#ifdef ENABLE_WALLET
boost::optional<CScript> GetMinerScriptPubKey(CReserveKey& reservekey)
#else
@@ -477,7 +478,7 @@ boost::optional<CScript> GetMinerScriptPubKey()
return scriptPubKey;
}
/*#ifdef ENABLE_WALLET
#ifdef ENABLE_WALLET
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
{
boost::optional<CScript> scriptPubKey = GetMinerScriptPubKey(reservekey);
@@ -596,6 +597,7 @@ static bool ProcessBlockFound(CBlock* pblock)
}
}
// Track how many getdata requests this block gets
//if ( 0 )
{
LOCK(wallet.cs_wallet);
wallet.mapRequestCount[pblock->GetHash()] = 0;
@@ -640,12 +642,13 @@ void static BitcoinMiner()
unsigned int n = chainparams.EquihashN();
unsigned int k = chainparams.EquihashK();
int32_t notaryid = -1;
while ( (ASSETCHAIN_INIT == 0 || KOMODO_INITDONE == 0) ) //chainActive.Tip()->nHeight != 235300 &&
while ( (ASSETCHAIN_INIT == 0 || KOMODO_INITDONE == 0) ) //chainActive.Tip()->nHeight != 235300 &&
{
sleep(1);
if ( komodo_baseid(ASSETCHAINS_SYMBOL) < 0 )
break;
}
//sleep(60);
komodo_chosennotary(&notaryid,chainActive.Tip()->nHeight,NOTARY_PUBKEY33);
std::string solver;

View File

@@ -38,6 +38,7 @@ bool bSpendZeroConfChange = true;
bool fSendFreeTransactions = false;
bool fPayAtLeastCustomFee = true;
extern int32_t KOMODO_EXCHANGEWALLET;
extern char ASSETCHAINS_SYMBOL[16];
/**
* Fees smaller than this (in satoshi) are considered zero fee (for transaction creation)
@@ -373,9 +374,9 @@ void CWallet::ChainTip(const CBlockIndex *pindex, const CBlock *pblock,
{
if (added) {
IncrementNoteWitnesses(pindex, pblock, tree);
} else {
} else if ( ASSETCHAINS_SYMBOL[0] == 0 || nWitnessCacheSize > 1 ){
DecrementNoteWitnesses(pindex);
}
} else fprintf(stderr,"would have decremented %s nWitnessCacheSize.%d\n",ASSETCHAINS_SYMBOL,(int32_t)nWitnessCacheSize);
}
void CWallet::SetBestChain(const CBlockLocator& loc)
@@ -642,6 +643,7 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex,
const CBlock* pblockIn,
ZCIncrementalMerkleTree& tree)
{
//fprintf(stderr,"A increment witness cache -> %d\n",(int32_t)nWitnessCacheSize);
{
LOCK(cs_wallet);
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
@@ -670,7 +672,7 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex,
}
}
if (nWitnessCacheSize < WITNESS_CACHE_SIZE) {
//fprintf(stderr,"increment nWitnesscache -> %d\n",(int32_t)nWitnessCacheSize);
fprintf(stderr,"increment nWitnesscache -> %d\n",(int32_t)nWitnessCacheSize);
nWitnessCacheSize += 1;
}
@@ -785,7 +787,12 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex)
}
}
//fprintf(stderr,"decrement witness cache -> %d\n",(int32_t)nWitnessCacheSize);
nWitnessCacheSize -= 1;
if ( nWitnessCacheSize > 1 )
nWitnessCacheSize -= 1;
else
{
fprintf(stderr,"%s nWitnessCacheSize.%d\n",ASSETCHAINS_SYMBOL,(int32_t)nWitnessCacheSize);
}
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) {
CNoteData* nd = &(item.second);
@@ -804,11 +811,6 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex)
}
}
}
if ( nWitnessCacheSize <= 0 )
{
extern char ASSETCHAINS_SYMBOL[16];
fprintf(stderr,"%s nWitnessCacheSize.%d\n",ASSETCHAINS_SYMBOL,(int32_t)nWitnessCacheSize);
}
if ( KOMODO_REWIND == 0 )
assert(nWitnessCacheSize > 0);
//if (fFileBacked) {
@@ -2240,7 +2242,6 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
{
if ( KOMODO_EXCHANGEWALLET == 0 )
{
extern char ASSETCHAINS_SYMBOL[16];
uint32_t locktime; int32_t txheight; CBlockIndex *tipindex;
if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.Tip() != 0 && chainActive.Tip()->nHeight >= 60000 )
{
@@ -3725,7 +3726,6 @@ int CMerkleTx::GetDepthInMainChain(const CBlockIndex* &pindexRet) const
int CMerkleTx::GetBlocksToMaturity() const
{
extern char ASSETCHAINS_SYMBOL[];
if ( ASSETCHAINS_SYMBOL[0] == 0 )
COINBASE_MATURITY = _COINBASE_MATURITY;
if (!IsCoinBase())