-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
0.21.kyo.2 #50
base: 0.21.base
Are you sure you want to change the base?
0.21.kyo.2 #50
Changes from all commits
1a85d7c
b840689
40b2167
1a00326
687bc08
850f5c6
749652f
1de3eec
e762b6d
c5c2338
c8e1daf
63bba49
5aa90a6
90750ea
73daa61
937041a
ad37d7a
58b2566
8806e08
be75d75
71f5454
25cfe3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,10 @@ | |
|
||
#include <vector> | ||
|
||
#define BLOCK_PROOF_OF_STAKE 0x01 // is proof-of-stake block | ||
#define BLOCK_STAKE_ENTROPY 0x02 // entropy bit for stake modifier | ||
#define BLOCK_STAKE_MODIFIER 0x04 | ||
|
||
/** | ||
* Maximum amount of time that a block timestamp is allowed to exceed the | ||
* current network-adjusted time before the block will be accepted. | ||
|
@@ -63,6 +67,12 @@ class CBlockFileInfo | |
nBlocks = 0; | ||
nSize = 0; | ||
nUndoSize = 0; | ||
nFlags = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These changes belong in the Also, Take a look at the file on 0.17 here: Please make sure you're careful when you move code, it needs to be added to appropriate locations - this is important as some properties are purposely mem-only or not serialized at all depending on usage. I understand you were trying to short-hand initialize the values on declaration with |
||
nStakeModifier = 0; | ||
nStakeModifierChecksum = 0; | ||
hashProofOfStake = arith_uint256(); | ||
prevoutStake.SetNull(); | ||
nStakeTime = 0; | ||
nHeightFirst = 0; | ||
nHeightLast = 0; | ||
nTimeFirst = 0; | ||
|
@@ -180,14 +190,27 @@ class CBlockIndex | |
uint32_t nBits{0}; | ||
uint32_t nNonce{0}; | ||
|
||
unsigned int nFlags; // ppcoin: block index flags | ||
|
||
uint64_t nStakeModifier; // hash modifier for proof-of-stake | ||
unsigned int nStakeModifierChecksum; // checksum of index; in-memeory only | ||
|
||
// proof-of-stake specific fields | ||
COutPoint prevoutStake; | ||
unsigned int nStakeTime; | ||
arith_uint256 hashProofOfStake; | ||
|
||
//! (memory only) Sequential id assigned to distinguish order in which blocks are received. | ||
int32_t nSequenceId{0}; | ||
|
||
//! (memory only) Maximum nTime in the chain up to and including this block. | ||
unsigned int nTimeMax{0}; | ||
|
||
|
||
|
||
CBlockIndex() | ||
{ | ||
|
||
} | ||
|
||
explicit CBlockIndex(const CBlockHeader& block) | ||
|
@@ -301,6 +324,47 @@ class CBlockIndex | |
return false; | ||
} | ||
|
||
bool IsProofOfWork() const | ||
{ | ||
return !(nFlags & BLOCK_PROOF_OF_STAKE); | ||
} | ||
|
||
bool IsProofOfStake() const | ||
{ | ||
return (nFlags & BLOCK_PROOF_OF_STAKE); | ||
} | ||
|
||
void SetProofOfStake() | ||
{ | ||
nFlags |= BLOCK_PROOF_OF_STAKE; | ||
} | ||
|
||
unsigned int GetStakeEntropyBit() const | ||
{ | ||
return ((nFlags & BLOCK_STAKE_ENTROPY) >> 1); | ||
} | ||
|
||
bool SetStakeEntropyBit(unsigned int nEntropyBit) | ||
{ | ||
if (nEntropyBit > 1) | ||
return false; | ||
nFlags |= (nEntropyBit ? BLOCK_STAKE_ENTROPY : 0); | ||
return true; | ||
} | ||
|
||
void SetStakeModifier(uint64_t nModifier, bool fGeneratedStakeModifier) | ||
{ | ||
nStakeModifier = nModifier; | ||
if (fGeneratedStakeModifier) | ||
nFlags |= BLOCK_STAKE_MODIFIER; | ||
} | ||
|
||
bool GeneratedStakeModifier() const | ||
{ | ||
return (nFlags & BLOCK_STAKE_MODIFIER); | ||
} | ||
|
||
|
||
//! Build the skiplist pointer for this entry. | ||
void BuildSkip(); | ||
|
||
|
@@ -319,11 +383,15 @@ const CBlockIndex* LastCommonAncestor(const CBlockIndex* pa, const CBlockIndex* | |
/** Used to marshal pointers into hashes for db storage. */ | ||
class CDiskBlockIndex : public CBlockIndex | ||
{ | ||
private: | ||
uint256 blockHash; | ||
|
||
public: | ||
uint256 hashPrev; | ||
|
||
CDiskBlockIndex() { | ||
hashPrev = uint256(); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing |
||
} | ||
|
||
explicit CDiskBlockIndex(const CBlockIndex* pindex) : CBlockIndex(*pindex) { | ||
|
@@ -342,13 +410,27 @@ class CDiskBlockIndex : public CBlockIndex | |
if (obj.nStatus & BLOCK_HAVE_DATA) READWRITE(VARINT(obj.nDataPos)); | ||
if (obj.nStatus & BLOCK_HAVE_UNDO) READWRITE(VARINT(obj.nUndoPos)); | ||
|
||
READWRITE(nFlags); | ||
READWRITE(nStakeModifier); | ||
if (IsProofOfStake()) { | ||
READWRITE(prevoutStake); | ||
READWRITE(nStakeTime); | ||
} else if (ser_action.ForRead()) { | ||
const_cast<CDiskBlockIndex*>(this)->prevoutStake.SetNull(); | ||
const_cast<CDiskBlockIndex*>(this)->nStakeTime = 0; | ||
} | ||
|
||
READWRITE(hashProofOfStake); | ||
|
||
// block header | ||
READWRITE(obj.nVersion); | ||
READWRITE(obj.hashPrev); | ||
READWRITE(obj.hashMerkleRoot); | ||
READWRITE(obj.nTime); | ||
READWRITE(obj.nBits); | ||
READWRITE(obj.nNonce); | ||
READWRITE(blockHash); | ||
|
||
} | ||
|
||
uint256 GetBlockHash() const | ||
|
@@ -360,6 +442,8 @@ class CDiskBlockIndex : public CBlockIndex | |
block.nTime = nTime; | ||
block.nBits = nBits; | ||
block.nNonce = nNonce; | ||
const_cast<CDiskBlockIndex*>(this)->blockHash = block.GetHash(); | ||
|
||
return block.GetHash(); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happened to
static const CAmount CENT = 1000000;
I believe this was used across different files?