Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmed Hilali committed Sep 10, 2019
1 parent cc84bee commit a8cd45f
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 21 deletions.
2 changes: 0 additions & 2 deletions src/pos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ static bool CheckStakeModifier(const CBlockIndex* pindexPrev, const CBlock& bloc
if (block.hashPrevBlock.IsNull())
return block.stakeModifier.IsNull();

if (block.IsProofOfStake())
return block.stakeModifier == pos::ComputeStakeModifier_PoS(pindexPrev->stakeModifier,
block.proofOfStakeBody->coinstakePrevout);
return block.stakeModifier == pos::ComputeStakeModifier_PoW(pindexPrev->stakeModifier, block.hashPrevBlock);
}

bool CheckBlockProof_headerOnly(const CBlockHeader& block, const Consensus::Params& params) {
Expand Down
4 changes: 0 additions & 4 deletions src/pos.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ class CBlockIndex;

class CBlockHeader;

class CTransaction;

class COutPoint;

class CCoinsViewCache;

namespace pos {
Expand Down
8 changes: 0 additions & 8 deletions src/pos_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,4 @@ namespace pos {
ss << prevStakeModifier << prevout.hash << prevout.n;
return Hash(ss.begin(), ss.end());
}

uint256 ComputeStakeModifier_PoW(uint256 prevStakeModifier, const uint256& prevBlockHash) {
// Calculate hash
CDataStream ss(SER_GETHASH, 0);
ss << prevStakeModifier << prevBlockHash;
return Hash(ss.begin(), ss.end());
}

}
5 changes: 0 additions & 5 deletions src/pos_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,4 @@ namespace pos {
/// of transaction confirmation. To meet kernel protocol, the txout
/// must hash with a future stake modifier to generate the proof.
uint256 ComputeStakeModifier_PoS(uint256 prevStakeModifier, const COutPoint& prevout);

/// Theoretically, blockHash can be used by miner to make next PoS block easier for him.
/// However, PoW blocks are not supported in mainnet.
uint256 ComputeStakeModifier_PoW(uint256 prevStakeModifier, const uint256& prevBlockHash);

}
4 changes: 2 additions & 2 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4645,10 +4645,10 @@ int CWalletTx::GetDepthInMainChain(interfaces::Chain::Lock& locked_chain) const

int CWalletTx::GetBlocksToMaturity(interfaces::Chain::Lock& locked_chain) const
{
if (!IsCoinBase())
if (!IsCoinStake())
return 0;
int chain_depth = GetDepthInMainChain(locked_chain);
assert(chain_depth >= 0); // coinbase tx should not be conflicted
assert(chain_depth >= 0); // coinstake tx should not be conflicted
return std::max(0, (COINBASE_MATURITY+1) - chain_depth);
}

Expand Down
1 change: 1 addition & 0 deletions src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ class CWalletTx

const uint256& GetHash() const { return tx->GetHash(); }
bool IsCoinBase() const { return tx->IsCoinBase(); }
bool IsCoinStake() const { return tx->IsCoinStake(); }
bool IsImmatureCoinBase(interfaces::Chain::Lock& locked_chain) const;
};

Expand Down

0 comments on commit a8cd45f

Please sign in to comment.