keyvalue

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 17 Imported by: 4

Documentation

Overview

Package keyvalue contains an implementation of the channel persister interface using a keyvalue database interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelIterator

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

ChannelIterator implements the persistence.ChannelIterator interface.

func (*ChannelIterator) Channel

func (i *ChannelIterator) Channel() *persistence.Channel

Channel returns the iterator's current channel.

func (*ChannelIterator) Close

func (i *ChannelIterator) Close() error

Close closes the iterator and releases its resources. It returns the last error that occurred when advancing the iterator.

func (*ChannelIterator) Next

Next advances the iterator and returns whether there is another channel.

type PersistRestorer

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

PersistRestorer implements both the persister and the restorer interface using a sorted key-value store.

func NewPersistRestorer

func NewPersistRestorer(db sortedkv.Database) *PersistRestorer

NewPersistRestorer creates a new PersistRestorer for the supplied database.

func (*PersistRestorer) ActivePeers

func (pr *PersistRestorer) ActivePeers(ctx context.Context) ([]wire.Address, error)

ActivePeers returns a list of all peers with which a channel is persisted.

func (*PersistRestorer) ChannelCreated

func (pr *PersistRestorer) ChannelCreated(_ context.Context, s channel.Source, peers []wire.Address, parent *channel.ID) error

ChannelCreated inserts a channel into the database.

func (*PersistRestorer) ChannelRemoved

func (pr *PersistRestorer) ChannelRemoved(ctx context.Context, id channel.ID) error

ChannelRemoved deletes a channel from the database.

func (*PersistRestorer) Close

func (pr *PersistRestorer) Close() error

Close closes the PersistRestorer and releases all resources it holds.

func (*PersistRestorer) Enabled

func (pr *PersistRestorer) Enabled(_ context.Context, s channel.Source) error

Enabled persists the channel's staging and current transaction, and phase.

func (*PersistRestorer) PhaseChanged

func (pr *PersistRestorer) PhaseChanged(_ context.Context, s channel.Source) error

PhaseChanged persists the channel's phase.

func (*PersistRestorer) RestoreAll

func (pr *PersistRestorer) RestoreAll() (persistence.ChannelIterator, error)

RestoreAll should return an iterator over all persisted channels.

func (*PersistRestorer) RestoreChannel added in v0.4.0

func (pr *PersistRestorer) RestoreChannel(ctx context.Context, id channel.ID) (*persistence.Channel, error)

RestoreChannel restores a single channel.

func (*PersistRestorer) RestorePeer

func (pr *PersistRestorer) RestorePeer(addr wire.Address) (persistence.ChannelIterator, error)

RestorePeer should return an iterator over all persisted channels which the given peer is a part of.

func (*PersistRestorer) SigAdded

func (pr *PersistRestorer) SigAdded(_ context.Context, s channel.Source, idx channel.Index) error

SigAdded persists the channel's staging transaction.

func (*PersistRestorer) Staged

Staged persists the staging transaction as well as the channel's phase.

type PersistedState added in v0.4.0

type PersistedState struct {
	State **channel.State
}

PersistedState is a helper struct to allow for de-/encoding of empty states.

func (*PersistedState) Decode added in v0.4.0

func (s *PersistedState) Decode(r io.Reader) error

Decode reads a channel.State from an `io.Reader`.

func (PersistedState) Encode added in v0.4.0

func (s PersistedState) Encode(w io.Writer) error

Encode writes itself to a stream. If the stream fails, the underlying error is returned.

Jump to

Keyboard shortcuts

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