Skip to content

Commit

Permalink
[rpc] AsyncRPCOperation: pwallet_ -> m_pwallet
Browse files Browse the repository at this point in the history
  • Loading branch information
ch4ot1c authored and Jon Layton committed Jul 15, 2018
1 parent abb201c commit c9e785d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions src/asyncrpcoperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ std::map<OperationStatus, std::string> OperationStatusMap = {
* Every operation instance should have a globally unique id
*/
AsyncRPCOperation::AsyncRPCOperation(std::shared_ptr<CWallet> const wallet) :
pwallet_(wallet), error_code_(0), error_message_()
m_pwallet(wallet), error_code_(0), error_message_()
{
// Set a unique reference for each operation
boost::uuids::uuid uuid = uuidgen();
Expand All @@ -39,7 +39,7 @@ AsyncRPCOperation::AsyncRPCOperation(std::shared_ptr<CWallet> const wallet) :
}

AsyncRPCOperation::AsyncRPCOperation(const AsyncRPCOperation& o) :
pwallet_(o.pwallet_),
m_pwallet(o.m_pwallet),
id_(o.id_), creation_time_(o.creation_time_), state_(o.state_.load()),
start_time_(o.start_time_), end_time_(o.end_time_),
error_code_(o.error_code_), error_message_(o.error_message_),
Expand All @@ -48,7 +48,7 @@ AsyncRPCOperation::AsyncRPCOperation(const AsyncRPCOperation& o) :
}

