Skip to content

Commit

Permalink
fix deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
CryptoForge committed May 12, 2021
1 parent af5e0ca commit bd3f73d
Showing 1 changed file with 50 additions and 23 deletions.
73 changes: 50 additions & 23 deletions src/wallet/rpcpiratewallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,32 @@ void getTransparentSpends(RpcTx &tx, vector<TransactionSpendT> &vSpend, CAmount
if (parentwtx != NULL) {
parentOut = parentwtx->vout[txin.prevout.n];
} else {
CTransaction parentctx;
uint256 hashBlock;
map<uint256, ArchiveTxPoint>::iterator it = pwalletMain->mapArcTxs.find(txin.prevout.hash);
if (it != pwalletMain->mapArcTxs.end()){

// Find the block it claims to be in
BlockMap::iterator mi = mapBlockIndex.find(txin.prevout.hash);
if (mi == mapBlockIndex.end()) {
return;
}
CBlockIndex* pindex = (*mi).second;
if (!pindex || !chainActive.Contains(pindex)) {
return;
}
CTransaction parentctx;
uint256 hashBlock;

//Get Tx from block
CBlock block;
ReadBlockFromDisk(block, pindex, 1);
// Find the block it claims to be in
BlockMap::iterator mi = mapBlockIndex.find(it->second.hashBlock);
if (mi == mapBlockIndex.end()) {
return;
}
CBlockIndex* pindex = (*mi).second;
if (!pindex || !chainActive.Contains(pindex)) {
return;
}

//Get Tx from block
CBlock block;
ReadBlockFromDisk(block, pindex, 1);

//Get Tx
for (int j = 0; j < block.vtx.size(); j++) {
if (txin.prevout.hash == block.vtx[j].GetHash()) {
parentctx = block.vtx[j];
parentOut = parentctx.vout[txin.prevout.n];
//Get Tx
for (int j = 0; j < block.vtx.size(); j++) {
if (txin.prevout.hash == block.vtx[j].GetHash()) {
parentctx = block.vtx[j];
parentOut = parentctx.vout[txin.prevout.n];
}
}
}
}
Expand Down Expand Up @@ -244,10 +248,33 @@ void getSaplingSpends(RpcTx &tx, std::set<uint256> &ivks, std::set<uint256> &ivk
if (parentwtx != NULL) {
output = parentwtx->vShieldedOutput[op.n];
} else {
CTransaction parentctx;
uint256 hashBlock;
if (GetTransaction(op.hash, parentctx, hashBlock, true)) {
output = parentctx.vShieldedOutput[op.n];
map<uint256, ArchiveTxPoint>::iterator it = pwalletMain->mapArcTxs.find(op.hash);
if (it != pwalletMain->mapArcTxs.end()){

CTransaction parentctx;
uint256 hashBlock;

// Find the block it claims to be in
BlockMap::iterator mi = mapBlockIndex.find(it->second.hashBlock);
if (mi == mapBlockIndex.end()) {
return;
}
CBlockIndex* pindex = (*mi).second;
if (!pindex || !chainActive.Contains(pindex)) {
return;
}

//Get Tx from block
CBlock block;
ReadBlockFromDisk(block, pindex, 1);

//Get Tx
for (int j = 0; j < block.vtx.size(); j++) {
if (op.hash == block.vtx[j].GetHash()) {
parentctx = block.vtx[j];
output = parentctx.vShieldedOutput[op.n];
}
}
}
}

Expand Down

0 comments on commit bd3f73d

Please sign in to comment.