Permalink
Browse files

Fix resendtx

  • Loading branch information...
Tranz5 committed May 6, 2014
1 parent fdf06a7 commit a26f801dd4880a1c7a31c2fda9f821510adb3743
Showing with 25 additions and 21 deletions.
  1. +2 −2 src/main.cpp
  2. +1 −1 src/main.h
  3. +1 −1 src/rpcwallet.cpp
  4. +20 −16 src/wallet.cpp
  5. +1 −1 src/wallet.h
@@ -224,12 +224,12 @@ void static Inventory(const uint256& hash)
}
// ask wallets to resend their transactions
void ResendWalletTransactions()
void ResendWalletTransactions(bool fForce)
{
{
LOCK(cs_setpwalletRegistered);
BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
pwallet->ResendWalletTransactions();
pwallet->ResendWalletTransactions(fForce);
}
}
@@ -137,7 +137,7 @@ uint256 WantedByOrphan(const CBlock* pblockOrphan);
const CBlockIndex* GetLastBlockIndex(const CBlockIndex* pindex, bool fProofOfStake);
void BitcoinMiner(CWallet *pwallet);
void StakeMiner(CWallet *pwallet);
void ResendWalletTransactions();
void ResendWalletTransactions(bool fForce = false);
@@ -1825,7 +1825,7 @@ Value resendtx(CWallet* pWallet, const Array& params, bool fHelp)
"Re-send unconfirmed transactions.\n"
);
ResendWalletTransactions();
ResendWalletTransactions(true);
return Value::null;
}
@@ -975,23 +975,27 @@ void CWalletTx::RelayWalletTransaction()
RelayWalletTransaction(txdb);
}
void CWallet::ResendWalletTransactions()
void CWallet::ResendWalletTransactions(bool fForce)
{
// Do this infrequently and randomly to avoid giving away
// that these are our transactions.
static int64 nNextTime;
if (GetTime() < nNextTime)
return;
bool fFirst = (nNextTime == 0);
nNextTime = GetTime() + GetRand(30 * 60);
if (fFirst)
return;
// Only do it if there's been a new block since last time
static int64 nLastTime;
if (nTimeBestReceived < nLastTime)
return;
nLastTime = GetTime();
if (!fForce)
{
// Do this infrequently and randomly to avoid giving away
// that these are our transactions.
static int64 nNextTime;
if (GetTime() < nNextTime)
return;
bool fFirst = (nNextTime == 0);
nNextTime = GetTime() + GetRand(30 * 60);
if (fFirst)
return;
// Only do it if there's been a new block since last time
static int64 nLastTime;
if (nTimeBestReceived < nLastTime)
return;
nLastTime = GetTime();
}
// Rebroadcast any of our txes that aren't in a block yet
printf("ResendWalletTransactions()\n");
@@ -1005,7 +1009,7 @@ void CWallet::ResendWalletTransactions()
CWalletTx& wtx = item.second;
// Don't rebroadcast until it's had plenty of time that
// it should have gotten in already by now.
if (nTimeBestReceived - (int64)wtx.nTimeReceived > 5 * 60)
if (fForce || nTimeBestReceived - (int64_t)wtx.nTimeReceived > 5 * 60)
mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx));
}
BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted)
@@ -232,7 +232,7 @@ class CWallet : public CCryptoKeyStore
int ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false);
int ScanForWalletTransaction(const uint256& hashTx);
void ReacceptWalletTransactions();
void ResendWalletTransactions();
void ResendWalletTransactions(bool fForce = false);
int64 GetBalance() const;
int64 GetUnconfirmedBalance() const;
int64 GetImmatureBalance() const;

0 comments on commit a26f801

Please sign in to comment.