Store the migration operation id rather than the operation iteslf
This commit is contained in:
parent
7cf4749d0d
commit
d48c3efca7
|
@ -191,6 +191,10 @@ libzcash::SaplingPaymentAddress AsyncRPCOperation_saplingmigration::getMigration
|
|||
return toAddress;
|
||||
}
|
||||
|
||||
void AsyncRPCOperation_saplingmigration::cancel() {
|
||||
set_state(OperationStatus::CANCELLED);
|
||||
}
|
||||
|
||||
UniValue AsyncRPCOperation_saplingmigration::getStatus() const {
|
||||
UniValue v = AsyncRPCOperation::getStatus();
|
||||
UniValue obj = v.get_obj();
|
||||
|
|
|
@ -20,6 +20,8 @@ public:
|
|||
|
||||
virtual void main();
|
||||
|
||||
virtual void cancel();
|
||||
|
||||
virtual UniValue getStatus() const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -603,17 +603,20 @@ void CWallet::RunSaplingMigration(int blockHeight) {
|
|||
// height N, implementations SHOULD start generating the transactions at around
|
||||
// height N-5
|
||||
if (blockHeight % 500 == 495) {
|
||||
if (saplingMigrationOperation != nullptr) {
|
||||
saplingMigrationOperation->cancel();
|
||||
std::shared_ptr<AsyncRPCQueue> q = getAsyncRPCQueue();
|
||||
std::shared_ptr<AsyncRPCOperation> lastOperation = q->popOperationForId(saplingMigrationOperationId);
|
||||
if (lastOperation != nullptr) {
|
||||
lastOperation->cancel();
|
||||
}
|
||||
pendingSaplingMigrationTxs.clear();
|
||||
std::shared_ptr<AsyncRPCQueue> q = getAsyncRPCQueue();
|
||||
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_saplingmigration(blockHeight + 5));
|
||||
saplingMigrationOperation = operation;
|
||||
saplingMigrationOperationId = operation->getId();
|
||||
q->addOperation(operation);
|
||||
} else if (blockHeight % 500 == 499) {
|
||||
if (saplingMigrationOperation != nullptr) {
|
||||
saplingMigrationOperation->cancel();
|
||||
std::shared_ptr<AsyncRPCQueue> q = getAsyncRPCQueue();
|
||||
std::shared_ptr<AsyncRPCOperation> lastOperation = q->popOperationForId(saplingMigrationOperationId);
|
||||
if (lastOperation != nullptr) {
|
||||
lastOperation->cancel();
|
||||
}
|
||||
for (const CTransaction& transaction : pendingSaplingMigrationTxs) {
|
||||
// The following is taken from z_sendmany/z_mergetoaddress
|
||||
|
|
|
@ -757,7 +757,7 @@ private:
|
|||
TxNullifiers mapTxSaplingNullifiers;
|
||||
|
||||
std::vector<CTransaction> pendingSaplingMigrationTxs;
|
||||
std::shared_ptr<AsyncRPCOperation> saplingMigrationOperation = nullptr;
|
||||
AsyncRPCOperationId saplingMigrationOperationId;
|
||||
|
||||
void AddToTransparentSpends(const COutPoint& outpoint, const uint256& wtxid);
|
||||
void AddToSproutSpends(const uint256& nullifier, const uint256& wtxid);
|
||||
|
|
Loading…
Reference in New Issue