From 8e6927f90157e2c0065dfa9d8d7632e3c74073a4 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 19 Jul 2021 12:48:11 +0100 Subject: [PATCH] Document why a nested call to ExtractMinerAddress is not recursive --- src/miner.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/miner.h b/src/miner.h index 600de3b3b..9b76ec6ba 100644 --- a/src/miner.h +++ b/src/miner.h @@ -51,6 +51,16 @@ public: MinerAddress operator()(const libzcash::UnifiedAddress &addr) const { auto recipient = RecipientForPaymentAddress()(addr); if (recipient) { + // This looks like a recursive call, but we are actually calling + // ExtractMinerAddress with a different type: + // - libzcash::PaymentAddress has a libzcash::UnifiedAddress + // alternative, which invokes this method. + // - RecipientForPaymentAddress() returns libzcash::RawAddress, + // which does not have a libzcash::UnifiedAddress alternative. + // + // This works because std::visit does not require the visitor to + // solely match the std::variant, only that it can handle all of + // the variant's alternatives. return std::visit(ExtractMinerAddress(), *recipient); } else { // Either the UA only contains unknown shielded receivers (unlikely that we