AsyncRPCOperation& AsyncRPCOperation::operator=( const AsyncRPCOperation& other ) {
this->pwallet_ = other.pwallet_;
this->m_pwallet = other.m_pwallet;
this->id_ = other.id_;
this->creation_time_ = other.creation_time_;
this->state_.store(other.state_.load());
Expand Down
2 changes: 1 addition & 1 deletion src/asyncrpcoperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class AsyncRPCOperation {
std::chrono::time_point<std::chrono::system_clock> start_time_, end_time_;

// Wallet of interest for this operation
std::shared_ptr<CWallet> pwallet_;
std::shared_ptr<CWallet> m_pwallet;

void start_execution_clock();
void stop_execution_clock();
Expand Down
28 changes: 14 additions & 14 deletions src/wallet/asyncrpcoperation_mergetoaddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,13 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
// change upon arrival of new blocks which contain joinsplit transactions. This is likely
// to happen as creating a chained joinsplit transaction can take longer than the block interval.
{
LOCK2(cs_main, pwallet_->cs_wallet);
LOCK2(cs_main, m_pwallet->cs_wallet);
for (auto t : noteInputs_) {
JSOutPoint jso = std::get<0>(t);
std::vector<JSOutPoint> vOutPoints = {jso};
uint256 inputAnchor;
std::vector<boost::optional<ZCIncrementalWitness>> vInputWitnesses;
pwallet_->GetNoteWitnesses(vOutPoints, vInputWitnesses, inputAnchor);
m_pwallet->GetNoteWitnesses(vOutPoints, vInputWitnesses, inputAnchor);
jsopWitnessAnchorMap[jso.ToString()] = MergeToAddressWitnessAnchorData{vInputWitnesses[0], inputAnchor};
}
}
Expand Down Expand Up @@ -422,7 +422,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
// Consume change as the first input of the JoinSplit.
//
if (jsChange > 0) {
LOCK2(cs_main, pwallet_->cs_wallet);
LOCK2(cs_main, m_pwallet->cs_wallet);

// Update tree state with previous joinsplit
ZCIncrementalMerkleTree tree;
Expand Down Expand Up @@ -512,8 +512,8 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
int wtxHeight = -1;
int wtxDepth = -1;
{
LOCK2(cs_main, pwallet_->cs_wallet);
const CWalletTx& wtx = pwallet_->mapWallet[jso.hash];
LOCK2(cs_main, m_pwallet->cs_wallet);
const CWalletTx& wtx = m_pwallet->mapWallet[jso.hash];
// Zero confirmation notes belong to transactions which have not yet been mined
if (mapBlockIndex.find(wtx.hashBlock) == mapBlockIndex.end()) {
throw JSONRPCError(RPC_WALLET_ERROR, strprintf("mapBlockIndex does not contain block hash %s", wtx.hashBlock.ToString()));
Expand Down Expand Up @@ -705,7 +705,7 @@ UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit(MergeToAddressJSInf
uint256 anchor;
{
LOCK(cs_main);
pwallet_->GetNoteWitnesses(outPoints, witnesses, anchor);
m_pwallet->GetNoteWitnesses(outPoints, witnesses, anchor);
}
return perform_joinsplit(info, witnesses, anchor);
}
Expand Down Expand Up @@ -915,19 +915,19 @@ UniValue AsyncRPCOperation_mergetoaddress::getStatus() const
* Lock input utxos
*/
void AsyncRPCOperation_mergetoaddress::lock_utxos() {
LOCK2(cs_main, pwallet_->cs_wallet);
LOCK2(cs_main, m_pwallet->cs_wallet);
for (auto utxo : utxoInputs_) {
pwallet_->LockCoin(std::get<0>(utxo));
m_pwallet->LockCoin(std::get<0>(utxo));
}
}

/**
* Unlock input utxos
*/
void AsyncRPCOperation_mergetoaddress::unlock_utxos() {
LOCK2(cs_main, pwallet_->cs_wallet);
LOCK2(cs_main, m_pwallet->cs_wallet);
for (auto utxo : utxoInputs_) {
pwallet_->UnlockCoin(std::get<0>(utxo));
m_pwallet->UnlockCoin(std::get<0>(utxo));
}
}

Expand All @@ -936,18 +936,18 @@ void AsyncRPCOperation_mergetoaddress::unlock_utxos() {
* Lock input notes
*/
void AsyncRPCOperation_mergetoaddress::lock_notes() {
LOCK2(cs_main, pwallet_->cs_wallet);
LOCK2(cs_main, m_pwallet->cs_wallet);
for (auto note : noteInputs_) {
pwallet_->LockNote(std::get<0>(note));
m_pwallet->LockNote(std::get<0>(note));
}
}

/**
* Unlock input notes
*/
void AsyncRPCOperation_mergetoaddress::unlock_notes() {
LOCK2(cs_main, pwallet_->cs_wallet);
LOCK2(cs_main, m_pwallet->cs_wallet);
for (auto note : noteInputs_) {
pwallet_->UnlockNote(std::get<0>(note));
m_pwallet->UnlockNote(std::get<0>(note));
}
}
26 changes: 13 additions & 13 deletions src/wallet/asyncrpcoperation_sendmany.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ AsyncRPCOperation_sendmany::AsyncRPCOperation_sendmany(

// We don't need to lock on the wallet as spending key related methods are thread-safe
SpendingKey key;
if (!pwallet_->GetSpendingKey(addr, key)) {
if (!m_pwallet->GetSpendingKey(addr, key)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid from address, no spending key found for zaddr");
}

Expand Down Expand Up @@ -407,13 +407,13 @@ bool AsyncRPCOperation_sendmany::main_impl() {
// change upon arrival of new blocks which contain joinsplit transactions. This is likely
// to happen as creating a chained joinsplit transaction can take longer than the block interval.
if (z_inputs_.size() > 0) {
LOCK2(cs_main, pwallet_->cs_wallet);
LOCK2(cs_main, m_pwallet->cs_wallet);
for (auto t : z_inputs_) {
JSOutPoint jso = std::get<0>(t);
std::vector<JSOutPoint> vOutPoints = { jso };
uint256 inputAnchor;
std::vector<boost::optional<ZCIncrementalWitness>> vInputWitnesses;
pwallet_->GetNoteWitnesses(vOutPoints, vInputWitnesses, inputAnchor);
m_pwallet->GetNoteWitnesses(vOutPoints, vInputWitnesses, inputAnchor);
jsopWitnessAnchorMap[ jso.ToString() ] = WitnessAnchorData{ vInputWitnesses[0], inputAnchor };
}
}
Expand Down Expand Up @@ -538,7 +538,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
// Consume change as the first input of the JoinSplit.
//
if (jsChange > 0) {
LOCK2(cs_main, pwallet_->cs_wallet);
LOCK2(cs_main, m_pwallet->cs_wallet);

// Update tree state with previous joinsplit
ZCIncrementalMerkleTree tree;
Expand Down Expand Up @@ -625,8 +625,8 @@ bool AsyncRPCOperation_sendmany::main_impl() {
int wtxHeight = -1;
int wtxDepth = -1;
{
LOCK2(cs_main, pwallet_->cs_wallet);
const CWalletTx& wtx = pwallet_->mapWallet[jso.hash];
LOCK2(cs_main, m_pwallet->cs_wallet);
const CWalletTx& wtx = m_pwallet->mapWallet[jso.hash];
// Zero-confirmation notes belong to transactions which have not yet been mined
if (mapBlockIndex.find(wtx.hashBlock) == mapBlockIndex.end()) {
throw JSONRPCError(RPC_WALLET_ERROR, strprintf("mapBlockIndex does not contain block hash %s", wtx.hashBlock.ToString()));
Expand Down Expand Up @@ -832,9 +832,9 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) {
set<CBitcoinAddress> setAddress = {fromtaddr_};
vector<COutput> vecOutputs;

LOCK2(cs_main, pwallet_->cs_wallet);
LOCK2(cs_main, m_pwallet->cs_wallet);

pwallet_->AvailableCoins(vecOutputs, false, NULL, true, fAcceptCoinbase);
m_pwallet->AvailableCoins(vecOutputs, false, NULL, true, fAcceptCoinbase);

BOOST_FOREACH(const COutput& out, vecOutputs) {
if (!out.fSpendable) {
Expand Down Expand Up @@ -879,8 +879,8 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) {
bool AsyncRPCOperation_sendmany::find_unspent_notes() {
std::vector<CNotePlaintextEntry> entries;
{
LOCK2(cs_main, pwallet_->cs_wallet);
pwallet_->GetFilteredNotes(entries, fromaddress_, mindepth_);
LOCK2(cs_main, m_pwallet->cs_wallet);
m_pwallet->GetFilteredNotes(entries, fromaddress_, mindepth_);
}

for (CNotePlaintextEntry & entry : entries) {
Expand Down Expand Up @@ -924,7 +924,7 @@ UniValue AsyncRPCOperation_sendmany::perform_joinsplit(AsyncJoinSplitInfo & info
uint256 anchor;
{
LOCK(cs_main);
pwallet_->GetNoteWitnesses(outPoints, witnesses, anchor);
m_pwallet->GetNoteWitnesses(outPoints, witnesses, anchor);
}
return perform_joinsplit(info, witnesses, anchor);
}
Expand Down Expand Up @@ -1117,10 +1117,10 @@ void AsyncRPCOperation_sendmany::add_taddr_outputs_to_tx() {

void AsyncRPCOperation_sendmany::add_taddr_change_output_to_tx(CAmount amount) {

LOCK2(cs_main, pwallet_->cs_wallet);
LOCK2(cs_main, m_pwallet->cs_wallet);

EnsureWalletIsUnlocked();
CReserveKey keyChange(pwallet_);
CReserveKey keyChange(m_pwallet);
CPubKey vchPubKey;
bool ret = keyChange.GetReservedKey(vchPubKey);
if (!ret) {
Expand Down
8 changes: 4 additions & 4 deletions src/wallet/asyncrpcoperation_shieldcoinbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,20 +484,20 @@ UniValue AsyncRPCOperation_shieldcoinbase::getStatus() const {
* Lock input utxos
*/
void AsyncRPCOperation_shieldcoinbase::lock_utxos() {
LOCK2(cs_main, pwallet_->cs_wallet);
LOCK2(cs_main, m_pwallet->cs_wallet);
for (auto utxo : inputs_) {
COutPoint outpt(utxo.txid, utxo.vout);
pwallet_->LockCoin(outpt);
m_pwallet->LockCoin(outpt);
}
}

/**
* Unlock input utxos
*/
void AsyncRPCOperation_shieldcoinbase::unlock_utxos() {
LOCK2(cs_main, pwallet_->cs_wallet);
LOCK2(cs_main, m_pwallet->cs_wallet);
for (auto utxo : inputs_) {
COutPoint outpt(utxo.txid, utxo.vout);
pwallet_->UnlockCoin(outpt);
m_pwallet->UnlockCoin(outpt);
}
}

0 comments on commit c9e785d

Please sign in to comment.