Merge pull request #694 from jl777/jl777
make notarizations complete by preventing skipping old ones
This commit is contained in:
@@ -694,7 +694,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
|||||||
}
|
}
|
||||||
else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 )
|
else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 )
|
||||||
komodo_rwccdata((char *)"KMD",1,&ccdata,0);
|
komodo_rwccdata((char *)"KMD",1,&ccdata,0);
|
||||||
if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height )
|
if ( matched != 0 )//&& *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height )
|
||||||
{
|
{
|
||||||
sp->NOTARIZED_HEIGHT = *notarizedheightp;
|
sp->NOTARIZED_HEIGHT = *notarizedheightp;
|
||||||
sp->NOTARIZED_HASH = srchash;
|
sp->NOTARIZED_HASH = srchash;
|
||||||
|
|||||||
@@ -585,6 +585,15 @@ CBlockTreeDB *pblocktree = NULL;
|
|||||||
#define KOMODO_ZCASH
|
#define KOMODO_ZCASH
|
||||||
#include "komodo.h"
|
#include "komodo.h"
|
||||||
|
|
||||||
|
int64_t komodo_snapshot()
|
||||||
|
{
|
||||||
|
int64_t total = -1;
|
||||||
|
if ( pblocktree != 0 )
|
||||||
|
total = pblocktree->Snapshot();
|
||||||
|
else fprintf(stderr,"null pblocktree start with -addressindex=true\n");
|
||||||
|
return(total);
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// mapOrphanTransactions
|
// mapOrphanTransactions
|
||||||
|
|||||||
@@ -109,9 +109,11 @@ extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOS
|
|||||||
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;
|
||||||
|
void vcalc_sha256(char deprecated[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uint8_t *src,int32_t len);
|
||||||
|
|
||||||
extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33];
|
extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33];
|
||||||
uint32_t Mining_start,Mining_height;
|
uint32_t Mining_start,Mining_height;
|
||||||
|
int32_t My_notaryid = -1;
|
||||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||||
int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize);
|
int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize);
|
||||||
//uint64_t komodo_paxtotal();
|
//uint64_t komodo_paxtotal();
|
||||||
@@ -472,13 +474,22 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount)
|
|||||||
}
|
}
|
||||||
pblock->nSolution.clear();
|
pblock->nSolution.clear();
|
||||||
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]);
|
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]);
|
||||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 )
|
if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 && My_notaryid >= 0 )
|
||||||
{
|
{
|
||||||
|
uint32_t r;
|
||||||
CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1);
|
CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1);
|
||||||
if ( pblock->nTime < pindexPrev->nTime+60 )
|
if ( pblock->nTime < pindexPrev->nTime+60 )
|
||||||
pblock->nTime = pindexPrev->nTime + 60;
|
pblock->nTime = pindexPrev->nTime + 60;
|
||||||
if ( gpucount < 33 )
|
if ( gpucount < 33 )
|
||||||
pblock->nTime += (rand() % (33 - gpucount)*(33 - gpucount));
|
{
|
||||||
|
uint8_t tmpbuffer[40]; uint32_t r; int32_t n=0; uint256 randvals;
|
||||||
|
memcpy(&tmpbuffer[n],&My_notaryid,sizeof(My_notaryid)), n += sizeof(My_notaryid);
|
||||||
|
memcpy(&tmpbuffer[n],&Mining_height,sizeof(Mining_height)), n += sizeof(Mining_height);
|
||||||
|
memcpy(&tmpbuffer[n],&pblock->hashPrevBlock,sizeof(pblock->hashPrevBlock)), n += sizeof(pblock->hashPrevBlock);
|
||||||
|
vcalc_sha256(0,(uint8_t *)&randvals,tmpbuffer,n);
|
||||||
|
memcpy(&r,&randvals,sizeof(r));
|
||||||
|
pblock->nTime += (r % (33 - gpucount)*(33 - gpucount));
|
||||||
|
}
|
||||||
if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 )
|
if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 )
|
||||||
{
|
{
|
||||||
CAmount txfees = 5000;
|
CAmount txfees = 5000;
|
||||||
@@ -729,7 +740,8 @@ void static BitcoinMiner()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
komodo_chosennotary(¬aryid,chainActive.Tip()->nHeight,NOTARY_PUBKEY33,(uint32_t)chainActive.Tip()->GetBlockTime());
|
komodo_chosennotary(¬aryid,chainActive.Tip()->nHeight,NOTARY_PUBKEY33,(uint32_t)chainActive.Tip()->GetBlockTime());
|
||||||
|
if ( notaryid != My_notaryid )
|
||||||
|
My_notaryid = notaryid;
|
||||||
std::string solver;
|
std::string solver;
|
||||||
//if ( notaryid >= 0 || ASSETCHAINS_SYMBOL[0] != 0 )
|
//if ( notaryid >= 0 || ASSETCHAINS_SYMBOL[0] != 0 )
|
||||||
solver = "tromp";
|
solver = "tromp";
|
||||||
|
|||||||
@@ -634,12 +634,12 @@ bool getAddressesFromParams(const UniValue& params, std::vector<std::pair<uint16
|
|||||||
uint160 hashBytes;
|
uint160 hashBytes;
|
||||||
int type = 0;
|
int type = 0;
|
||||||
if (!address.GetIndexKey(hashBytes, type)) {
|
if (!address.GetIndexKey(hashBytes, type)) {
|
||||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid addresses");
|
||||||
}
|
}
|
||||||
addresses.push_back(std::make_pair(hashBytes, type));
|
addresses.push_back(std::make_pair(hashBytes, type));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid addresse");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -682,8 +682,8 @@ UniValue getaddressmempool(const UniValue& params, bool fHelp)
|
|||||||
" }\n"
|
" }\n"
|
||||||
"]\n"
|
"]\n"
|
||||||
"\nExamples:\n"
|
"\nExamples:\n"
|
||||||
+ HelpExampleCli("getaddressmempool", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
|
+ HelpExampleCli("getaddressmempool", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'")
|
||||||
+ HelpExampleRpc("getaddressmempool", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
|
+ HelpExampleRpc("getaddressmempool", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}")
|
||||||
);
|
);
|
||||||
|
|
||||||
std::vector<std::pair<uint160, int> > addresses;
|
std::vector<std::pair<uint160, int> > addresses;
|
||||||
@@ -753,8 +753,8 @@ UniValue getaddressutxos(const UniValue& params, bool fHelp)
|
|||||||
" }\n"
|
" }\n"
|
||||||
"]\n"
|
"]\n"
|
||||||
"\nExamples:\n"
|
"\nExamples:\n"
|
||||||
+ HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
|
+ HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'")
|
||||||
+ HelpExampleRpc("getaddressutxos", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
|
+ HelpExampleRpc("getaddressutxos", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}")
|
||||||
);
|
);
|
||||||
|
|
||||||
bool includeChainInfo = false;
|
bool includeChainInfo = false;
|
||||||
@@ -840,8 +840,8 @@ UniValue getaddressdeltas(const UniValue& params, bool fHelp)
|
|||||||
" }\n"
|
" }\n"
|
||||||
"]\n"
|
"]\n"
|
||||||
"\nExamples:\n"
|
"\nExamples:\n"
|
||||||
+ HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
|
+ HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'")
|
||||||
+ HelpExampleRpc("getaddressdeltas", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
|
+ HelpExampleRpc("getaddressdeltas", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -957,8 +957,8 @@ UniValue getaddressbalance(const UniValue& params, bool fHelp)
|
|||||||
" \"received\" (string) The total number of satoshis received (including change)\n"
|
" \"received\" (string) The total number of satoshis received (including change)\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\nExamples:\n"
|
"\nExamples:\n"
|
||||||
+ HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
|
+ HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'")
|
||||||
+ HelpExampleRpc("getaddressbalance", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
|
+ HelpExampleRpc("getaddressbalance", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}")
|
||||||
);
|
);
|
||||||
|
|
||||||
std::vector<std::pair<uint160, int> > addresses;
|
std::vector<std::pair<uint160, int> > addresses;
|
||||||
@@ -993,6 +993,23 @@ UniValue getaddressbalance(const UniValue& params, bool fHelp)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t komodo_snapshot();
|
||||||
|
|
||||||
|
UniValue getsnapshot(const UniValue& params, bool fHelp)
|
||||||
|
{
|
||||||
|
UniValue result(UniValue::VOBJ); int64_t total;
|
||||||
|
if ( fHelp || params.size() > 0 )
|
||||||
|
{
|
||||||
|
throw runtime_error(
|
||||||
|
"getsnapshot\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ( (total= komodo_snapshot()) >= 0 )
|
||||||
|
result.push_back(Pair("total", (double)total/COIN));
|
||||||
|
else result.push_back(Pair("error", "no addressindex"));
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
UniValue getaddresstxids(const UniValue& params, bool fHelp)
|
UniValue getaddresstxids(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
@@ -1015,8 +1032,8 @@ UniValue getaddresstxids(const UniValue& params, bool fHelp)
|
|||||||
" ,...\n"
|
" ,...\n"
|
||||||
"]\n"
|
"]\n"
|
||||||
"\nExamples:\n"
|
"\nExamples:\n"
|
||||||
+ HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
|
+ HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'")
|
||||||
+ HelpExampleRpc("getaddresstxids", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
|
+ HelpExampleRpc("getaddresstxids", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}")
|
||||||
);
|
);
|
||||||
|
|
||||||
std::vector<std::pair<uint160, int> > addresses;
|
std::vector<std::pair<uint160, int> > addresses;
|
||||||
|
|||||||
@@ -345,6 +345,7 @@ static const CRPCCommand vRPCCommands[] =
|
|||||||
{ "addressindex", "getaddressdeltas", &getaddressdeltas, false },
|
{ "addressindex", "getaddressdeltas", &getaddressdeltas, false },
|
||||||
{ "addressindex", "getaddresstxids", &getaddresstxids, false },
|
{ "addressindex", "getaddresstxids", &getaddresstxids, false },
|
||||||
{ "addressindex", "getaddressbalance", &getaddressbalance, false },
|
{ "addressindex", "getaddressbalance", &getaddressbalance, false },
|
||||||
|
{ "addressindex", "getsnapshot", &getsnapshot, false },
|
||||||
|
|
||||||
/* Utility functions */
|
/* Utility functions */
|
||||||
{ "util", "createmultisig", &createmultisig, true },
|
{ "util", "createmultisig", &createmultisig, true },
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ extern UniValue getaddressmempool(const UniValue& params, bool fHelp);
|
|||||||
extern UniValue getaddressutxos(const UniValue& params, bool fHelp);
|
extern UniValue getaddressutxos(const UniValue& params, bool fHelp);
|
||||||
extern UniValue getaddressdeltas(const UniValue& params, bool fHelp);
|
extern UniValue getaddressdeltas(const UniValue& params, bool fHelp);
|
||||||
extern UniValue getaddresstxids(const UniValue& params, bool fHelp);
|
extern UniValue getaddresstxids(const UniValue& params, bool fHelp);
|
||||||
|
extern UniValue getsnapshot(const UniValue& params, bool fHelp);
|
||||||
extern UniValue getaddressbalance(const UniValue& params, bool fHelp);
|
extern UniValue getaddressbalance(const UniValue& params, bool fHelp);
|
||||||
extern UniValue getpeerinfo(const UniValue& params, bool fHelp);
|
extern UniValue getpeerinfo(const UniValue& params, bool fHelp);
|
||||||
extern UniValue ping(const UniValue& params, bool fHelp);
|
extern UniValue ping(const UniValue& params, bool fHelp);
|
||||||
|
|||||||
44
src/txdb.cpp
44
src/txdb.cpp
@@ -396,6 +396,50 @@ bool CBlockTreeDB::ReadAddressIndex(uint160 addressHash, int type,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address);
|
||||||
|
|
||||||
|
int64_t CBlockTreeDB::Snapshot()
|
||||||
|
{
|
||||||
|
char chType; int64_t total = -1; std::string address;
|
||||||
|
boost::scoped_ptr<leveldb::Iterator> pcursor(NewIterator());
|
||||||
|
pcursor->SeekToFirst();
|
||||||
|
fprintf(stderr,"pcursor iterate\n");
|
||||||
|
while (pcursor->Valid())
|
||||||
|
{
|
||||||
|
boost::this_thread::interruption_point();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
leveldb::Slice slKey = pcursor->key();
|
||||||
|
CDataStream ssKey(slKey.data(), slKey.data()+slKey.size(), SER_DISK, CLIENT_VERSION);
|
||||||
|
CAddressIndexKey indexKey;
|
||||||
|
ssKey >> chType;
|
||||||
|
ssKey >> indexKey;
|
||||||
|
fprintf(stderr,"chType.%d\n",chType);
|
||||||
|
if ( chType == DB_ADDRESSINDEX )
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
leveldb::Slice slValue = pcursor->value();
|
||||||
|
CDataStream ssValue(slValue.data(), slValue.data()+slValue.size(), SER_DISK, CLIENT_VERSION);
|
||||||
|
CAmount nValue;
|
||||||
|
ssValue >> nValue;
|
||||||
|
getAddressFromIndex(indexKey.type, indexKey.hashBytes, address);
|
||||||
|
fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN);
|
||||||
|
if ( total < 0 )
|
||||||
|
total = (int64_t)nValue;
|
||||||
|
else total += (int64_t)nValue;
|
||||||
|
//addressIndex.push_back(make_pair(indexKey, nValue));
|
||||||
|
pcursor->Next();
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
return error("failed to get address index value");
|
||||||
|
}
|
||||||
|
} else { break; }
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(total);
|
||||||
|
}
|
||||||
|
|
||||||
bool CBlockTreeDB::WriteTimestampIndex(const CTimestampIndexKey ×tampIndex) {
|
bool CBlockTreeDB::WriteTimestampIndex(const CTimestampIndexKey ×tampIndex) {
|
||||||
CLevelDBBatch batch;
|
CLevelDBBatch batch;
|
||||||
batch.Write(make_pair(DB_TIMESTAMPINDEX, timestampIndex), 0);
|
batch.Write(make_pair(DB_TIMESTAMPINDEX, timestampIndex), 0);
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ public:
|
|||||||
bool ReadFlag(const std::string &name, bool &fValue);
|
bool ReadFlag(const std::string &name, bool &fValue);
|
||||||
bool LoadBlockIndexGuts();
|
bool LoadBlockIndexGuts();
|
||||||
bool blockOnchainActive(const uint256 &hash);
|
bool blockOnchainActive(const uint256 &hash);
|
||||||
|
int64_t Snapshot();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BITCOIN_TXDB_H
|
#endif // BITCOIN_TXDB_H
|
||||||
|
|||||||
Reference in New Issue
Block a user