Skip to content

Commit

Permalink
Initial synchronization fix + cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
pallas1 committed Mar 14, 2018
1 parent 35c30aa commit 1bfc8bb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ std::string CTxIn::ToString() const
if (IsNull())
str += strprintf("nValue %d.%08d, coinbase %s", nValue / COIN, nValue % COIN, HexStr(scriptSig));
else
str += strprintf("nValue %d.%08d, addr %s, pubKey %s, scriptSig=%s", nValue / COIN, nValue % COIN,
str += strprintf("nValue %d.%08d, addr %s, pubKey %s, scriptSig=%s", nValue / COIN, nValue % COIN,
CBitcoinAddress(CKeyID(pubKey)).ToString(), pubKey.ToString(), HexStr(scriptSig));
str += ")";
return str;
Expand Down Expand Up @@ -86,7 +86,7 @@ uint64_t CTransaction::GetValueOut() const
uint64_t nValueOut = 0;
BOOST_FOREACH(const CTxOut& txout, vout)
{
if (!MoneyRange(txout.nValue+nValueOut) || (nValueOut + txout.nValue) < nValueOut)
if (!MoneyRange(txout.nValue + nValueOut) || (nValueOut + txout.nValue < nValueOut))
throw std::runtime_error("CTransaction::GetValueOut() : value out of range");
nValueOut += txout.nValue;
}
Expand All @@ -98,8 +98,8 @@ uint64_t CTransaction::GetValueIn() const
uint64_t nValueIn = 0;
BOOST_FOREACH(const CTxIn& txin, vin)
{
if (!MoneyRange(txin.nValue+nValueIn) || (nValueIn+txin.nValue) < nValueIn)
throw std::runtime_error("CTransaction::GetValueIn() : value in of range");
if (!MoneyRange(txin.nValue + nValueIn) || (nValueIn + txin.nValue < nValueIn))
throw std::runtime_error("CTransaction::GetValueIn() : value out of range");
nValueIn += txin.nValue;
}
return nValueIn;
Expand Down
4 changes: 2 additions & 2 deletions src/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class CTxOut
// to spend something, then we consider it dust.
// A typical txout is 34 bytes big, and will
// need a CTxIn of at least 148 bytes to spend,
// so dust is a txout less than 546 satoshis
// so dust is a txout less than 546 satoshis
// with default nMinRelayTxFee.
return ((nValue*1000)/(3*((int)GetSerializeSize(SER_DISK,0)+148)) < nMinRelayTxFee);
}
Expand Down Expand Up @@ -308,7 +308,7 @@ class CBlockHeader
static const int CURRENT_VERSION=1;

//!!!!!!!!!!! struct must be in packed order even though serialize order is version first
//or else we can't use hash macros, could also use #pragma pack but that has
//or else we can't use hash macros, could also use #pragma pack but that has
//terrible implicatation on non-x86
uint256 hashPrevBlock;
uint256 hashMerkleRoot;
Expand Down
14 changes: 8 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,16 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
REJECT_INVALID, "bad-txns-msg-length");
}

BOOST_FOREACH(const CTxIn& txin, tx.vin)
{
if (!tx.IsCoinBase()) {
BOOST_FOREACH(const CTxIn& txin, tx.vin)
{
uint64_t balance=0;
pviewTip->Balance(txin.pubKey,balance);
if(balance > 1800000000 * COIN)
return state.DoS(100, error("CheckTransaction() : txin total out of range"),
REJECT_INVALID, "bad-txns-txintotal-toolarge");
}
return state.DoS(100, error("CheckTransaction() : txin out of range"),
REJECT_INVALID, "bad-txns-txintotal-toolarge");
}
}

// Check for duplicate inputs
set<uint160> vInOutPoints;
Expand Down Expand Up @@ -2039,7 +2041,7 @@ bool static WriteBlockPosition(CBlockIndex *pindexNew, const CBlock &block, cons

bool static AcceptBlockHeader(const CBlockHeader &block, CValidationState& state, CBlockIndex* &pindexNew)
{
printf("Accept block header\n");
//printf("Accept block header\n");

// Check for duplicate
uint256 hash = block.GetHash();
Expand Down

0 comments on commit 1bfc8bb

Please sign in to comment.