Documentation
¶
Overview ¶
Package s3d is `bstore s3d`, the S3 gateway of spec section 16: a reader and a writer for clients that speak S3, authenticated with AWS Signature Version 4 in gateway mode. Reads are proven against the bucket's chain (package reader); writes are published by the identity an access key maps to (package publish). docs/s3.md is the operator's guide and the compatibility matrix.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessKey ¶
type AccessKey struct {
ID string `json:"id"`
Secret string `json:"secret,omitempty"`
SecretFile string `json:"secret_file,omitempty"`
Identity string `json:"identity"`
Buckets []string `json:"buckets,omitempty"`
}
AccessKey is one S3 access key.
type Auth ¶
type Auth struct {
Key *Key
// Seed is the request's signature: a streaming body's chunks chain
// from it, and replay protection is keyed by it.
Seed string
Scope string
Time time.Time
Payload string // the x-amz-content-sha256 value
Presign bool
// contains filtered or unexported fields
}
Auth is a request whose signature verified.
type BountyConfig ¶
type BountyConfig struct {
Satoshis uint64 `json:"satoshis"`
T uint64 `json:"t"`
K uint64 `json:"k"`
RetentionSeconds uint64 `json:"retention_seconds"`
DeadlineBlocks uint64 `json:"deadline_blocks"`
CheckC uint64 `json:"check_c"`
}
BountyConfig is the hold bounty a put asks for (spec section 4.3).
type BucketConfig ¶
type BucketConfig struct {
Bucket string `json:"bucket"`
Owner string `json:"owner"`
ID string `json:"id"`
}
BucketConfig is one bucket chain the gateway serves: the identifier, the owner's key and the bucket id (spec sections 3.3 and 16.1).
type Config ¶
type Config struct {
// Data is the data directory: identities/<name>/ (each a wallet, its
// funding trees and its outbox), store/ (the local closures), uploads/,
// state.json. Absolute.
Data string `json:"data"`
// Listen is the address S3 is served on; TLSCert and TLSKey, when both
// set, serve it over TLS (otherwise a proxy in front terminates it).
Listen string `json:"listen"`
TLSCert string `json:"tls_cert,omitempty"`
TLSKey string `json:"tls_key,omitempty"`
// ETagMD5 makes ETags S3's MD5s (a part's MD5; the MD5 of the parts'
// MD5s for a multipart upload), at the cost of an MD5 over every body.
// Off, an object's ETag is its content hash (its SHA-256, what
// x-amz-checksum-sha256 carries) and a part's its SHA-256.
ETagMD5 bool `json:"etag_md5,omitempty"`
// Region is the SigV4 region clients sign for; Domain, when set, also
// serves virtual-host addressing (<bucket>.<domain>).
Region string `json:"region"`
Domain string `json:"domain,omitempty"`
// Chain is the chain view (nodeapi.ParseChain: woc:main, woc:test,
// asset:URL; 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 (publish.ParseSettler: arcade:main, arcade:URL, arc:URL, rpc:URL,
// tcp:ADDR; default GorillaPool's arcade), with RPCUser, RPCPass,
// ArcadeKey; Headers a header source (bcommon headers; 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
// gateway needs one, 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 asked and written to; Facade, when set,
// is the plane; Providers are providers pieces and entries are
// unicast to (their submit route). Quorum is how many hosts must take
// an entry when there is no facade.
Hosts []string `json:"hosts"`
Facade string `json:"facade,omitempty"`
Providers []string `json:"providers,omitempty"`
Quorum int `json:"quorum,omitempty"`
// CA, when set, is a PEM file of certificates trusted, besides the
// system's, for TLS to hosts, providers and advertisers.
CA string `json:"ca,omitempty"`
// FetchPrivate lets the gateway fetch from advertised URLs whose host
// resolves to a loopback, private or link-local address; off, such an
// advertisement is never fetched from.
FetchPrivate bool `json:"fetch_private,omitempty"`
// Identities are the writer identities, each with a wallet under
// identities/<name>; AccessKeys map S3 access keys to them; Buckets are
// the chains served.
Identities []string `json:"identities"`
AccessKeys []AccessKey `json:"access_keys"`
Buckets []BucketConfig `json:"buckets"`
// Bounty, when set, is the hold bounty every put asks for; HoldAhead is
// how many mined hold outputs of it each identity keeps ready.
Bounty *BountyConfig `json:"bounty,omitempty"`
HoldAhead int `json:"hold_ahead,omitempty"`
// HoldTree is how many hold outputs one transaction carries: 16 by
// default, at most what hosts admit of a mined transaction (1,024).
HoldTree int `json:"hold_tree,omitempty"`
Limits Limits `json:"limits"`
// PieceTree and EntryTree size funding trees. 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,
// still read and held to the same cap.
PieceTree int `json:"piece_tree"`
EntryTree int `json:"entry_tree"`
Fee *feepolicy.Config `json:"fee,omitempty"`
FeeRate uint64 `json:"fee_sat_per_byte,omitempty"`
FeeFloor uint64 `json:"fee_floor,omitempty"`
Mainnet bool `json:"mainnet"`
// RefuseUnmined makes fund -beef take mined payments only.
RefuseUnmined bool `json:"refuse_unmined,omitempty"`
// The payment acceptance rule a settlement is remitted by (accept_
// keys, docs/s3.md).
acceptcfg.Config
// PieceWorkers is how many piece carriers a put mints and sends at once
// (default 4); PieceAhead how many piece outputs are kept ready ahead
// of the puts, across the current tree, the trees held for a switch
// and the trees being minted, with more trees minted in the background
// when fewer are left (default piece_tree: one tree always ready);
// EntryAhead the same for entry trees (default half of entry_tree). A
// writer is held to the entry outputs ready per block interval: set
// entry_ahead to the puts one block interval must absorb, and the
// gateway keeps that many ready across as many trees of entry_tree
// outputs as it takes, each entry carrier carrying only its own tree.
PieceWorkers int `json:"piece_workers,omitempty"`
PieceAhead int `json:"piece_ahead,omitempty"`
EntryAhead int `json:"entry_ahead,omitempty"`
// Race is the hold race, settlement and reclaim the gateway runs in the
// background for its own puts.
Race RaceConfig `json:"race"`
// StoreBytes bounds the local closures kept for reading the gateway's
// own writes and for copies.
StoreBytes int64 `json:"store_bytes"`
// OutboxBytes bounds what each identity's outbox may owe its targets
// (a provider that is down) before a put is refused with 503
// SlowDown; 0 is 8 GiB.
OutboxBytes int64 `json:"outbox_bytes,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), with mutex and
// block profiling on.
PprofListen string `json:"pprof_listen,omitempty"`
}
Config is the gateway's configuration file, JSON; an unknown key is refused. Every field has a default but Data, Hosts, Identities, AccessKeys and Buckets.
func LoadConfig ¶
LoadConfig reads and checks a configuration file.
func (*Config) IdentityDir ¶
IdentityDir is an identity's directory.
type Key ¶
type Key struct {
ID string
Secret string
Identity string
// Buckets are the S3 bucket names the key may use; empty is every
// configured bucket.
Buckets map[string]bool
}
Key is one access key.
type Limits ¶
type Limits struct {
// MaxObject bounds a PutObject body; MaxUpload a multipart upload's
// assembled object; MaxPart one part; MaxParts the part numbers.
MaxObject int64 `json:"max_object"`
MaxUpload int64 `json:"max_upload"`
MaxPart int64 `json:"max_part"`
MaxParts int `json:"max_parts"`
// Uploads open at once, in all and per access key; UploadSeconds how
// long one may stay open.
Uploads int `json:"uploads"`
UploadsPerKey int `json:"uploads_per_key"`
UploadSeconds int `json:"upload_seconds"`
// Writes are puts, copies and completions at once; PartWrites part
// uploads at once; Reads object reads at once. Past each the gateway
// answers 503 SlowDown.
Writes int `json:"writes"`
PartWrites int `json:"part_writes"`
Reads int `json:"reads"`
// PartWriters is how many part blobs are written to the disk at once,
// across every upload: parts in flight are hashed as they stream in
// and queue for a writer, so the drive sees this many streams, not one
// per part. Default 2.
PartWriters int `json:"part_writers"`
// Stages are put and copy bodies streaming in at once; Lookups the
// heads, gets and listings asking hosts at once.
Stages int `json:"stages"`
Lookups int `json:"lookups"`
// MinRate is the slowest a request body may arrive, bytes a second
// averaged after its first IdleSeconds; slower is cut off.
MinRate int64 `json:"min_rate"`
// ReplayPerKey bounds the signatures one access key has remembered
// against replay; past it that key's writes are refused with SlowDown.
// A signature is remembered for the 15 minutes it could be replayed,
// so this bounds a key's sustained writes to ReplayPerKey / 900 a
// second. The default is one replay window at RequestsPerSec, so the
// request rate, not this, is what holds a key back.
ReplayPerKey int `json:"replay_per_key"`
// RequestsPerSec and Burst bound the requests of one access key.
RequestsPerSec float64 `json:"requests_per_sec"`
Burst float64 `json:"burst"`
// IdleSeconds is the longest a request body or a response may stall.
IdleSeconds int `json:"idle_seconds"`
// DeleteKeys bounds one DeleteObjects request.
DeleteKeys int `json:"delete_keys"`
}
Limits are the gateway's hardening; zero takes the default.
type Options ¶
type Options struct {
Now func() time.Time
Logf func(format string, args ...any)
// Tick paces the background work.
Tick time.Duration
// LockWait is how long an identity another process has open (a
// command run against it) is waited for at start.
LockWait time.Duration
}
Options are what an embedding caller may set beyond the configuration.
type RaceConfig ¶ added in v0.3.0
type RaceConfig struct {
// Off leaves races to the command line, run against a stopped gateway.
Off bool `json:"off,omitempty"`
// WindowSeconds is the race window (default an hour); TickSeconds the
// pause between passes (default 10).
WindowSeconds int64 `json:"window_seconds,omitempty"`
TickSeconds int `json:"tick_seconds,omitempty"`
// Budget is the most paid for one settlement challenge a provider
// prices (default 0: only free answers).
Budget uint64 `json:"budget,omitempty"`
// NoPublish keeps failed challenges unpublished as outcome records.
NoPublish bool `json:"no_publish,omitempty"`
// Parallel is how many open races a pass steps at once (default 8).
Parallel int `json:"parallel,omitempty"`
}
RaceConfig is the gateway's background race (spec section 9.4): for each identity's own puts with a bounty, the race judged, settled by rank once closed, the remittances sent, and the hold output reclaimed after the deadline when nothing settled, as `bstore holds`, `settle` and `reclaim` would. On by default.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is one running gateway.
func New ¶
New opens a gateway over a checked configuration: every identity's wallet (bstore s3d init creates them), its funding trees and outbox, the local store and the state.