pub struct SingleNodePayment {
pub quotes: [QuotePaymentInfo; 5],
}Expand description
Single node payment structure for a chunk.
Contains exactly CLOSE_GROUP_SIZE quotes where only the median-priced one
receives payment (3x), and the remaining quotes have Amount::ZERO.
The fixed-size array ensures compile-time enforcement of the quote count, making the median index always valid.
Fields§
§quotes: [QuotePaymentInfo; 5]All quotes (sorted by price) - fixed size ensures median index is always valid
Implementations§
Source§impl SingleNodePayment
impl SingleNodePayment
Sourcepub fn from_quotes(
quotes_with_prices: Vec<(PaymentQuote, Amount)>,
) -> Result<Self>
pub fn from_quotes( quotes_with_prices: Vec<(PaymentQuote, Amount)>, ) -> Result<Self>
Create a SingleNode payment from 5 quotes and their prices.
The quotes are automatically sorted by price (cheapest first).
The median (index 2) gets 3x its quote price.
The other 4 get Amount::ZERO.
§Arguments
quotes_with_prices- Vec of (PaymentQuote, Amount) tuples (will be sorted internally)
§Errors
Returns error if not exactly 5 quotes are provided.
Sourcepub fn total_amount(&self) -> Amount
pub fn total_amount(&self) -> Amount
Get the total payment amount (should be 3x median price)
Sourcepub fn paid_quote(&self) -> Option<&QuotePaymentInfo>
pub fn paid_quote(&self) -> Option<&QuotePaymentInfo>
Get the median quote that receives payment.
Returns None only if the internal array is somehow shorter than MEDIAN_INDEX,
which should never happen since the array is fixed-size [_; CLOSE_GROUP_SIZE].
Sourcepub async fn pay(&self, wallet: &Wallet) -> Result<Vec<TxHash>>
pub async fn pay(&self, wallet: &Wallet) -> Result<Vec<TxHash>>
Pay for all quotes on-chain using the wallet.
Pays 3x to the median quote and 0 to the other 4.
§Errors
Returns an error if the payment transaction fails.
Sourcepub async fn verify(
&self,
network: &EvmNetwork,
owned_quote_hash: Option<QuoteHash>,
) -> Result<Amount>
pub async fn verify( &self, network: &EvmNetwork, owned_quote_hash: Option<QuoteHash>, ) -> Result<Amount>
Verify all payments on-chain.
This checks that all 5 payments were recorded on the blockchain. The contract requires exactly 5 payment verifications.
§Arguments
network- The EVM network to verify onowned_quote_hash- Optional quote hash that this node owns (expects to receive payment)
§Returns
The total verified payment amount received by owned quotes.
§Errors
Returns an error if verification fails or payment is invalid.
Trait Implementations§
Source§impl Clone for SingleNodePayment
impl Clone for SingleNodePayment
Source§fn clone(&self) -> SingleNodePayment
fn clone(&self) -> SingleNodePayment
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SingleNodePayment
impl RefUnwindSafe for SingleNodePayment
impl Send for SingleNodePayment
impl Sync for SingleNodePayment
impl Unpin for SingleNodePayment
impl UnsafeUnpin for SingleNodePayment
impl UnwindSafe for SingleNodePayment
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more