provider

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 59 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package provider is bstore-provider: the market front of spec section 17 over a hold backend. It receives pieces from a bucket's blob topic (the plane's delivery, or a writer's unicast through BRC-167 upload sessions) and entries from its records topic; checks each closure as spec section 5 and rows C1 to C4 of frozen.md section 14 have it, and recomputes the proof root; decides by its hold policy and the bounty's own checks (spec section 9.3); advertises at once, because the writer ranks by first sight; answers challenges, renewals and settlement remittances on its front (spec section 10.1); and serves the closure on BRC-167's object routes, with HTTP Range.

Index

Constants

This section is empty.

Variables

View Source
var Profile = bwallet.Profile{
	FundProtocol:   storerec.Protocol,
	FundKeyID:      storerec.KeyFund,
	FundBasket:     "bstore fund",
	Version:        "bstore-provider-1",
	LegacyPoolFile: "bstore-provider-pool.json",
}

Profile is the embedded wallet's profile: the fund key under [1, "bstore"] key id fund, counterparty self, and the registered basket.

Functions

func Doctor added in v0.2.0

func Doctor(ctx context.Context, cfg *Config, ca string, w io.Writer) error

Doctor reports a provider's identity, its pool, its store, and whether the chain view, the header source, the settlement leg, the hosts, the facade and its own public routes answer, and the fee policy in force. It reads only: it opens the wallet to read the pool, walks the store's directory, and asks each endpoint one GET. ca, when set, is a PEM file trusted besides the system's for the provider's own public URL. It returns an error only when the configuration or the wallet cannot be read; an endpoint that does not answer is reported.

func Init

func Init(data string) (string, error)

Init creates a provider's wallet under data and returns its identity key; it refuses a directory that holds one.

func Reach added in v0.2.0

func Reach(ctx context.Context, hc *http.Client, urls ...string) string

Reach is one GET of each URL in turn: the first that answers below 500 is reported with its status, else why the last did not.

func WalletDir

func WalletDir(data string) string

WalletDir is the wallet's directory under a data directory.

Types

type AdRec

type AdRec struct {
	Txid   string `json:"txid"`
	Vout   uint32 `json:"vout"`
	Expiry uint64 `json:"expiry"`
	Height uint32 `json:"height"`
	RawHex string `json:"rawHex"`
	Bump   string `json:"bump"`
	// First is the txid of the advertisement this one renews, through
	// every renewal: the one whose first sight a renewal keeps.
	First string `json:"first"`
}

AdRec is a mined advertisement.

type BucketConfig

type BucketConfig struct {
	Bucket string `json:"bucket"`
	// Writers, when set, are the only writers whose pieces and entries are
	// taken, 66 hex digits each.
	Writers []string `json:"writers,omitempty"`
}

BucketConfig is one bucket the provider subscribes to.

type Config

