db

package
v0.1.0-alpha.0...-0b1224c Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2019 License: Apache-2.0, Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Update

func Update(db *bolt.DB, f func(*Root) error) error

Update opens a writable transaction and calls f with an instance of Root as the root bucket, then it commits the transaction. It returns the error returned by f, or any error committing to the database, if f was successful.

func View

func View(db *bolt.DB, f func(*Root) error) error

View opens a read-only transaction and calls f with an instance of Root as the root bucket. It returns the error returned by f.

Types

type Agent

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

Agent is a bucket with a static set of elements.

Agent is the db layout for a Starlight agent.

Accessor methods read and write records and open child buckets.

func (*Agent) Bucket

func (o *Agent) Bucket() *bolt.Bucket

Bucket returns o's underlying *bolt.Bucket object. This can be useful to access low-level database functions or other features not exposed by this generated code.

Note, if o's transaction is read-only and the underlying bucket has not previously been created in a writable transaction, Bucket returns nil.

func (*Agent) Channels

func (o *Agent) Channels() *MapOfFsmChannel

Channels gets the child bucket with key "Channels" from o.

Channels holds the state of all open channels. Closed channels are deleted. (Their history is still available in Updates.)

Channels creates a new bucket if none exists and o's transaction is writable. Regardless, it always returns a non-nil *MapOfFsmChannel; if the bucket doesn't exist and o's transaction is read-only, the returned value represents an empty bucket.

func (*Agent) Config

func (o *Agent) Config() *Config

Config gets the child bucket with key "Config" from o.

Config creates a new bucket if none exists and o's transaction is writable. Regardless, it always returns a non-nil *Config; if the bucket doesn't exist and o's transaction is read-only, the returned value represents an empty bucket.

func (*Agent) EncryptedSeed

func (o *Agent) EncryptedSeed() []byte

EncryptedSeed reads the record stored under key "EncryptedSeed". If no record has been stored, EncryptedSeed returns the zero value.

func (*Agent) Messages

func (o *Agent) Messages() *MapOfMessageMessage

Messages gets the child bucket with key "Messages" from o.

Messages creates a new bucket if none exists and o's transaction is writable. Regardless, it always returns a non-nil *MapOfMessageMessage; if the bucket doesn't exist and o's transaction is read-only, the returned value represents an empty bucket.

func (*Agent) NextKeypathIndex

func (o *Agent) NextKeypathIndex() uint32

NextKeypathIndex reads the record stored under key "NextKeypathIndex". If no record has been stored, NextKeypathIndex returns the zero value.

func (*Agent) PrimaryAcct

func (o *Agent) PrimaryAcct() *fsm.AccountID

PrimaryAcct reads the record stored under key "PrimaryAcct". If no record has been stored, PrimaryAcct returns a pointer to the zero value.

func (*Agent) PutEncryptedSeed

func (o *Agent) PutEncryptedSeed(v []byte)

PutEncryptedSeed stores v as a record under the key "EncryptedSeed".

func (*Agent) PutNextKeypathIndex

func (o *Agent) PutNextKeypathIndex(v uint32)

PutNextKeypathIndex stores v as a record under the key "NextKeypathIndex".

func (*Agent) PutPrimaryAcct

func (o *Agent) PutPrimaryAcct(v *fsm.AccountID)

PutPrimaryAcct stores v as a record under the key "PrimaryAcct".

func (*Agent) PutReady

func (o *Agent) PutReady(v bool)

PutReady stores v as a record under the key "Ready".

Ready indicates whether or not the Agent is ready to accept and process new commands. The Agent is only in a not-ready state when it is closing.

func (*Agent) PutWallet

func (o *Agent) PutWallet(v *fsm.WalletAcct)

PutWallet stores v as a record under the key "Wallet".

func (*Agent) Ready

func (o *Agent) Ready() bool

Ready reads the record stored under key "Ready".

Ready indicates whether or not the Agent is ready to accept and process new commands. The Agent is only in a not-ready state when it is closing.

If no record has been stored, Ready returns the zero value.

func (*Agent) Updates

func (o *Agent) Updates() *SeqOfUpdateUpdate

Updates gets the child bucket with key "Updates" from o.

Updates creates a new bucket if none exists and o's transaction is writable. Regardless, it always returns a non-nil *SeqOfUpdateUpdate; if the bucket doesn't exist and o's transaction is read-only, the returned value represents an empty bucket.

