add notary pay stuff without breaking blockindex.

This commit is contained in:
blackjok3r
2019-04-17 18:36:00 +08:00
parent ab7558ab9d
commit 25bf471ddd
3 changed files with 12 additions and 9 deletions

View File

@@ -28,6 +28,7 @@ class CChainPower;
#include "pow.h" #include "pow.h"
#include "tinyformat.h" #include "tinyformat.h"
#include "uint256.h" #include "uint256.h"
extern int8_t is_STAKED(const char *chain_name);
#include <vector> #include <vector>
@@ -36,6 +37,8 @@ class CChainPower;
static const int SPROUT_VALUE_VERSION = 1001400; static const int SPROUT_VALUE_VERSION = 1001400;
static const int SAPLING_VALUE_VERSION = 1010100; static const int SAPLING_VALUE_VERSION = 1010100;
extern int32_t ASSETCHAINS_LWMAPOS; extern int32_t ASSETCHAINS_LWMAPOS;
extern char ASSETCHAINS_SYMBOL[65];
//extern uint64_t ASSETCHAINS_NOTARY_PAY;
struct CDiskBlockPos struct CDiskBlockPos
{ {
@@ -533,11 +536,6 @@ public:
READWRITE(nNonce); READWRITE(nNonce);
READWRITE(nSolution); READWRITE(nSolution);
// LABS extra blockindex stuff.
// only read/write nNotaryPay if it has a value. This should be backwards compatible with all existing chains.
if ( nNotaryPay != 0 )
READWRITE(nNotaryPay);
// Only read/write nSproutValue if the client version used to create // Only read/write nSproutValue if the client version used to create
// this index was storing them. // this index was storing them.
if ((s.GetType() & SER_DISK) && (nVersion >= SPROUT_VALUE_VERSION)) { if ((s.GetType() & SER_DISK) && (nVersion >= SPROUT_VALUE_VERSION)) {
@@ -549,6 +547,11 @@ public:
if ((s.GetType() & SER_DISK) && (nVersion >= SAPLING_VALUE_VERSION)) { if ((s.GetType() & SER_DISK) && (nVersion >= SAPLING_VALUE_VERSION)) {
READWRITE(nSaplingValue); READWRITE(nSaplingValue);
} }
if ( (s.GetType() & SER_DISK) && (is_STAKED(ASSETCHAINS_SYMBOL) != 0) )
{
READWRITE(nNotaryPay);
READWRITE(segid);
}
} }
uint256 GetBlockHash() const uint256 GetBlockHash() const

View File

@@ -1,7 +1,7 @@
#ifndef KOMODO_NK_H #ifndef KOMODO_NK_H
#define KOMODO_NK_H #define KOMODO_NK_H
#define ASSETCHAINS_N 96 #define ASSETCHAINS_N 77
#define ASSETCHAINS_K 5 #define ASSETCHAINS_K 3
#endif #endif

View File

@@ -3714,11 +3714,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
//FlushStateToDisk(); //FlushStateToDisk();
komodo_connectblock(false,pindex,*(CBlock *)&block); // dPoW state update. komodo_connectblock(false,pindex,*(CBlock *)&block); // dPoW state update.
if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 ) if ( ASSETCHAINS_NOTARY_PAY[0] != 0 )
{ {
// Update the notary pay with the latest payment. // Update the notary pay with the latest payment.
pindex->nNotaryPay = pindex->pprev->nNotaryPay + notarypaycheque; pindex->nNotaryPay = pindex->pprev->nNotaryPay + notarypaycheque;
fprintf(stderr, "total notary pay.%li\n", pindex->nNotaryPay); //fprintf(stderr, "total notary pay.%li\n", pindex->nNotaryPay);
} }
return true; return true;
} }