type Config struct {
	// Data is the data directory: the wallet, the state, the store, the
	// payment ledger. Absolute.
	Data string `json:"data"`
	// Listen is the address the routes are served on; TLSCert and TLSKey,
	// when both set, serve them over TLS (otherwise a TLS proxy in front
	// terminates it).
	Listen  string `json:"listen"`
	TLSCert string `json:"tls_cert,omitempty"`
	TLSKey  string `json:"tls_key,omitempty"`
	// PublicURL is the https URL the routes are reached at from outside:
	// objects at <PublicURL>/chirp/v1/..., the front at
	// <PublicURL>/bstore/v1 (spec section 10.1). No trailing slash, no
	// query, no fragment, no user information.
	PublicURL string `json:"public_url"`
	// Chain is the chain view (proofs, spends, transactions):
	// nodeapi.ParseChain's woc:main, woc:test, asset:<url> or a list;
	// default woc:main or woc:test by Mainnet. Node, the older key, a
	// node's asset API, is chain asset:<url>. Settle is the settlement leg,
	// arcade:main, arcade:test, arcade:<url>, arc:<url>, rpc:<url> or
	// tcp:<host:port> (default GorillaPool's arcade), with RPCUser, RPCPass
	// and ArcadeKey as it needs; Headers a header source (bcommon headers:
	// woc:main, bhs:<url>, arcade:<url>, chaintracks:<url> or a bridge
	// URL; default woc:main or woc:test), HeadersToken its bearer token.
	// WoCKey and WoCRate are a WhatsOnChain API key and its requests a
	// second: a busy provider exceeds the free 3 a second and needs a key,
	// or a node. On a regtest chain set chain, settle and headers.
	Chain        string  `json:"chain,omitempty"`
	Node         string  `json:"node,omitempty"`
	Settle       string  `json:"settle,omitempty"`
	RPCUser      string  `json:"rpc_user,omitempty"`
	RPCPass      string  `json:"rpc_pass,omitempty"`
	ArcadeKey    string  `json:"arcade_key,omitempty"`
	Headers      string  `json:"headers,omitempty"`
	HeadersToken string  `json:"headers_token,omitempty"`
	WoCKey       string  `json:"woc_key,omitempty"`
	WoCRate      float64 `json:"woc_rate,omitempty"`
	// Hosts are the overlay hosts advertisements are submitted to, each
	// directly; Facade, when set, is a plane facade they are submitted to
	// once as well. UHRPTopic also submits each to tm_uhrp, as BRC-26 has
	// it, where a host carries that topic.
	Hosts     []string `json:"hosts"`
	Facade    string   `json:"facade,omitempty"`
	UHRPTopic bool     `json:"uhrp_topic"`
	// Buckets are the buckets the provider takes objects for.
	Buckets []BucketConfig `json:"buckets"`
	// Backend selects the hold backend: "native" (the content-addressed
	// store under Data/store), or "bridge" when a bridge runs the provider
	// as a front for another advertiser and supplies the backend (Front).
	// Export, when set, keeps a read-only view of every held closure there
	// for an NFS export (docs/provider.md); a bridge keeps no closure.
	Backend string `json:"backend"`
	Export  string `json:"export,omitempty"`
	// QuotaBytes bounds the store; UnclaimedBytes the part of it pieces no
	// entry has claimed yet may take, and UnclaimedSeconds how long such a
	// piece is kept.
	QuotaBytes       uint64 `json:"quota_bytes"`
	UnclaimedBytes   uint64 `json:"unclaimed_bytes"`
	UnclaimedSeconds uint64 `json:"unclaimed_seconds"`
	// Policy is what the provider takes, Terms what it publishes and
	// charges, Limits its routes' hardening.
	Policy Policy `json:"policy"`
	Terms  Terms  `json:"terms"`
	Limits Limits `json:"limits"`
	// TreeCount and TreeSats size the funding trees advertisements and
	// renewals spend; an advertisement pays all of its output in fee, so
	// TreeSats is the most one costs. Fee is the miner fee policy (feepolicy.Config;
	// default 100 satoshis per 1000 bytes, floor 100, capped at 100/1000); FeeRate and FeeFloor
	// are its older keys fee_sat_per_byte and fee_floor, still read.
	TreeCount int               `json:"tree_count"`
	TreeSats  uint64            `json:"tree_sats"`
	Fee       *feepolicy.Config `json:"fee,omitempty"`
	FeeRate   uint64            `json:"fee_sat_per_byte,omitempty"`
	FeeFloor  uint64            `json:"fee_floor,omitempty"`
	// Mainnet selects mainnet addresses for the fund address, and the
	// mainnet services by default.
	Mainnet bool `json:"mainnet"`
	// RefuseUnmined makes fund -beef take mined payments only.
	RefuseUnmined bool `json:"refuse_unmined,omitempty"`
	// TrustedProxies are the addresses (CIDR) of proxies in front of the
	// provider whose X-Forwarded-For names the client: every per-address
	// budget is the client's, not the proxy's.
	TrustedProxies []string `json:"trusted_proxies,omitempty"`
	// Feeders are the addresses (CIDR) of the plane's local feeders: the
	// overlay bridge that hands this provider what the plane delivers on its
	// topics. A submission whose connection comes from one skips the
	// per-address submission budgets, which a feed at plane speed would
	// otherwise trip and lose pieces to; the global bounds still apply.
	Feeders []string `json:"feeders,omitempty"`
	// MetricsListen, when set, serves /metrics there, and only there.
	MetricsListen string `json:"metrics_listen,omitempty"`
	// PprofListen, when set, serves Go's net/http/pprof there (a loopback
	// address: the profiles are the process's internals).
	PprofListen string `json:"pprof_listen,omitempty"`
	// FeedListen, when set, is a loopback address where the plane's local
	// feeder (an overlay bridge on the same host) submits: POST /submit and
	// /healthz only, plain HTTP, no BRC-104, and no per-address budgets, the
	// way a bridge reaches its engine. Every other route stays on Listen.
	FeedListen string `json:"feed_listen,omitempty"`
	// Accept is the payment acceptance rule (accept_threshold_sats and the
	// other accept_ keys, docs/provider.md).
	acceptcfg.Config
}

