Browse Source

Lock fixes

pull/434/head
miketout 2 years ago
parent
commit
17d7595626
  1. 24
      src/miner.cpp
  2. 1
      src/rpc/misc.cpp
  3. 4
      src/rpc/pbaasrpc.cpp

24
src/miner.cpp

@ -1603,7 +1603,6 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const std::vecto
// if this is not for mining, first determine if we have a right to make a block
if (isStake)
{
LOCK(pwalletMain->cs_wallet);
uint64_t txfees, utxovalue;
uint32_t txtime;
uint256 utxotxid;
@ -1881,11 +1880,14 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const std::vecto
if (notarizationBuilder.mtx.vin.size())
{
LOCK2(cs_main, mempool.cs);
TransactionBuilderResult buildResult = notarizationBuilder.Build();
if (buildResult.IsTx())
std::vector<TransactionBuilderResult> buildResultVec;
{
LOCK2(cs_main, pwalletMain->cs_wallet);
buildResultVec.push_back(notarizationBuilder.Build());
}
if (buildResultVec[0].IsTx())
{
notarizationTx = buildResult.GetTxOrThrow();
notarizationTx = buildResultVec[0].GetTxOrThrow();
if (LogAcceptCategory("notarization"))
{
@ -1895,16 +1897,20 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const std::vecto
LogPrint("notarization", "%s: (PII) Submitting notarization confirmations:\n%s\n", __func__, jsonNotaryConfirmations.write(1,2).c_str());
}
// add to mem pool and relay
if (myAddtomempool(notarizationTx))
bool relayTx = false;
{
LOCK(mempool.cs);
relayTx = myAddtomempool(notarizationTx);
}
if (relayTx)
{
RelayTransaction(notarizationTx);
}
}
else
{
printf("%s: (PII) error adding notary evidence: %s\n", __func__, buildResult.GetError().c_str());
LogPrint("notarization", "%s: (PII) error adding notary evidence: %s\n", __func__, buildResult.GetError().c_str());
printf("%s: (PII) error adding notary evidence: %s\n", __func__, buildResultVec[0].GetError().c_str());
LogPrint("notarization", "%s: (PII) error adding notary evidence: %s\n", __func__, buildResultVec[0].GetError().c_str());
}
}
}

1
src/rpc/misc.cpp

@ -148,6 +148,7 @@ UniValue getinfo(const UniValue& params, bool fHelp)
obj.push_back(Pair("testnet", PBAAS_TESTMODE));
#ifdef ENABLE_WALLET
if (pwalletMain) {
LOCK(pwalletMain->cs_wallet);
obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime()));
obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize()));
}

4
src/rpc/pbaasrpc.cpp

@ -6488,8 +6488,8 @@ UniValue sendcurrency(const UniValue& params, bool fHelp)
std::vector<CRecipient> outputs;
std::set<libzcash::PaymentAddress> zaddrDestSet;
LOCK2(cs_main, mempool.cs);
LOCK(pwalletMain->cs_wallet);
LOCK2(cs_main, pwalletMain->cs_wallet);
LOCK(mempool.cs);
libzcash::PaymentAddress zaddress;
bool hasZSource = !wildCardAddress && pwalletMain->GetAndValidateSaplingZAddress(sourceAddress, zaddress);

Loading…
Cancel
Save