Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Benjamin Allred
crown-core
Commits
ffd0e8ba
Commit
ffd0e8ba
authored
6 years ago
by
presstab
Browse files
Options
Download
Email Patches
Plain Diff
Add PoS to CBlock and Header
parent
cf1f2d66
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
src/chainparams.cpp
+4
-1
src/chainparams.cpp
src/chainparams.h
+6
-1
src/chainparams.h
src/miner.cpp
+4
-1
src/miner.cpp
src/primitives/block.cpp
+5
-0
src/primitives/block.cpp
src/primitives/block.h
+2
-0
src/primitives/block.h
src/primitives/pureheader.h
+14
-0
src/primitives/pureheader.h
with
35 additions
and
3 deletions
+35
-3
src/chainparams.cpp
View file @
ffd0e8ba
...
...
@@ -125,7 +125,10 @@ public:
nMinerThreads
=
0
;
nTargetTimespan
=
14
*
24
*
60
*
60
;
// Crown: 2 weeks
nTargetSpacing
=
1
*
60
;
// Crown: 1 minutes
nMaxTipAge
=
6
*
60
*
60
;
nMaxTipAge
=
6
*
60
*
60
;
nAuxpowChainId
=
20
;
nPoSChainId
=
22
;
/**
* Build the genesis block. Note that the output of the genesis coinbase cannot
...
...
This diff is collapsed.
Click to expand it.
src/chainparams.h
View file @
ffd0e8ba
...
...
@@ -84,7 +84,9 @@ public:
int64_t
StartMasternodePayments
()
const
{
return
nStartMasternodePayments
;
}
CBaseChainParams
::
Network
NetworkID
()
const
{
return
networkID
;
}
/* Return the auxpow chain ID. */
inline
int32_t
AuxpowChainId
()
const
{
return
20
;
}
inline
int32_t
AuxpowChainId
()
const
{
return
nAuxpowChainId
;
}
int32_t
PoSChainId
()
const
{
return
nPoSChainId
;
}
int
PoSStartHeight
()
const
{
return
nBlockPoSStart
;
}
/* Return start height of auxpow and the retarget interval change. */
virtual
int
AuxpowStartHeight
()
const
=
0
;
/* Return whether or not to enforce strict chain ID checks. */
...
...
@@ -127,6 +129,9 @@ protected:
std
::
string
strLegacySignerDummyAddress
;
std
::
string
strDevfundAddress
;
int64_t
nStartMasternodePayments
;
int32_t
nAuxpowChainId
;
int32_t
nPoSChainId
;
int
nBlockPoSStart
;
};
/**
...
...
This diff is collapsed.
Click to expand it.
src/miner.cpp
View file @
ffd0e8ba
...
...
@@ -108,7 +108,10 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
txNew
.
vout
[
0
].
scriptPubKey
=
scriptPubKeyIn
;
/* Initialise the block version. */
const
int32_t
nChainId
=
Params
().
AuxpowChainId
();
int32_t
nChainId
=
Params
().
AuxpowChainId
();
if
(
chainActive
.
Height
()
>
Params
().
PoSStartHeight
())
nChainId
=
Params
().
PoSChainId
();
pblock
->
nVersion
.
SetBaseVersion
(
CBlockHeader
::
CURRENT_VERSION
,
nChainId
);
...
...
This diff is collapsed.
Click to expand it.
src/primitives/block.cpp
View file @
ffd0e8ba
...
...
@@ -24,6 +24,11 @@ void CBlockHeader::SetAuxpow (CAuxPow* apow)
}
}
void
CBlockHeader
::
SetProofOfStake
(
bool
fProofOfStake
)
{
nVersion
.
SetProofOfStake
(
fProofOfStake
);
}
uint256
CBlock
::
BuildMerkleTree
(
bool
*
fMutated
)
const
{
/* WARNING! If you're reading this because you're learning about crypto
...
...
This diff is collapsed.
Click to expand it.
src/primitives/block.h
View file @
ffd0e8ba
...
...
@@ -75,6 +75,8 @@ public:
*/
void
SetAuxpow
(
CAuxPow
*
apow
);
void
SetProofOfStake
(
bool
fProofOfStake
);
};
class
CBlock
:
public
CBlockHeader
...
...
This diff is collapsed.
Click to expand it.
src/primitives/pureheader.h
View file @
ffd0e8ba
...
...
@@ -21,6 +21,7 @@ private:
/* Modifiers to the version. */
static
const
int32_t
VERSION_AUXPOW
=
(
1
<<
8
);
static
const
int32_t
VERSION_POS_START
=
(
1
<<
9
);
/** Bits above are reserved for the auxpow chain ID. */
static
const
int32_t
VERSION_CHAIN_START
=
(
1
<<
16
);
...
...
@@ -123,6 +124,19 @@ public:
nVersion
&=
~
VERSION_AUXPOW
;
}
inline
bool
IsProofOfStake
()
const
{
return
nVersion
&
VERSION_POS_START
;
}
inline
void
SetProofOfStake
(
bool
fProofOfStake
)
{
if
(
fProofOfStake
)
nVersion
|=
VERSION_POS_START
;
else
nVersion
&=
~
VERSION_POS_START
;
}
/**
* Check whether this is a "legacy" block without chain ID.
* @return True iff it is.
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment