shards

package
v0.16.3-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PaymentShard

type PaymentShard interface {
	// Hash returns the hash used for the HTLC representing this shard.
	Hash() lntypes.Hash

	// MPP returns any extra MPP records that should be set for the final
	// hop on the route used by this shard.
	MPP() *record.MPP

	// AMP returns any extra AMP records that should be set for the final
	// hop on the route used by this shard.
	AMP() *record.AMP
}

PaymentShard is an interface representing a shard tracked by the ShardTracker. It contains options that are specific to the given shard that might differ from the overall payment.

type Shard

type Shard struct {
	// contains filtered or unexported fields
}

Shard is a struct used for simple shards where we only need to keep map it to a single hash.

func (*Shard) AMP

func (s *Shard) AMP() *record.AMP

AMP returns any extra AMP records that should be set for the final hop on the route used by this shard.

func (*Shard) Hash

func (s *Shard) Hash() lntypes.Hash

Hash returns the hash used for the HTLC representing this shard.

func (*Shard) MPP

func (s *Shard) MPP() *record.MPP

MPP returns any extra MPP records that should be set for the final hop on the route used by this shard.

type ShardTracker

type ShardTracker interface {
	// NewShard registers a new attempt with the ShardTracker and returns a
	// new shard representing this attempt. This attempt's shard should be
	// canceled if it ends up not being used by the overall payment, i.e.
	// if the attempt fails.
	NewShard(uint64, bool) (PaymentShard, error)

	// CancelShard cancel's the shard corresponding to the given attempt
	// ID. This lets the ShardTracker free up any slots used by this shard,
	// and in case of AMP payments return the share used by this shard to
	// the root share.
	CancelShard(uint64) error

	// GetHash retrieves the hash used by the shard of the given attempt
	// ID. This will return an error if the attempt ID is unknown.
	GetHash(uint64) (lntypes.Hash, error)
}

ShardTracker is an interface representing a tracker that keeps track of the inflight shards of a payment, and is able to assign new shards the correct options such as hash and extra records.

func NewSimpleShardTracker

func NewSimpleShardTracker(paymentHash lntypes.Hash,
	shards map[uint64]lntypes.Hash) ShardTracker

NewSimpleShardTracker creates a new instance of the SimpleShardTracker with the given payment hash and existing attempts.

type SimpleShardTracker

type SimpleShardTracker struct {
	sync.Mutex
	// contains filtered or unexported fields
}

SimpleShardTracker is an implementation of the ShardTracker interface that simply maps attempt IDs to hashes. New shards will be given a static payment hash. This should be used for regular and MPP payments, in addition to resumed payments where all the attempt's hashes have already been created.

func (*SimpleShardTracker) CancelShard

func (m *SimpleShardTracker) CancelShard(id uint64) error

CancelShard cancel's the shard corresponding to the given attempt ID.

func (*SimpleShardTracker) GetHash

func (m *SimpleShardTracker) GetHash(id uint64) (lntypes.Hash, error)

GetHash retrieves the hash used by the shard of the given attempt ID. This will return an error if the attempt ID is unknown.

func (*SimpleShardTracker) NewShard

func (m *SimpleShardTracker) NewShard(id uint64, _ bool) (PaymentShard, error)

NewShard registers a new attempt with the ShardTracker and returns a new shard representing this attempt. This attempt's shard should be canceled if it ends up not being used by the overall payment, i.e. if the attempt fails.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL