Token "generating" -> "persisting" -> "redeeming" occurs repeatedly for the same voucher code
Created by: crwood
After injecting a voucher code into a ZKAPAuthorizer-enabled tahoe client, I observe via tahoe run
s stdout that ZKAPAuthorizer is attempting to regenerate new tokens for the given voucher every three minutes as follows:
>>> 2020-03-11T12:51:08-0400 [_zkapauthorizer.resource._VoucherCollection#info] Accepting a voucher (MvQK7iCI5F07iGax92jgo-LMBtJ_DNbEn-pbsxRcSwOE) for redemption.
>>> 2020-03-11T12:51:08-0400 [_zkapauthorizer.controller.PaymentController#info] Generating random tokens for a voucher (MvQK7iCI5F07iGax92jgo-LMBtJ_DNbEn-pbsxRcSwOE).
>>> 2020-03-11T12:51:14-0400 [_zkapauthorizer.controller.PaymentController#info] Persisting random tokens for a voucher (MvQK7iCI5F07iGax92jgo-LMBtJ_DNbEn-pbsxRcSwOE).
>>> 2020-03-11T12:51:19-0400 [_zkapauthorizer.controller.PaymentController#info] Redeeming random tokens for a voucher (MvQK7iCI5F07iGax92jgo-LMBtJ_DNbEn-pbsxRcSwOE).
>>> 2020-03-11T12:52:02-0400 [twisted.web.client._HTTP11ClientFactory#info] Starting factory _HTTP11ClientFactory(<function quiescentCallback at 0x7a4ff1f073d0>, <twisted.internet.endpoints._WrapperEndpoint object at 0x7a4ff206a750>)
>>> 2020-03-11T12:52:06-0400 [_zkapauthorizer.controller.PaymentController#error] Voucher MvQK7iCI5F07iGax92jgo-LMBtJ_DNbEn-pbsxRcSwOE reported as not paid for during redemption.
>>> 2020-03-11T12:52:06-0400 [twisted.web.client._HTTP11ClientFactory#info] Stopping factory _HTTP11ClientFactory(<function quiescentCallback at 0x7a4ff1f073d0>, <twisted.internet.endpoints._WrapperEndpoint object at 0x7a4ff206a750>)
>>> 2020-03-11T12:54:05-0400 [_zkapauthorizer.controller.PaymentController#info] Generating random tokens for a voucher (MvQK7iCI5F07iGax92jgo-LMBtJ_DNbEn-pbsxRcSwOE).
>>> 2020-03-11T12:54:11-0400 [_zkapauthorizer.controller.PaymentController#info] Persisting random tokens for a voucher (MvQK7iCI5F07iGax92jgo-LMBtJ_DNbEn-pbsxRcSwOE).
>>> 2020-03-11T12:54:11-0400 [_zkapauthorizer.controller.PaymentController#info] Redeeming random tokens for a voucher (MvQK7iCI5F07iGax92jgo-LMBtJ_DNbEn-pbsxRcSwOE).
>>> 2020-03-11T12:54:51-0400 [twisted.web.client._HTTP11ClientFactory#info] Starting factory _HTTP11ClientFactory(<function quiescentCallback at 0x7a4ff1f21b50>, <twisted.internet.endpoints._WrapperEndpoint object at 0x7a4ff80fccd0>)
>>> 2020-03-11T12:54:56-0400 [_zkapauthorizer.controller.PaymentController#error] Voucher MvQK7iCI5F07iGax92jgo-LMBtJ_DNbEn-pbsxRcSwOE reported as not paid for during redemption.
>>> 2020-03-11T12:54:56-0400 [twisted.web.client._HTTP11ClientFactory#info] Stopping factory _HTTP11ClientFactory(<function quiescentCallback at 0x7a4ff1f21b50>, <twisted.internet.endpoints._WrapperEndpoint object at 0x7a4ff80fccd0>)
>>> 2020-03-11T12:57:05-0400 [_zkapauthorizer.controller.PaymentController#info] Generating random tokens for a voucher (MvQK7iCI5F07iGax92jgo-LMBtJ_DNbEn-pbsxRcSwOE).
>>> 2020-03-11T12:57:11-0400 [_zkapauthorizer.controller.PaymentController#info] Persisting random tokens for a voucher (MvQK7iCI5F07iGax92jgo-LMBtJ_DNbEn-pbsxRcSwOE).
>>> 2020-03-11T12:57:11-0400 [_zkapauthorizer.controller.PaymentController#info] Redeeming random tokens for a voucher (MvQK7iCI5F07iGax92jgo-LMBtJ_DNbEn-pbsxRcSwOE).
>>> 2020-03-11T12:57:51-0400 [twisted.web.client._HTTP11ClientFactory#info] Starting factory _HTTP11ClientFactory(<function quiescentCallback at 0x7a4ff1f21c50>, <twisted.internet.endpoints._WrapperEndpoint object at 0x7a4ff20fdcd0>)
>>> 2020-03-11T12:57:55-0400 [_zkapauthorizer.controller.PaymentController#error] Voucher MvQK7iCI5F07iGax92jgo-LMBtJ_DNbEn-pbsxRcSwOE reported as not paid for during redemption.
>>> 2020-03-11T12:57:55-0400 [twisted.web.client._HTTP11ClientFactory#info] Stopping factory _HTTP11ClientFactory(<function quiescentCallback at 0x7a4ff1f21c50>, <twisted.internet.endpoints._WrapperEndpoint object at 0x7a4ff20fdcd0>)
Because this operation is rather CPU intensive, resources here should perhaps be used more efficiently, e.g., by having the redemption process attempt re-use previously-generated tokens prior to generating new ones.