Documentation
¶
Overview ¶
Package home is a sender's directory: its identity and coin pool (bcommon's bwallet), its settings, and the funding trees its carriers spend from.
Index ¶
- Variables
- func Lock(dir string) (func(), error)
- func SaveConfig(dir string, c Config) error
- type Config
- type Pending
- type State
- func (s *State) DropPending(txid string)
- func (s *State) NextTree() *funding.Tree
- func (s *State) NextTreeFrom(height uint32) *funding.Tree
- func (s *State) Remaining() uint64
- func (s *State) RemainingFrom(height uint32) uint64
- func (s *State) Save() error
- func (s *State) Tree(txid string) *funding.Tree
- type Sweep
Constants ¶
This section is empty.
Variables ¶
var ErrLocked = errors.New("the home is in use by another beefcat command")
ErrLocked is a home another beefcat command is using.
Functions ¶
func Lock ¶
Lock takes the home's lock: one command that spends from its pool or writes its state at a time. The returned function releases it.
func SaveConfig ¶
SaveConfig writes the home's settings.
Types ¶
type Config ¶
type Config struct {
// Network is main, test or regtest.
Network string `json:"network"`
// Headers is the header source every proof is checked against.
Headers string `json:"headers,omitempty"`
// Chain is the chain view: transactions, proofs and spends.
Chain string `json:"chain,omitempty"`
// Settle is the settlement leg funding trees and sweeps are mined
// through.
Settle string `json:"settle,omitempty"`
// RPC is a node's JSON-RPC, for coinbase on a regtest chain you run.
RPC string `json:"rpc,omitempty"`
}
Config is what init writes and every command reads. A flag overrides a field for one run.
func LoadConfig ¶
LoadConfig reads the home's settings; a home without any is empty.
type Pending ¶
type Pending struct {
Tree funding.Tree `json:"tree"`
Coin bwallet.Output `json:"coin"`
// Asked counts the commands that found the tree unknown and its coin
// unspent.
Asked int `json:"asked,omitempty"`
}
Pending is a funding tree signed for a coin and not yet recorded as mined: what producer.Trees.Prepare was given.
type State ¶
type State struct {
Identity string `json:"identity"`
Trees []funding.Tree `json:"trees,omitempty"`
Pending []Pending `json:"pending,omitempty"`
Sweeps []Sweep `json:"sweeps,omitempty"`
// Sent counts the carriers and data bytes this home has sent.
SentCarriers uint64 `json:"sentCarriers,omitempty"`
SentBytes uint64 `json:"sentBytes,omitempty"`
// contains filtered or unexported fields
}
State is the home's record of its funding trees.
func LoadState ¶
LoadState reads the home's state for identity (hex), or starts an empty one. The caller holds the lock.
func (*State) DropPending ¶
DropPending forgets the pending record of txid.
func (*State) NextTreeFrom ¶ added in v0.2.0
NextTreeFrom is the first tree mined at height or above with an output left, or nil.
func (*State) RemainingFrom ¶ added in v0.2.0
RemainingFrom is how many carriers the trees mined at height or above can still fund.