Config is a provider's configuration file, JSON. Every field has a default but Data, PublicURL and Buckets.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig reads a configuration file, takes the defaults and checks it. An unknown key is refused, so a misspelt one is not silently a default.

func (*Config) Check

func (c *Config) Check() error

Check takes the defaults and refuses a configuration that cannot run.

func (*Config) FrontURL

func (c *Config) FrontURL() string

FrontURL is the front a provider's advertisement derives: the public URL followed by /bstore/v1.

func (*Config) Spec added in v0.9.0

func (c *Config) Spec() chaincfg.Spec

Spec is the chain, settlement and fee settings, for chaincfg.

type DeleteRec added in v0.11.0

type DeleteRec struct {
	Created uint64 `json:"created"`
	At      int64  `json:"at"`
}

DeleteRec is a delete entry remembered for the puts it may still meet.

type EntryRec

type EntryRec struct {
	C      string `json:"c"`
	Bucket string `json:"bucket"`
	// Key is the entry's key in the bucket: what a later delete names.
	// Entries noted before it was kept have none and no delete reaches them.
	Key         string   `json:"key,omitempty"`
	Writer      string   `json:"writer"`
	Root        string   `json:"root"`
	Size        uint64   `json:"size"`
	ContentHash string   `json:"contentHash"`
	ProofRoot   string   `json:"proofRoot"`
	Created     uint64   `json:"created"`
	Hold        *HoldRec `json:"hold,omitempty"`
	// Decision is "", "held", or why it was declined; At when it arrived.
	Decision string `json:"decision"`
	At       int64  `json:"at"`
}

EntryRec is an object entry the provider received, and what it decided.

type Front

type Front struct {
	// Backend is the bridge backend. Its Advertise returns the
	// advertiser's advertisement mined, with its own proof in the BEEF.
	Backend backend.Backend
	// Advertiser is the advertiser's identity key, 33 bytes compressed:
	// every advertisement the backend returns must name it.
	Advertiser []byte
	// Forward is told of every spend of a held entry's hold output (a
	// settlement, or a reclaim) once it is mined. An error is retried.
	Forward func(context.Context, Settlement) error
}