func (*Agent) Wallet

func (o *Agent) Wallet() *fsm.WalletAcct

Wallet reads the record stored under key "Wallet". If no record has been stored, Wallet returns a pointer to the zero value.

type Config

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

Config is a bucket with a static set of elements.

Config is the db layout for Starlight agent-level configuration.

Accessor methods read and write records and open child buckets.

func (*Config) Bucket

func (o *Config) Bucket() *bolt.Bucket

Bucket returns o's underlying *bolt.Bucket object. This can be useful to access low-level database functions or other features not exposed by this generated code.

Note, if o's transaction is read-only and the underlying bucket has not previously been created in a writable transaction, Bucket returns nil.

func (*Config) ChannelFeerate

func (o *Config) ChannelFeerate() int64

ChannelFeerate reads the record stored under key "ChannelFeerate". If no record has been stored, ChannelFeerate returns the zero value.

func (*Config) FinalityDelayMins

func (o *Config) FinalityDelayMins() int64

FinalityDelayMins reads the record stored under key "FinalityDelayMins". If no record has been stored, FinalityDelayMins returns the zero value.

func (*Config) HorizonURL

func (o *Config) HorizonURL() string

HorizonURL reads the record stored under key "HorizonURL". If no record has been stored, HorizonURL returns the zero value.

func (*Config) HostFeerate

func (o *Config) HostFeerate() int64

HostFeerate reads the record stored under key "HostFeerate". If no record has been stored, HostFeerate returns the zero value.

func (*Config) KeepAlive

func (o *Config) KeepAlive() bool

KeepAlive reads the record stored under key "KeepAlive". If no record has been stored, KeepAlive returns the zero value.

func (*Config) MaxRoundDurMins

func (o *Config) MaxRoundDurMins() int64

MaxRoundDurMins reads the record stored under key "MaxRoundDurMins". If no record has been stored, MaxRoundDurMins returns the zero value.

func (*Config) Public

func (o *Config) Public() bool

Public reads the record stored under key "Public". If no record has been stored, Public returns the zero value.

func (*Config) PutChannelFeerate

func (o *Config) PutChannelFeerate(v int64)

PutChannelFeerate stores v as a record under the key "ChannelFeerate".

func (*Config) PutFinalityDelayMins

func (o *Config) PutFinalityDelayMins(v int64)

PutFinalityDelayMins stores v as a record under the key "FinalityDelayMins".

func (*Config) PutHorizonURL

func (o *Config) PutHorizonURL(v string)

PutHorizonURL stores v as a record under the key "HorizonURL".

func (*Config) PutHostFeerate

func (o *Config) PutHostFeerate(v int64)

PutHostFeerate stores v as a record under the key "HostFeerate".

func (*Config) PutKeepAlive

func (o *Config) PutKeepAlive(v bool)

PutKeepAlive stores v as a record under the key "KeepAlive".

func (*Config) PutMaxRoundDurMins

func (o *Config) PutMaxRoundDurMins(v int64)

PutMaxRoundDurMins stores v as a record under the key "MaxRoundDurMins".

func (*Config) PutPublic

func (o *Config) PutPublic(v bool)

PutPublic stores v as a record under the key "Public".

func (*Config) PutPwHash

func (o *Config) PutPwHash(v []byte)

PutPwHash stores v as a record under the key "PwHash".

func (*Config) PutPwType

func (o *Config) PutPwType(v string)

PutPwType stores v as a record under the key "PwType".

PwType records which hashing function was used for PwHash. Currently, it's always "bcrypt".

func (*Config) PutUsername

func (o *Config) PutUsername(v string)

PutUsername stores v as a record under the key "Username".

func (*Config) PwHash

func (o *Config) PwHash() []byte

PwHash reads the record stored under key "PwHash". If no record has been stored, PwHash returns the zero value.

func (*Config) PwType

func (o *Config) PwType() string

PwType reads the record stored under key "PwType".

PwType records which hashing function was used for PwHash. Currently, it's always "bcrypt".

If no record has been stored, PwType returns the zero value.

func (*Config) Username

func (o *Config) Username() string

Username reads the record stored under key "Username". If no record has been stored, Username returns the zero value.

type MapOfFsmChannel

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

MapOfFsmChannel is a bucket with arbitrary keys, holding records of type *fsm.Channel.

func (*MapOfFsmChannel) Bucket

func (o *MapOfFsmChannel) Bucket() *bolt.Bucket

