migration4

package
v0.16.2-beta Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSessionsPerTx = 5000

DefaultSessionsPerTx is the default number of sessions that should be migrated per db transaction.

View Source
const SessionIDSize = 33

SessionIDSize is 33-bytes; it is a serialized, compressed public key.

Variables

View Source
var (

	// ErrUninitializedDB signals that top-level buckets for the database
	// have not been initialized.
	ErrUninitializedDB = errors.New("db not initialized")

	// ErrClientSessionNotFound signals that the requested client session
	// was not found in the database.
	ErrClientSessionNotFound = errors.New("client session not found")

	// ErrCorruptChanDetails signals that the clients channel detail's
	// on-disk structure deviates from what is expected.
	ErrCorruptChanDetails = errors.New("channel details corrupted")

	// ErrChannelNotRegistered signals a channel has not yet been registered
	// in the client database.
	ErrChannelNotRegistered = errors.New("channel not registered")
)

Functions

func MigrateAckedUpdates

func MigrateAckedUpdates(sessionsPerTx int) func(kvdb.Backend) error

MigrateAckedUpdates migrates the tower client DB. It takes the individual Acked Updates that are stored for each session and re-stores them using the RangeIndex representation.

func ReadElement

func ReadElement(r io.Reader, element interface{}) error

ReadElement deserializes a single element from the provided io.Reader.

func ReadElements

func ReadElements(r io.Reader, elements ...interface{}) error

ReadElements deserializes the provided io.Reader into a variadic list of target elements.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info.

func WriteElement

func WriteElement(w io.Writer, element interface{}) error

WriteElement serializes a single element into the provided io.Writer.

func WriteElements

func WriteElements(w io.Writer, elements ...interface{}) error

WriteElements serializes a variadic list of elements into the given io.Writer.

Types

type BackupID

type BackupID struct {
	// ChanID is the channel id of the revoked commitment.
	ChanID ChannelID

	// CommitHeight is the commitment height of the revoked commitment.
	CommitHeight uint64
}

BackupID identifies a particular revoked, remote commitment by channel id and commitment height.

func (*BackupID) Decode

func (b *BackupID) Decode(r io.Reader) error

Decode reads a BackupID from the passed io.Reader.

func (*BackupID) Encode

func (b *BackupID) Encode(w io.Writer) error

Encode writes the BackupID from the passed io.Writer.

func (BackupID) String

func (b BackupID) String() string

String returns a human-readable encoding of a BackupID.

type ChannelID

type ChannelID [32]byte

ChannelID is a series of 32-bytes that uniquely identifies all channels within the network. The ChannelID is computed using the outpoint of the funding transaction (the txid, and output index). Given a funding output the ChannelID can be calculated by XOR'ing the big-endian serialization of the txid and the big-endian serialization of the output index, truncated to 2 bytes.

func (ChannelID) String

func (c ChannelID) String() string

String returns the string representation of the ChannelID. This is just the hex string encoding of the ChannelID itself.

type KVStore

type KVStore interface {
	// Put saves the specified key/value pair to the store. Keys that do not
	// already exist are added and keys that already exist are overwritten.
	Put(key, value []byte) error

	// Delete removes the specified key from the bucket. Deleting a key that
	// does not exist does not return an error.
	Delete(key []byte) error
}

KVStore is an interface representing a key-value store.

type RangeIndex

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

RangeIndex can be used to keep track of which numbers have been added to a set. It does so by keeping track of a sorted list of rangeItems. Each rangeItem has a start and end value of a range where all values in-between have been added to the set. It works well in situations where it is expected numbers in the set are not sparse.

func NewRangeIndex

func NewRangeIndex(ranges map[uint64]uint64,
	opts ...RangeIndexOption) (*RangeIndex, error)

NewRangeIndex constructs a new RangeIndex. An initial set of ranges may be passed to the function in the form of a map.

func (*RangeIndex) Add

func (a *RangeIndex) Add(newHeight uint64, kv KVStore) error

Add adds a single number to the range set. It first attempts to apply the necessary changes to the passed KV store and then only if this succeeds, will the changes be applied to the in-memory structure.

func (*RangeIndex) GetAllRanges

func (a *RangeIndex) GetAllRanges() map[uint64]uint64

GetAllRanges returns a copy of the range set in the form of a map.

func (*RangeIndex) IsInIndex

func (a *RangeIndex) IsInIndex(n uint64) bool

IsInIndex returns true if the given number is in the range set.

func (*RangeIndex) MaxHeight

func (a *RangeIndex) MaxHeight() uint64

MaxHeight returns the highest number covered in the range.

func (*RangeIndex) NumInSet

func (a *RangeIndex) NumInSet() uint64

NumInSet returns the number of items covered by the range set.

type RangeIndexOption

type RangeIndexOption func(*RangeIndex)

RangeIndexOption describes the signature of a functional option that can be used to modify the behaviour of a RangeIndex.

func WithSerializeUint64Fn

func WithSerializeUint64Fn(fn func(uint64) ([]byte, error)) RangeIndexOption

WithSerializeUint64Fn is a functional option that can be used to set the function to be used to do the serialization of a uint64 into a byte slice.

type SessionID

type SessionID [SessionIDSize]byte

SessionID is created from the remote public key of a client, and serves as a unique identifier and authentication for sending state updates.

func (SessionID) String

func (s SessionID) String() string

String returns a hex encoding of the session id.

Jump to

Keyboard shortcuts

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