Documentation ¶
Index ¶
- Constants
- Variables
- func MigrateChannelMaxHeights(tx kvdb.RwTx) error
- func ReadElement(r io.Reader, element interface{}) error
- func ReadElements(r io.Reader, elements ...interface{}) error
- func UseLogger(logger btclog.Logger)
- func WriteElement(w io.Writer, element interface{}) error
- func WriteElements(w io.Writer, elements ...interface{}) error
- type BackupID
- type BreachHint
- type ChannelID
- type CommittedUpdate
- type CommittedUpdateBody
- type KVStore
- type RangeIndex
- type RangeIndexOption
- type SessionID
Constants ¶
const BreachHintSize = 16
BreachHintSize is the length of the identifier used to detect remote commitment broadcasts.
const SessionIDSize = 33
SessionIDSize is 33-bytes; it is a serialized, compressed public key.
Variables ¶
var ( // ErrUninitializedDB signals that top-level buckets for the database // have not been initialized. ErrUninitializedDB = errors.New("db not initialized") )
Functions ¶
func MigrateChannelMaxHeights ¶
MigrateChannelMaxHeights migrates the tower client db by collecting all the max commitment heights that have been backed up for each channel and then storing those heights alongside the channel info.
func ReadElement ¶
ReadElement deserializes a single element from the provided io.Reader.
func ReadElements ¶
ReadElements deserializes the provided io.Reader into a variadic list of target elements.
func WriteElement ¶
WriteElement serializes a single element into the provided io.Writer.
func WriteElements ¶
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.
type BreachHint ¶
type BreachHint [BreachHintSize]byte
BreachHint is the first 16-bytes of SHA256(txid), which is used to identify the breach transaction.
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.
type CommittedUpdate ¶
type CommittedUpdate struct { // SeqNum is the unique sequence number allocated by the session to this // update. SeqNum uint16 CommittedUpdateBody }
CommittedUpdate holds a state update sent by a client along with its allocated sequence number and the exact remote commitment the encrypted justice transaction can rectify.
type CommittedUpdateBody ¶
type CommittedUpdateBody struct { // BackupID identifies the breached commitment that the encrypted blob // can spend from. BackupID BackupID // Hint is the 16-byte prefix of the revoked commitment transaction ID. Hint BreachHint // EncryptedBlob is a ciphertext containing the sweep information for // exacting justice if the commitment transaction matching the breach // hint is broadcast. EncryptedBlob []byte }
CommittedUpdateBody represents the primary components of a CommittedUpdate. On disk, this is stored under the sequence number, which acts as its key.
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.