Bucket returns o's underlying *bolt.Bucket object. This can be useful to access low-level database functions or other features not exposed by this generated code.

Note, if o's transaction is read-only and the underlying bucket has not previously been created in a writable transaction, Bucket returns nil.

func (*MapOfFsmChannel) Get

func (o *MapOfFsmChannel) Get(key []byte) *fsm.Channel

Get reads the record stored in o under the given key.

If no record has been stored, it returns a pointer to the zero value.

func (*MapOfFsmChannel) GetByString

func (o *MapOfFsmChannel) GetByString(key string) *fsm.Channel

GetByString is equivalent to o.Get([]byte(key)).

func (*MapOfFsmChannel) Put

func (o *MapOfFsmChannel) Put(key []byte, v *fsm.Channel)

Put stores v in o as a record under the given key.

func (*MapOfFsmChannel) PutByString

func (o *MapOfFsmChannel) PutByString(key string, v *fsm.Channel)

PutByString is equivalent to o.Put([]byte(key), v).

type MapOfMessageMessage

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

MapOfMessageMessage is a bucket with arbitrary keys, holding records of type *message.Message.

func (*MapOfMessageMessage) Bucket

func (o *MapOfMessageMessage) Bucket() *bolt.Bucket

Bucket returns o's underlying *bolt.Bucket object. This can be useful to access low-level database functions or other features not exposed by this generated code.

Note, if o's transaction is read-only and the underlying bucket has not previously been created in a writable transaction, Bucket returns nil.

func (*MapOfMessageMessage) Get

func (o *MapOfMessageMessage) Get(key []byte) *message.Message

Get reads the record stored in o under the given key.

If no record has been stored, it returns a pointer to the zero value.

func (*MapOfMessageMessage) GetByString

func (o *MapOfMessageMessage) GetByString(key string) *message.Message

GetByString is equivalent to o.Get([]byte(key)).

func (*MapOfMessageMessage) Put

func (o *MapOfMessageMessage) Put(key []byte, v *message.Message)

Put stores v in o as a record under the given key.

func (*MapOfMessageMessage) PutByString

func (o *MapOfMessageMessage) PutByString(key string, v *message.Message)

PutByString is equivalent to o.Put([]byte(key), v).

type Root

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

Root is a bucket with a static set of elements.

Root is the type of the root bucket, as required by genbolt.

Accessor methods read and write records and open child buckets. See functions View and Update to open transactions.

func NewRoot

func NewRoot(tx *bolt.Tx) *Root

NewRoot returns a new Root for tx.

Root is the type of the root bucket, as required by genbolt.

func (*Root) Agent

func (o *Root) Agent() *Agent

Agent gets the child bucket with key "Agent" from o.

Agent creates a new bucket if none exists and o's transaction is writable. Regardless, it always returns a non-nil *Agent; if the bucket doesn't exist and o's transaction is read-only, the returned value represents an empty bucket.

func (*Root) DeleteAgent

func (r *Root) DeleteAgent()

DeleteAgent wipes an agent from the database by deleting its bucket.

func (*Root) Tx

func (o *Root) Tx() *bolt.Tx

Tx returns o's underlying *bolt.Tx object. This can be useful to access low-level database functions or other features not exposed by this generated code.

type SeqOfUpdateUpdate

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

SeqOfUpdateUpdate is a bucket with sequential numeric keys, holding records of type *update.Update.

func (*SeqOfUpdateUpdate) Add

func (o *SeqOfUpdateUpdate) Add(v *update.Update, np *uint64)

Add stores v in o under a new sequence number. It writes the new sequence number to *np before marshaling v. It is okay for np to point to a field inside v, to store the sequence number in the new record.

func (*SeqOfUpdateUpdate) Bucket

func (o *SeqOfUpdateUpdate) Bucket() *bolt.Bucket

Bucket returns o's underlying *bolt.Bucket object. This can be useful to access low-level database functions or other features not exposed by this generated code.

Note, if o's transaction is read-only and the underlying bucket has not previously been created in a writable transaction, Bucket returns nil.

func (*SeqOfUpdateUpdate) Get

Get reads the record stored in o under sequence number n.

If no record has been stored, it returns a pointer to the zero value.

func (*SeqOfUpdateUpdate) Put

func (o *SeqOfUpdateUpdate) Put(n uint64, v *update.Update)

Put stores v in o as a record under sequence number n.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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