Struct AsyncReceiveOfferCache

Source
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

  1. On initial startup, recipients will request offer paths from the static invoice server
  2. 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
  3. Once the invoice is confirmed as persisted by the server, the recipient will mark the corresponding offer as ready to receive payments
  4. 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
  5. 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

Source

pub fn new() -> Self

Creates an empty AsyncReceiveOfferCache to be passed into OffersMessageFlow.

Trait Implementations§

Source§

impl Readable for AsyncReceiveOfferCache

Source§

fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError>

Reads a Self in from the given Read.
Source§

impl Writeable for AsyncReceiveOfferCache

Source§

fn write<W: Writer>(&self, w: &mut W) -> Result<(), Error>

Writes self out to the given Writer.
Source§

fn encode(&self) -> Vec<u8>

Writes self out to a Vec<u8>.
Source§

fn serialized_length(&self) -> usize

Gets the length of this object after it has been serialized. This can be overridden to optimize cases where we prepend an object with its length.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> LengthReadable for T
where T: Readable,

Source§

fn read_from_fixed_length_buffer<R>(reader: &mut R) -> Result<T, DecodeError>

Reads a Self in from the given LengthLimitedRead.
Source§

impl<T> MaybeReadable for T
where T: Readable,

Source§

fn read<R>(reader: &mut R) -> Result<Option<T>, DecodeError>
where R: Read,

Reads a Self in from the given Read.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V