Front makes a provider the market front of spec section 17 for an advertiser that holds, serves and advertises the bytes itself: an incumbent UHRP host joined through a bridge backend. The provider still receives, checks the closure, recomputes the proof root, decides and answers; then, for each closure it takes, it hands every object to the backend (Put), has the backend make the closure held (Advertise: the advertiser commits or renews through its own routes), checks the advertisement the backend returns, publishes it to the bucket's records topic unchanged, and drops its own copy of the bytes, keeping the proof tree's segment hashes. It answers challenges by reference only, every sampled segment read through the backend (from the advertiser's URL) and checked against the kept hashes before anything is signed; it serves no object routes and takes no uploads; a bounty pays the advertiser, so a settlement it finds is passed to Forward rather than taken.

type Funding

type Funding struct {
	C  string `json:"c"`
	At int64  `json:"at"`
}

Funding is the carrier a funding outpoint paid for, as an earlier version kept it.

type HeldRec added in v0.4.0

type HeldRec struct {
	Class string `json:"class"`
	At    int64  `json:"at"`
}

HeldRec is a challenge payment held for confirmation: its class and when it was taken (Unix seconds).

type HoldRec

type HoldRec struct {
	Txid      string `json:"txid"` // display order
	Vout      uint32 `json:"vout"`
	Sats      uint64 `json:"sats"`
	T         uint64 `json:"t"`
	K         uint64 `json:"k"`
	Retention uint64 `json:"retention"`
	Deadline  uint64 `json:"deadline"`
	CheckC    uint64 `json:"checkC"`
	// Height is the hold output's block, once checked.
	Height uint32 `json:"height,omitempty"`
}

HoldRec is an entry's hold terms and what the provider found of them.

func (*HoldRec) Outpoint

func (h *HoldRec) Outpoint() string

Outpoint is the hold output as "<txid>.<vout>".

type Holding

type Holding struct {
	Root        string `json:"root"`
	Size        uint64 `json:"size"`
	ContentHash string `json:"contentHash"`
	ProofRoot   string `json:"proofRoot"`
	// RootLen is the root node's length: the advertisement's fileSize.
	RootLen uint64 `json:"rootLen"`
	// Objects and Blobs count the closure's distinct objects and its blob
	// positions; Bytes is what its distinct objects take on disk.
	Objects int    `json:"objects"`
	Blobs   int    `json:"blobs"`
	Bytes   uint64 `json:"bytes"`
	// Verified once the closure and its proof root checked out; Damaged
	// once an object read back wrong or went missing, after which the root
	// is neither served, answered for nor renewed.
	Verified bool `json:"verified"`
	Damaged  bool `json:"damaged,omitempty"`
	// Buckets and Entries name what it is held for.
	Buckets []string `json:"buckets"`
	Entries []string `json:"entries"`
	// Ad is the live advertisement; Lease is the expiry the closure is
	// kept through (an advertisement's, or a pending one's).
	Ad    *AdRec `json:"ad,omitempty"`
	Lease uint64 `json:"lease"`
	// At is when it was taken, Unix seconds.
	At int64 `json:"at"`
	// Handed is a front's: every object was handed to the backend and the
	// advertiser's advertisement adopted, and the front's own copy of the
	// bytes dropped (Bytes is then 0).
	Handed bool `json:"handed,omitempty"`
}

Holding is a closure the provider holds, or is deciding to.

type Limits

type Limits struct {
	HandshakesPerSec        float64 `json:"handshakes_per_sec"`
	HandshakeBurst          float64 `json:"handshake_burst"`
	HandshakesPerAddrPerSec float64 `json:"handshakes_per_addr_per_sec"`
	HandshakeAddrBurst      float64 `json:"handshake_addr_burst"`
	ResponsesPerSec         float64 `json:"responses_per_sec"`
	ResponseBurst           float64 `json:"response_burst"`
	Sessions                int     `json:"sessions"`
	SessionTTLSeconds       int     `json:"session_ttl_seconds"`
	// ChallengesPerBuyerPerMin and ChallengeBurst bound the challenges one
	// buyer (identity key) is answered; FreePerWriterPerMin the free
	// settlement challenges one writer is.
	ChallengesPerBuyerPerMin float64 `json:"challenges_per_buyer_per_min"`
	ChallengeBurst           float64 `json:"challenge_burst"`
	FreePerWriterPerMin      float64 `json:"free_per_writer_per_min"`
	// ChallengeWorkers bounds the challenges answered at once.
	ChallengeWorkers int `json:"challenge_workers"`
	// VerifyWorkers bounds the roots seen through at once for entries:
	// each verified and then decided (held, advertised) by one worker.
	VerifyWorkers int `json:"verify_workers"`
	// AdSends bounds the advertisements on their way to the settlement leg
	// at once, behind the workers.
	AdSends int `json:"ad_sends"`
	// AdBatch is the most roots one advertisement transaction carries (an
	// output each, spec section 12.1 admits up to 1,024 a transaction), and
	// AdBatchMs how long the minter collects roots behind the first before
	// it signs; 1 mints one a transaction, as before.
	AdBatch   int `json:"ad_batch"`
	AdBatchMs int `json:"ad_batch_ms"`
	// AdVerdict is what an advertisement's send waits for on an arcade leg:
	// "proof" (the default) returns once arcade has taken the transaction,
	// the Merkle proof the background watches for being the evidence;
	// "network" waits for the network's verdict first, which bounds the
	// rate at what the network announces (about 150 a second on one node).
	AdVerdict string `json:"ad_verdict"`
	// UndecidedPerWriter is the most put entries from one writer kept
	// waiting for their closures; one past it is refused for room, and a
	// feeder reads no refusal, so a writer bursting while closures stall
	// (a host or network pause) loses what arrives over it.
	UndecidedPerWriter int `json:"undecided_per_writer"`
	// RenewalsPerRootPerHour bounds paid renewals of one root.
	RenewalsPerRootPerHour float64 `json:"renewals_per_root_per_hour"`
	// SubmitsPerAddrPerSec and SubmitBurst bound submissions from one
	// address (the plane's listener, or a writer's unicast).
	SubmitsPerAddrPerSec float64 `json:"submits_per_addr_per_sec"`
	SubmitBurst          float64 `json:"submit_burst"`
	// InFlightPerAddr bounds the submissions and uploads one address has
	// read or processed at once; one past it waits up to inflightWait for
	// a slot before a 429 (a feeder skips it, as it skips the rate).
	InFlightPerAddr int `json:"in_flight_per_addr"`
	// ObjectReaders bounds the object reads served at once;
	// ObjectReadsPerAddrPerSec and ObjectReadBurst one address's reads.
	ObjectReaders            int     `json:"object_readers"`
	ObjectReadsPerAddrPerSec float64 `json:"object_reads_per_addr_per_sec"`
	ObjectReadBurst          float64 `json:"object_read_burst"`
	// UploadSessions bounds the open upload sessions, and their life.
	UploadSessions       int    `json:"upload_sessions"`
	UploadSessionSeconds uint64 `json:"upload_session_seconds"`
}

Limits are the routes' hardening; zero takes the default.

type Options

type Options struct {
	// FreshSpends reads the node for every hold and spend asked about,
	// rather than answering from one read of a transaction for a moment
	// (chaincfg CacheSpends, minedHolds): for a test that changes what the
	// node holds and looks at once.
	FreshSpends bool
	// Now is the clock; Tick paces the background work (resuming,
	// publishing, collecting, settling, evicting); Logf receives the log.
	Now  func() time.Time
	Tick time.Duration
	Logf func(format string, args ...any)
	// Settler, when set, is the settlement leg instead of the configured
	// one.
	Settler publish.Settler
	// Front, when set, makes the provider a front for another advertiser
	// (configuration backend "bridge"): see Front.
	Front *Front
	// Accept, when set, adjusts the payment verifier once it is built
	// (tests: a broadcaster or a status source of their own).
	Accept func(*acceptance.Verifier)
}

Options are what a caller embedding a provider may set beyond the configuration.

type Outgoing

type Outgoing struct {
	Host  string `json:"host"`
	Topic string `json:"topic"`
	Txid  string `json:"txid"`
	Beef  string `json:"beef"`
	Tries int    `json:"tries"`
	Next  int64  `json:"next"`
}

Outgoing is a mined advertisement still to reach one host on one topic.

type Owed

type Owed struct {
	Root    string `json:"root"`
	Until   uint64 `json:"until"`
	Payment string `json:"payment"`
	// Held is a renewal whose payment is held for confirmation: made once
	// the payment's proof verifies, dropped if it is double-spent first.
	Held bool `json:"held,omitempty"`
}

Owed is a renewal paid for: the root's advertisement is owed through Until.

type Payout

type Payout struct {
	Settlement string `json:"settlement"`
	Rank       int    `json:"rank"`
	Satoshis   uint64 `json:"satoshis"`
	// Via is "remittance" or "scan".
	Via string `json:"via"`
	At  int64  `json:"at"`
}

Payout is a settlement found paying this provider for one entry.

type PendingAd

type PendingAd struct {
	Root string `json:"root"`
	Txid string `json:"txid"`
	// AdVout is the root's output in the transaction: a transaction minted
	// for several roots at once (limits.ad_batch) has a row per root.
	AdVout  uint32 `json:"adVout,omitempty"`
	RawHex  string `json:"rawHex,omitempty"`
	BeefHex string `json:"beef,omitempty"`
	Expiry  uint64 `json:"expiry"`
	// Tree and Vout are the funding output it spends for its fee; Prev the
	// advertisement a renewal spends.
	Tree string `json:"tree"`
	Vout uint32 `json:"vout"`
	Prev *AdRec `json:"prev,omitempty"`
	// Sent once the settlement leg took it.
	Sent bool  `json:"sent,omitempty"`
	At   int64 `json:"at"`
}

PendingAd is an advertisement or renewal transaction signed and persisted before it reaches the settlement leg. RawHex is the transaction alone: its inputs are the funding tree the state keeps and, for a renewal, the advertisement it renews, so its BEEF is rebuilt from those (pendingTx). BeefHex is what rows before 2026-11-05 kept: a BEEF with every unmined ancestor, 142 KB each on the lab once funding trees chained up behind a slow block, thousands of them the bulk of a 247 MB state written whole on every save.

type PendingTree

type PendingTree struct {
	Tree         funding.Tree   `json:"tree"`
	Coin         bwallet.Output `json:"coin"`
	ReturnedOnce bool           `json:"returnedOnce,omitempty"`
}

PendingTree is a funding tree signed for a coin and not yet adopted (producer.Trees.Prepare); ReturnedOnce marks one whose coin came back once, kept for one more recovery.

type Policy

type Policy struct {
	// MaxObject is the largest object taken, bytes.
	MaxObject uint64 `json:"max_object"`
	// MinDeadlineBlocks is how far ahead of the tip an entry's deadline
	// must be for its bounty to be raced for.
	MinDeadlineBlocks uint64 `json:"min_deadline_blocks"`
	// MaxRetentionSeconds is the longest an entry may ask an advertisement
	// to last from the entry's created time.
	MaxRetentionSeconds uint64 `json:"max_retention_seconds"`
	// HoldUnbountied takes an entry with no bounty, or one whose bounty
	// does not check out, for UnbountiedSeconds.
	HoldUnbountied    bool   `json:"hold_unbountied"`
	UnbountiedSeconds uint64 `json:"unbountied_seconds"`
	// AnswerInline answers challenges with the segments (the default); off,
	// every sample is by reference, fetched by the buyer from the
	// advertised URL.
	AnswerInline *bool `json:"answer_inline,omitempty"`
}

Policy is the provider's hold policy (spec section 9.3; not frozen).

type Provider

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

Provider is one running provider.

func New

func New(ctx context.Context, cfg *Config, opts Options) (*Provider, error)

New opens a provider over a checked configuration; Start serves it.

func (*Provider) Addr

func (p *Provider) Addr() string

Addr is the address the routes are served on.

func (*Provider) Close

func (p *Provider) Close() error

Close stops serving and the background work, and saves.

func (*Provider) Fees

func (p *Provider) Fees() mint.Fees

Fees is the provider's fee policy.

func (*Provider) FundAddress

func (p *Provider) FundAddress() (string, error)

FundAddress is where coin for the provider's fees is paid.

func (*Provider) Identity

func (p *Provider) Identity() string

Identity is the provider's identity key, 66 hex digits.

func (*Provider) NewPayer

func (p *Provider) NewPayer() *producer.Payer

NewPayer is a payer over the provider's pool, for a transaction a caller funds from it (its fee coin taken, its change kept).

func (*Provider) Purse

func (p *Provider) Purse(maxPay uint64) *purse.Purse

Purse pays from the provider's pool, up to maxPay for one payment (zero pays nothing): a BRC-105 402 answered as a client (the wallet of go-sdk AuthFetch).

func (*Provider) Settler

func (p *Provider) Settler() publish.Settler

Settler is the settlement leg the provider broadcasts on.

func (*Provider) Signer

func (p *Provider) Signer() *bwallet.Signer

Signer is the provider's key set: its identity, its fund key.

func (*Provider) Staged

func (p *Provider) Staged(h [32]byte) ([]byte, error)

Staged is an object of the provider's own store, whole: for a front, what a bridge backend uploads from between Put and Advertise, before the front drops its copy.

func (*Provider) Start

func (p *Provider) Start(ctx context.Context) error

Start listens, recovers what a previous run left, and starts the background work. It returns once the routes are served.

func (*Provider) TakeLocal added in v0.24.0

func (p *Provider) TakeLocal(ctx context.Context, lp publish.LocalPiece, verify bool) error

TakeLocal takes a piece carrier, or a record, from a gateway in this process: a storage node, the gateway's local_provider. It is the feeder path without the socket, and with the check of a piece optional; a record is always checked (takeLocalRecord).

With verify set, or for a piece the gateway gives no account of (lp.Known unset: an item read back from its outbox after a restart), the carrier is checked as any submission is (storerec.CheckPieceCarrier) before it is taken. With verify unset and an account given, the gateway's account is taken as given: the record's bucket, root, writer and piece, the piece's SHA-256, the funding output and the carrier's txid are the ones it minted, and only the piece's segment leaves are hashed here. The bucket's writer list, the funding output's one carrier and the room are held as always, and the closure walk still checks the closure's structure and content hash before the root is advertised.

The piece is kept by reference: lp.BEEF is this provider's from here on (the gateway does not reuse it). A refusal comes back as publish.Refused, which the gateway neither counts delivered nor sends again; a store error or an unmined funding tree comes back as an error, and the gateway sends the piece again later.

func (*Provider) Wallet

func (p *Provider) Wallet() wallet.Interface

Wallet is the provider's wallet.

type Settlement

type Settlement struct {
	Entry            string `json:"entry"`
	Bucket           string `json:"bucket"`
	Root             string `json:"root"`
	Hold             string `json:"hold"`
	Writer           string `json:"senderIdentityKey"`
	K                uint64 `json:"k"`
	Txid             string `json:"txid"`
	Height           uint32 `json:"height"`
	DerivationPrefix string `json:"derivationPrefix"`
	// BEEF is the spending transaction as Atomic BEEF with its proof.
	BEEF []byte `json:"beef"`
}

Settlement is a spend of the hold output of an entry a front took, as a front finds it: the payee of a bounty is the advertiser, whose key the front does not hold, so the front forwards what the advertiser needs to find and take its output (spec section 9.5): the transaction, and the BRC-29 derivation's prefix and sender; the suffix is the rank's, for ranks 1 to K.

type State

type State struct {
	Identity string `json:"identity"`
	// LogGen is the generation of the state log this checkpoint was taken
	// at: a start applies that generation and every later one (journal.go).
	LogGen uint64 `json:"logGen,omitempty"`

	// The funding trees advertisements and renewals spend.
	Tree         *funding.Tree  `json:"tree,omitempty"`
	Trees        []funding.Tree `json:"trees,omitempty"`
	Ahead        []funding.Tree `json:"ahead,omitempty"`
	PendingTrees []PendingTree  `json:"pendingTrees,omitempty"`

	// Holdings by root (64 hex digits); Entries by commitment (display
	// txid of the entry carrier).
	Holdings map[string]*Holding  `json:"holdings"`
	Entries  map[string]*EntryRec `json:"entries"`
	// Unclaimed are pieces no held closure names yet, by object hash.
	Unclaimed map[string]*Unclaimed `json:"unclaimed"`
	// Deletes are the newest delete entry seen per bucket and key: a put
	// made no later than it that arrives after it (the plane does not order
	// entries) is ended on arrival instead of waiting for a closure forever.
	Deletes map[string]*DeleteRec `json:"deletes,omitempty"`
	// PendingAds are advertisement and renewal transactions signed and not
	// yet recorded as mined: the journal a restart resumes from.
	PendingAds []PendingAd `json:"pendingAds,omitempty"`
	// Outbox is mined advertisements still to reach a host.
	Outbox []Outgoing `json:"outbox,omitempty"`
	// Free counts the free settlement challenges answered, by hold
	// outpoint ("<txid>.<vout>"): at most two each (spec section 9.4).
	Free map[string]int `json:"free"`
	// Payouts are the settlements found paying this provider, by entry
	// commitment: from a remittance or from the hold output's spend.
	Payouts map[string]*Payout `json:"payouts"`
	// MadeGood are lost fast remittances (unsettleable) whose entry's hold
	// output was later spent by a mined settlement paying this provider at
	// least as much, by the lost txid: the writer made the loss good, so it
	// is not held for confirmation on their account.
	MadeGood map[string]string `json:"madeGood,omitempty"`
	// Owed are renewals paid for and not made yet.
	Owed []Owed `json:"owed,omitempty"`
	// Held are challenge payments taken and held for confirmation, by
	// txid, with their class: sent again once mined, each buys its answer.
	Held map[string]HeldRec `json:"held,omitempty"`
	// Fundings is the table an earlier version kept here: read once, into
	// the funding log (fundingBook), and not written again.
	Fundings map[string]*Funding `json:"fundings,omitempty"`
	// Book is the payee's record of the ledger's payments settled.
	payee.Book
	// contains filtered or unexported fields
}

State is what a provider keeps between runs, in state.json in its data directory, written whole to a temporary file, synced and renamed. Large per-root data (the proof tree's leaves, the closure's objects) lives in files of its own under roots/.

type Terms

type Terms struct {
	ChallengeBase      uint64 `json:"challenge_base"`
	ChallengePerSample uint64 `json:"challenge_per_sample"`
	FreeC              uint64 `json:"free_c"`
	MinBounty          uint64 `json:"min_bounty"`
	MinAge             uint64 `json:"min_age"`
	RenewPerGiBDay     uint64 `json:"renew_per_gib_day"`
	RenewMinimum       uint64 `json:"renew_minimum"`
	// MaxRenewSeconds is the furthest ahead of now a renewal may run.
	MaxRenewSeconds uint64 `json:"max_renew_seconds"`
}

Terms are the provider's published terms (spec section 10.1), and the limits of what it sells.

type Unclaimed

type Unclaimed struct {
	Root   string `json:"root"`
	Bucket string `json:"bucket"`
	// Writer is who sent it: the piece's writer, or the identity that
	// uploaded it.
	Writer string `json:"writer"`
	Size   uint64 `json:"size"`
	At     int64  `json:"at"`
}

Unclaimed is a piece kept until an entry names its closure.

Jump to

Keyboard shortcuts

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