Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,37 @@ crypto_libbitcoin_crypto_base_a_SOURCES = \
crypto/hmac_sha256.cpp \
crypto/hmac_sha256.h \
crypto/hmac_sha512.cpp \

crypto/hmac_sha512.h \
crypto/sha512.h \
crypto/aes_helper.c \
crypto/blake.c \
crypto/bmw.c \
crypto/cubehash.c \
crypto/echo.c \
crypto/fugue.c \
crypto/groestl.c \
crypto/hamsi.c \
crypto/hamsi_helper.c \
crypto/jh.c \
crypto/keccak.c \
crypto/luffa.c \
crypto/shavite.c \
crypto/simd.c \
crypto/skein.c \
crypto/sph_simd.h \
crypto/sph_shavite.h \
crypto/sph_skein.h \
crypto/sph_jh.h \
crypto/sph_hamsi.h \
crypto/sph_keccak.h \
crypto/sph_echo.h \
crypto/sph_fugue.h \
crypto/sph_groestl.h \
crypto/sph_cubehash.h \
crypto/sph_bmw.h \
crypto/sph_blake.h \
crypto/sph_luffa.h \
crypto/poly1305.h \
crypto/poly1305.cpp \
crypto/ripemd160.cpp \
Expand Down
2 changes: 1 addition & 1 deletion src/amount.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static const CAmount COIN = 100000000;
* critical; in unusual circumstances like a(nother) overflow bug that allowed
* for the creation of coins out of thin air modification could lead to a fork.
* */
static const CAmount MAX_MONEY = 21000000 * COIN;
static const CAmount MAX_MONEY = 10000000 * COIN;
inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }

#endif // BITCOIN_AMOUNT_H
84 changes: 84 additions & 0 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -63,6 +67,12 @@ class CBlockFileInfo
nBlocks = 0;
nSize = 0;
nUndoSize = 0;
nFlags = 0;
nStakeModifier = 0;
nStakeModifierChecksum = 0;
hashProofOfStake = arith_uint256();
prevoutStake.SetNull();
nStakeTime = 0;
nHeightFirst = 0;
nHeightLast = 0;
nTimeFirst = 0;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();

Expand All @@ -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();

}

explicit CDiskBlockIndex(const CBlockIndex* pindex) : CBlockIndex(*pindex) {
Expand All @@ -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
Expand All @@ -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();
}

Expand Down
Loading