pub struct AsyncReceiveOfferCache { /* private fields */ }Expand description
If we are an often-offline recipient, we’ll want to interactively build offers and static invoices with an always-online node that will serve those static invoices to payers on our behalf when we are offline.
This struct is used to cache those interactively built offers, and should be passed into
OffersMessageFlow on startup as well as persisted whenever an offer or invoice is updated.
§Lifecycle of a cached offer
- On initial startup, recipients will request offer paths from the static invoice server
- Once a set of offer paths is received, recipients will build an offer and corresponding static invoice, cache the offer as pending, and send the invoice to the server for persistence
- Once the invoice is confirmed as persisted by the server, the recipient will mark the corresponding offer as ready to receive payments
- If the offer is later returned to the user, it will be kept cached and its invoice will be kept up-to-date until the offer expires
- If the offer does not get returned to the user within a certain timeframe, it will be replaced with a new one using fresh offer paths requested from the static invoice server
§Staying in sync with the Static Invoice Server
- Pending offers: for a given cached offer where a corresponding invoice is not yet confirmed as persisted by the static invoice server, we will retry persisting an invoice for that offer until it succeeds, once per timer tick
- Confirmed offers that have not yet been returned to the user: we will periodically replace an unused confirmed offer with a new one, to try to always have a fresh offer available. We wait several hours in between replacements to ensure the new offer replacement doesn’t conflict with the old one
- Confirmed offers that have been returned to the user: we will send the server a fresh invoice corresponding to each used offer once per timer tick until the offer expires
Implementations§
Source§impl AsyncReceiveOfferCache
impl AsyncReceiveOfferCache
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty AsyncReceiveOfferCache to be passed into OffersMessageFlow.
Trait Implementations§
Source§impl Readable for AsyncReceiveOfferCache
impl Readable for AsyncReceiveOfferCache
Source§impl Writeable for AsyncReceiveOfferCache
impl Writeable for AsyncReceiveOfferCache
Auto Trait Implementations§
impl Freeze for AsyncReceiveOfferCache
impl RefUnwindSafe for AsyncReceiveOfferCache
impl Send for AsyncReceiveOfferCache
impl Sync for AsyncReceiveOfferCache
impl Unpin for AsyncReceiveOfferCache
impl UnwindSafe for AsyncReceiveOfferCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> LengthReadable for Twhere
T: Readable,
impl<T> LengthReadable for Twhere
T: Readable,
Source§fn read_from_fixed_length_buffer<R>(reader: &mut R) -> Result<T, DecodeError>where
R: LengthLimitedRead,
fn read_from_fixed_length_buffer<R>(reader: &mut R) -> Result<T, DecodeError>where
R: LengthLimitedRead,
Reads a
Self in from the given LengthLimitedRead.