Skip to content
29 changes: 29 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,35 @@ crypto_libbitcoin_crypto_base_a_SOURCES = \
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
70 changes: 70 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,11 @@ class CBlockFileInfo
nBlocks = 0;
nSize = 0;
nUndoSize = 0;
nFlags = 0;
nStakeModifier = 0;
hashProofOfStake = arith_uint256();
prevoutStake.SetNull();
nStakeTime = 0;
nHeightFirst = 0;
nHeightLast = 0;
nTimeFirst = 0;
Expand Down Expand Up @@ -180,14 +189,26 @@ 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

// 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 +322,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 +381,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 @@ -349,6 +415,8 @@ class CDiskBlockIndex : public CBlockIndex
READWRITE(obj.nTime);
READWRITE(obj.nBits);
READWRITE(obj.nNonce);
READWRITE(blockHash);

}

uint256 GetBlockHash() const
Expand All @@ -360,6 +428,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
248 changes: 174 additions & 74 deletions src/chainparams.cpp

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/clientversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
* for both bitcoind and bitcoin-qt, to make it harder for attackers to
* target servers or GUI users specifically.
*/
const std::string CLIENT_NAME("Satoshi");
const std::string CLIENT_NAME("SidneyReilly");
#define CLIENT_VERSION_SUFFIX " ''"


#ifdef HAVE_BUILD_INFO
Expand Down
7 changes: 4 additions & 3 deletions src/consensus/consensus.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#ifndef BITCOIN_CONSENSUS_CONSENSUS_H
#define BITCOIN_CONSENSUS_CONSENSUS_H

#include <stdlib.h>
#include <stdint.h>
#include <stdlib.h>

/** The maximum allowed size for a serialized block, in bytes (only for buffer size limits) */
static const unsigned int MAX_BLOCK_SERIALIZED_SIZE = 4000000;
Expand All @@ -16,11 +16,12 @@ static const unsigned int MAX_BLOCK_WEIGHT = 4000000;
/** The maximum allowed number of signature check operations in a block (network rule) */
static const int64_t MAX_BLOCK_SIGOPS_COST = 80000;
/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */
static const int COINBASE_MATURITY = 100;
static const int COINBASE_MATURITY = 40;
static const int COINBASE_MATURITY_TESTNET = 10;

static const int WITNESS_SCALE_FACTOR = 4;

static const size_t MIN_TRANSACTION_WEIGHT = WITNESS_SCALE_FACTOR * 60; // 60 is the lower bound for the size of a valid serialized CTransaction
static const size_t MIN_TRANSACTION_WEIGHT = WITNESS_SCALE_FACTOR * 60; // 60 is the lower bound for the size of a valid serialized CTransaction
static const size_t MIN_SERIALIZABLE_TRANSACTION_WEIGHT = WITNESS_SCALE_FACTOR * 10; // 10 is the lower bound for the size of a serialized CTransaction

/** Flags for nSequence and nLockTime locks */
Expand Down
6 changes: 6 additions & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ struct Params {
uint256 nMinimumChainWork;
/** By default assume that the signatures in ancestors of this block are valid */
uint256 defaultAssumeValid;

// proof of stake
uint256 posLimit;
unsigned int nStakeMinAge;
unsigned int nStakeMaxAge;
unsigned int nStakeTargetSpacing;

/**
* If true, witness commitments contain a payload equal to a Bitcoin Script solution
Expand Down
Loading