pub struct NodeState {
pub invoices: Map<PaymentHash, PaymentState>,
pub issued_invoices: Map<PaymentHash, PaymentState>,
pub payments: Map<PaymentHash, RoutedPayment>,
pub excess_amount: u64,
pub log_prefix: String,
pub velocity_control: VelocityControl,
pub fee_velocity_control: VelocityControl,
pub last_summary: String,
pub dbid_high_water_mark: u64,
}
Expand description
Enforcement state for a node
Fields§
§invoices: Map<PaymentHash, PaymentState>
Added invoices for outgoing payments indexed by their payment hash
issued_invoices: Map<PaymentHash, PaymentState>
Issued invoices for incoming payments indexed by their payment hash
payments: Map<PaymentHash, RoutedPayment>
Payment states. There is one entry for each invoice. Entries also exist for HTLCs we route.
excess_amount: u64
Accumulator of excess payment amount in satoshi, for tracking certain payment corner cases. If this falls below zero, the attempted commit is failed.
log_prefix: String
Prefix for emitted logs lines
velocity_control: VelocityControl
Per node velocity control
fee_velocity_control: VelocityControl
Per node fee velocity control
last_summary: String
Last summary string
dbid_high_water_mark: u64
dbid high water mark
Implementations§
Source§impl NodeState
impl NodeState
Sourcepub fn new(
velocity_control: VelocityControl,
fee_velocity_control: VelocityControl,
) -> Self
pub fn new( velocity_control: VelocityControl, fee_velocity_control: VelocityControl, ) -> Self
Create a state
Sourcepub fn restore(
invoices_v: Vec<(Vec<u8>, PaymentState)>,
issued_invoices_v: Vec<(Vec<u8>, PaymentState)>,
preimages: Vec<[u8; 32]>,
excess_amount: u64,
velocity_control: VelocityControl,
fee_velocity_control: VelocityControl,
dbid_high_water_mark: u64,
) -> Self
pub fn restore( invoices_v: Vec<(Vec<u8>, PaymentState)>, issued_invoices_v: Vec<(Vec<u8>, PaymentState)>, preimages: Vec<[u8; 32]>, excess_amount: u64, velocity_control: VelocityControl, fee_velocity_control: VelocityControl, dbid_high_water_mark: u64, ) -> Self
Restore a state from persistence
Sourcepub fn summary(&mut self) -> (String, bool)
pub fn summary(&mut self) -> (String, bool)
Return a summary for debugging and whether it changed since last call
Sourcepub fn validate_payments(
&self,
channel_id: &ChannelId,
incoming_payment_summary: &Map<PaymentHash, u64>,
outgoing_payment_summary: &Map<PaymentHash, u64>,
balance_delta: &BalanceDelta,
validator: Arc<dyn Validator>,
) -> Result<(), ValidationError>
pub fn validate_payments( &self, channel_id: &ChannelId, incoming_payment_summary: &Map<PaymentHash, u64>, outgoing_payment_summary: &Map<PaymentHash, u64>, balance_delta: &BalanceDelta, validator: Arc<dyn Validator>, ) -> Result<(), ValidationError>
Validate outgoing in-flight payment amounts as a result of a new commitment tx.
The following policies are checked:
- no overpayment for any invoice.
- Sends without invoices (e.g. keysend) are only allowed if
policy.require_invoices
is false.
The amounts are in satoshi.
Sourcepub fn apply_payments(
&mut self,
channel_id: &ChannelId,
incoming_payment_summary: &Map<PaymentHash, u64>,
outgoing_payment_summary: &Map<PaymentHash, u64>,
balance_delta: &BalanceDelta,
validator: Arc<dyn Validator>,
)
pub fn apply_payments( &mut self, channel_id: &ChannelId, incoming_payment_summary: &Map<PaymentHash, u64>, outgoing_payment_summary: &Map<PaymentHash, u64>, balance_delta: &BalanceDelta, validator: Arc<dyn Validator>, )
Apply outgoing in-flight payment amounts as a result of a new commitment tx. Must call NodeState::validate_payments first.
Sourcepub fn htlc_fulfilled(
&mut self,
channel_id: &ChannelId,
preimage: PaymentPreimage,
validator: Arc<dyn Validator>,
) -> bool
pub fn htlc_fulfilled( &mut self, channel_id: &ChannelId, preimage: PaymentPreimage, validator: Arc<dyn Validator>, ) -> bool
Fulfills an HTLC. Performs bookkeeping on any invoice or routed payment with this payment hash.
Trait Implementations§
Source§impl PreimageMap for NodeState
impl PreimageMap for NodeState
Source§fn has_preimage(&self, hash: &PaymentHash) -> bool
fn has_preimage(&self, hash: &PaymentHash) -> bool
Auto Trait Implementations§
impl Freeze for NodeState
impl RefUnwindSafe for NodeState
impl Send for NodeState
impl Sync for NodeState
impl Unpin for NodeState
impl UnwindSafe for NodeState
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> 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