module

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 35 Imported by: 0 modules, 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 module is the bstore overlay module in Go: `tm_bstore_<bucket>` for each configured bucket, `tm_bstoreblob_<bucket>` where the host's topics name one, and `ls_bstore` for all of them, written to bcommon's engine-neutral contract (github.com/lightwebinc/bcommon/module) so that any Go overlay host that carries the adapter mounts it. It is the twin of the TypeScript module under host/src (frozen), built from the Go core: the admission rules are storerec.Admit, the fold and the map answers storerec's, and the questions storerec's classes.

Configuration is the TypeScript module's, read from the environment when the host calls the factory (docs/host.md): BSTORE_BUCKETS, BSTORE_STATE_DIR, BSTORE_HEADERS_URL, BSTORE_SERVED, BSTORE_KEEP_DAYS, BSTORE_PENDING_DAYS, BSTORE_OTHER_HOURS, BSTORE_MAX_BEEF, BSTORE_MAX_SWEEP_INPUTS, BSTORE_LISTEN, BSTORE_PRICES, BSTORE_PAYEE_KEY, BSTORE_SESSIONS, BSTORE_SESSION_TTL, the handshake and response budgets, BSTORE_ARCADE_URL, BSTORE_ASSET_URL, BSTORE_CHAIN, BSTORE_WOC_KEY and the BSTORE_ACCEPT_* rule, and one of its own, BSTORE_JOURNAL_SYNC_MS (the rows journal's group commit window). Every mistake is an error, and the host refuses to start.

Index

Constants

View Source
const (
	FloorKeepDays    = 31
	FloorPendingDays = 7
	FloorOtherHours  = 24
)

The retention floors (spec section 12.3): the long floor, the floor of unnamed entries, and everything else.

View Source
const (
	DefaultJournalSyncMs = 100
	MaxJournalSyncMs     = 60_000
)

The rows journal's group commit window (BSTORE_JOURNAL_SYNC_MS): lines are written at once and fsynced together this often, off the lookup service's lock; 0 fsyncs each line before the admission goes on. The default and the bound are the engine store's (OVERLAY_STORE_WAL_SYNC_MS).

View Source
const (
	// PageLimit is the outputs of a page of ads, unanchored, outcomes,
	// outcome-history, history and chain (tokens, for history and chain).
	PageLimit = 64
	// PerSeq is the tokens answered at one seq and kept at one seq of a
	// chain; PerSmall the classes answered eight at a time (pending, ad,
	// fronts, front, sweep).
	PerSeq   = 8
	PerSmall = 8
	// UnanchoredDays is how far back unanchored answers by admission;
	// OutcomeWindowDays the same for outcomes and its kin.
	UnanchoredDays    = 7
	OutcomeWindowDays = 31
	// FrontsPerAdvertiser is the front statements kept the long floor per
	// advertiser of a root the map names, by first sight.
	FrontsPerAdvertiser = 16
	// ReorgDepth is how many seqs below the highest the latest tokens are
	// looked for among those whose proof verifies, before the highest is
	// taken.
	ReorgDepth = 64
	// ChoiceTTL is how long the latest tokens found against the headers
	// are reused.
	ChoiceTTL = time.Minute
	// SettleMs is how long a drop waits for the engine to record the
	// admission it drops.
	SettleMs = time.Minute
)

The index's bounds (spec section 12.2 to 12.4).

View Source
const (
	PruneEvery = time.Hour
	FlushEvery = 2 * time.Second
	WatchEvery = 30 * time.Second
)

How often retention runs; how often drops still waiting are tried again (and the payment watch, at most every WatchEvery).

View Source
const (
	ReplayPendingMargin = 24 * time.Hour
	ReplayOtherMargin   = time.Hour
	ReplayMinedBlocks   = 4032
	// ReplaySkew is how far ahead of the host's clock a record may be dated
	// and still be replayed.
	ReplaySkew = 5 * time.Minute
)

The margins and the window above.

View Source
const DefaultListenPort = 8294

DefaultListenPort is the terms route's port on the Go host. The TypeScript host's is 8094; the Go engine runs beside it on the same hosts until a cutover, so the Go route takes its own.

View Source
const FlushChunk = 64

FlushChunk is how many drops one hold of the lock deletes in a Flush.

View Source
const JournalFile = "bstore-rows.jsonl"

JournalFile is the journal's file name in the state directory.

View Source
const Name = "bstore"

Name is the module's name, as a host's module list names it.

View Source
const RecentAdmissions = 4096

RecentAdmissions is how many admitted txids a manager remembers to count each once.

Variables

View Source
var AdmitKinds = []string{"entry", "outcome", "front", "bucket-token", "mined", "sweep"}

AdmitKinds are what an admitted transaction was.

View Source
var Build = "unversioned"

Build is the version the host logs; a binary sets it.

View Source
var Classes = func() []termsroute.PricedClass {
	out := make([]termsroute.PricedClass, len(storerec.Classes))
	for i, c := range storerec.Classes {
		out[i] = termsroute.PricedClass{Name: c.Name, Free: c.Free}
	}
	return out
}()

Classes are the lookup classes as the route prices them, in the order of spec section 11.1.

View Source
var DropReasons = []string{"retracted", "retention", "second-carrier", "unmatched-sweep"}

DropReasons are why the index drops an object.

View Source
var ErrNoSubmission = errors.New("bstore: the host did not hand the manager the submission's bytes (bcommon module.WithSubmission)")

ErrNoSubmission is a host that hands the manager a parsed BEEF without the submission's bytes (bcommon module.WithSubmission): the manager decides on the wire form (which transactions a BEEF carries, in what order, with which proofs), which a parsed and merged BEEF no longer shows.

View Source
var KindsReplayed = []string{replay.KindToken, "entry", "ad", "hold", "front", "outcome", "sweep"}

KindsReplayed are the kinds a walk answers objects as.

View Source
var Reasons = []string{
	"too-large", "cbor", "key-type", "magic", "missing", "type", "bucket", "identity", "seq", "writers", "changes", "count", "created",
	"consumed", "first", "objkey", "kind", "size", "profile", "content-type", "etag", "meta", "hold", "empty", "request", "outcome",
	"response-signature", "url", "shape", "beef", "mineable", "unlock", "lock", "signature", "funding", "unmined", "token-input",
	"bucket-id", "too-many", "piece", "not-bstore", "host-config", "range", "list",
}

Reasons are every label a host counts a refused submission by: the record rules of spec sections 3.2, 4.2, 8.1 and 8.2 and the transaction rules of section 12.1. A reader's labels and query are never an admission verdict.

View Source
var TokenStatuses = []string{"pending", "rooted", "consistent", "map-mismatch"}

TokenStatuses are the token statuses the index reports, each counted.

Functions

func CheckNoSync

func CheckNoSync(raw string) error

CheckNoSync refuses a host configured to synchronise a tm_bstore_ or tm_bstoreblob_ topic with a peer (OVERLAY_SYNC_PEERS, topic=url,...;topic=...): that synchronisation carries only unspent outputs, so it never carries a chain's spent tokens, and it drops what a topic manager refuses without trying it again. A host joins a bucket by replay (spec section 12.6).

func ParseBuckets

func ParseBuckets(raw string) ([]string, error)

ParseBuckets parses BSTORE_BUCKETS: bucket identifiers, once each.

func ParseListen

func ParseListen(raw string) (string, error)

ParseListen parses BSTORE_LISTEN, host:port, an IPv6 host in brackets or not, as the TypeScript module reads it; the answer is host:port as Go listens on it.

func ParseServed

func ParseServed(raw string, buckets []string) ([]string, error)

ParseServed parses BSTORE_SERVED: <bucket>:<owner>:<id>, each of a carried bucket, once. The result is <bucket>|<owner>|<id>.

Types

type AppliedChecker

type AppliedChecker interface {
	DoesAppliedTransactionExist(ctx context.Context, txid *chainhash.Hash, topic string) (bool, error)
}

AppliedChecker is a storage that says whether a topic applied a transaction: a drop decided while the engine admits the object waits until the engine has recorded the admission.

type BlobTopicManager

type BlobTopicManager struct {
	Topic  string
	Bucket string
	// contains filtered or unexported fields
}

BlobTopicManager is a bucket's blob topic on a host: it carries pieces only, and no host admits a piece or holds bytes (spec sections 5 and 12.1), so every submission is refused, raised and counted as piece. Mounted only where the operator names the topic, so that the host's default manager never admits anything on it.

func NewBlobTopicManager

func NewBlobTopicManager(topic string, host bmodule.Host) (*BlobTopicManager, error)

NewBlobTopicManager makes the blob manager of one topic.

func (*BlobTopicManager) GetDocumentation

func (t *BlobTopicManager) GetDocumentation() string

GetDocumentation implements module.TopicManager.

func (*BlobTopicManager) GetMetaData

func (t *BlobTopicManager) GetMetaData() *overlay.MetaData

GetMetaData implements module.TopicManager.

func (*BlobTopicManager) IdentifyAdmissibleOutputs

IdentifyAdmissibleOutputs implements module.TopicManager: refused, piece.

func (*BlobTopicManager) IdentifyNeededInputs

IdentifyNeededInputs implements module.InputIdentifier.

type Classified

type Classified struct {
	Q      *storerec.Question
	Priced bool
}

Classified is a question, validated, and whether this host prices it.

type Config

type Config struct {
	Buckets    []string
	StateDir   string
	HeadersURL string
	// Served are the chains this host serves: <bucket>|<owner hex>|<id hex>.
	Served         []string
	KeepDays       int
	PendingDays    int
	OtherHours     int
	MaxBEEF        int
	MaxSweepInputs int
	// JournalSync is the rows journal's group commit window; 0 syncs every
	// line.
	JournalSync time.Duration
	// Listen is the terms route's host:port; empty for none.
	Listen   string
	Prices   map[string]uint64
	PayeeKey *ec.PrivateKey
	Sessions termsroute.SessionBound
	Budget   termsroute.BudgetConfig
	Response termsroute.ResponseBudgetConfig
	Accept   termsroute.AcceptConfig
}

Config is the module's configuration.

func ParseConfig

func ParseConfig(getenv func(string) string) (*Config, error)

ParseConfig reads the whole configuration through getenv.

type Counts

type Counts struct {
	Tokens, PendingTokens, Entries, Outcomes, Fronts, Ads, Holds, Sweeps, SweepOutpoints, Marks, Rows, PendingDrops int
	Tally                                                                                                           tally
}

Counts are the gauges' values.

type Deleter

type Deleter interface {
	DeleteOutput(ctx context.Context, outpoint *transaction.Outpoint, topic string) error
}

Deleter is a storage that can delete an output: what drops need beyond the contract's RestoreStorage. A host whose storage cannot delete keeps what the index dropped, unanswered.

type Evicter

type Evicter interface {
	DeleteAppliedTransaction(ctx context.Context, txid *chainhash.Hash, topic string) error
}

Evicter is a storage that can forget that a topic applied a transaction, so that the same object offered again is decided afresh. Without it a dropped object offered again is a duplicate the engine never shows the manager.

type FileJournal

type FileJournal struct {
	Dir  string
	Path string
	// SyncEvery is the group commit window; zero syncs every line.
	SyncEvery time.Duration
	// OnSync, when set, is called after each timed fsync with the lines it
	// covered, how long it took and its error. It runs on the timer's
	// goroutine, holding no lock of the journal's.
	OnSync func(lines int, took time.Duration, err error)
	// contains filtered or unexported fields
}

FileJournal is the journal as a file, bstore-rows.jsonl in a directory. Each line is written to the file before Append returns, so a process that dies loses nothing (the line is in the page cache). When it reaches the disk is SyncEvery: zero flushes each line before Append returns; more is a group commit, one fsync for every line written in the window, run by a timer off the caller's path, so a power loss loses at most the window (the posture of the engine's own store, OVERLAY_STORE_WAL_SYNC_MS). Close and Rewrite flush. A last line cut short by a crash is cut off on load; any other line that does not parse stops the load, because a mark or a sweep's outpoint silently skipped could let a retracted carrier be answered again. A rewrite goes to a new file that is flushed and then renamed over the old one, so a crash leaves one or the other whole.

func NewFileJournal

func NewFileJournal(dir string) (*FileJournal, error)

NewFileJournal makes the directory and names the file. The journal syncs every line until SyncEvery is set.

func (*FileJournal) Append

func (j *FileJournal) Append(l Line) error

Append implements Journal: the line is in the file when it returns, and on disk too when SyncEvery is zero; otherwise a timed fsync takes it there within SyncEvery. An error of an earlier timed fsync is returned once, by the next Append, after its line is written.

func (*FileJournal) Close

func (j *FileJournal) Close() error

Close flushes what is pending and closes the file. A later Append opens it again.

func (*FileJournal) Load

func (j *FileJournal) Load() ([]Line, error)

Load implements Journal.

func (*FileJournal) Rewrite

func (j *FileJournal) Rewrite(lines []Line) error

Rewrite implements Journal. Lines pending in the old file need no fsync: the new file holds the state they were part of, and is flushed before it replaces the old one.

func (*FileJournal) Sync

func (j *FileJournal) Sync() error

Sync flushes every line written so far to disk now.

type Formula

type Formula struct {
	Txid    string
	Vout    uint32
	Context []byte
}

Formula is one output an answer names, with its context when the class gives one.

type Front

type Front struct {
	*termsroute.Front
	Addr string
}

Front is the terms route and where it listens.

type Journal

type Journal interface {
	Load() ([]Line, error)
	Append(l Line) error
	// Rewrite replaces everything with lines, atomically.
	Rewrite(lines []Line) error
}

Journal is where the state lives. Rewrite is durable when it returns; Append is durable when it returns or within the journal's sync window (FileJournal.SyncEvery).

type Line

type Line struct {
	K    string
	Op   string
	C    string
	B    string
	Key  string
	At   int64
	Life bool
	S    string
	Txid string
	Vout int64
}

Line is one journal line: what ls_bstore keeps beside the engine's storage (spec sections 12.2 to 12.5), as an append-only journal that retention compacts. The engine's storage holds the outputs a host still keeps; it cannot hold what must outlive them, or what it has no column for: which carrier a funding outpoint admitted first, the input outpoints of every admitted sweep, the retraction marks, when the host first saw each object, and which held outputs a later transaction spent. One JSON object a line:

{"k":"c","op":"<txid>.<vout>","c":"<C>","at":<ms>}          the first carrier admitted on a funding outpoint
{"k":"cf","op":"..."}                                      that row was dropped by retention
{"k":"a","b":"<bucket>","c":"<C>","at":<ms>}               a carrier, first seen
{"k":"af","c":"<C>"}                                       the carrier was dropped
{"k":"x","op":"...","key":"<owner>","at":<ms>,"life":<bool>,"b":"..."}
                                                           a retraction mark (b optional)
{"k":"xl","op":"..."}                                      the mark is kept for the host's life
{"k":"xf","op":"..."}                                      the mark was dropped by retention
{"k":"p","op":"...","s":"<sweep txid>","at":<ms>}          an input outpoint of an admitted sweep
{"k":"pf","op":"..."}                                      that outpoint was dropped by retention
{"k":"t","b":"...","txid":"<txid>","vout":<n>,"at":<ms>}   a bucket token, first seen
{"k":"tf","txid":"<txid>"}                                 the token was dropped
{"k":"o","b":"...","txid":"...","vout":<n>,"at":<ms>}      an advertisement, hold output or sweep output, first seen
{"k":"w","b":"...","txid":"...","vout":<n>}                a held output a later admitted transaction spent
{"k":"of","b":"...","txid":"...","vout":<n>}               the output was dropped

Commitments are in hash byte order and txids in display order, both lowercase hex; keys are 66 hex digits; at is the host's time in Unix milliseconds. Replayed in order the lines rebuild the state; the first line about a thing sets it and a later one only forgets or upgrades it. The bytes are the TypeScript module's, key for key, so one journal reads under either.

type MemoryJournal

type MemoryJournal struct {
	Lines []Line
	// contains filtered or unexported fields
}

MemoryJournal is a journal in memory, for tests and for a host that accepts losing it.

func (*MemoryJournal) Append

func (m *MemoryJournal) Append(l Line) error

Append implements Journal.

func (*MemoryJournal) Load

func (m *MemoryJournal) Load() ([]Line, error)

Load implements Journal.

func (*MemoryJournal) Rewrite

func (m *MemoryJournal) Rewrite(lines []Line) error

Rewrite implements Journal.

type Mounted

type Mounted struct {
	Module bmodule.Module
	LS     *Service
	// Front is the terms route, when configured.
	Front *Front
	// contains filtered or unexported fields
}

Mounted is the module for one configuration: the contract's Module, the lookup service, and what Start runs.

func Mount

func Mount(host bmodule.Host, c *Config, overlayTopics []string, journal Journal, hdrs chaintracker.ChainTracker, now func() time.Time) (*Mounted, error)

Mount builds the module for c. overlayTopics is OVERLAY_TOPICS, when known: a blob topic is mounted only where it names one. journal replaces the state directory's, hdrs the configured header source and now the host's clock, for tests.

func New

func New(host bmodule.Host, getenv func(string) string) (*Mounted, error)

New is the factory a host calls: the configuration from getenv, checked against OVERLAY_TOPICS and OVERLAY_SYNC_PEERS.

func (*Mounted) Close

func (m *Mounted) Close() error

Close flushes the rows journal and closes it (Start does when its context ends). A host that stops without it leaves at most the last sync window's lines in the page cache: written, not yet on disk.

func (*Mounted) Start

func (m *Mounted) Start(ctx context.Context) error

Start serves the terms route (when configured) until ctx ends, and runs the background tick: drops still waiting every FlushEvery, the payment watch every WatchEvery, and retention once the index is restored and every PruneEvery after. It returns when ctx ends, after closing the rows journal (Close).

type Options

type Options struct {
	Buckets []string
	// Served are the chains this host serves: <bucket>|<owner hex>|<id hex>.
	Served  []string
	Host    bmodule.Host
	Journal Journal
	// Priced are the priceable classes this host prices: asked through the
	// engine, they are refused.
	Priced map[string]bool
	// The retention floors; their floors when zero.
	KeepDays, PendingDays, OtherHours int
	Headers                           chaintracker.ChainTracker
	// Now is the host's clock; time.Now when nil.
	Now func() time.Time
	// Trees is the chain view a replay reads a chain's first token's parent
	// from (Replay); nil when the host has none.
	Trees replay.TreeSource
	// MaxBEEF and MaxSweepInputs are the topic managers' bounds, which a
	// replay holds a token it assembles to; storerec's defaults when zero.
	MaxBEEF, MaxSweepInputs int
}

Options build a Service.

type OutputList

type OutputList struct {
	Type    string       `json:"type"`
	Outputs []outputJSON `json:"outputs"`
}

OutputList is the engine's lookup answer as JSON.

type RecordsTopicManager

type RecordsTopicManager struct {
	Topic  string
	Bucket string
	// contains filtered or unexported fields
}

RecordsTopicManager is tm_bstore_<bucket>, the records topic of one bucket (spec section 12.1). The rules are storerec.Admit's; this is the engine seam: it runs them on the submission and turns the verdict into admittance instructions.

The engine records every transaction a topic manager returns instructions for as applied, empty instructions included, and a later submission of the same txid is a duplicate no topic manager is shown again. A refusal returned as empty instructions would therefore be permanent for that txid: anyone could suppress a genuine object by submitting it first in a different BEEF, and a token refused because the host's headers lagged would stay refused. So every refusal is raised, and the engine records nothing and marks nothing spent. No rule reads another topic, another record or anything this topic holds; the previous coins decide only which held outputs an accepted transaction retains: every one, so no admitted output is deleted when something spends it.

func NewRecordsTopicManager

func NewRecordsTopicManager(topic string, host bmodule.Host, headers chaintracker.ChainTracker, maxBEEF, maxSweepInputs int) (*RecordsTopicManager, error)

NewRecordsTopicManager makes the records manager of one topic; a bound below its floor is refused.

func (*RecordsTopicManager) Admit

Admit applies the rules to the submission's bytes with the held inputs, as the TypeScript manager's identifyAdmissibleOutputs does. A verdict Precheck left in ctx for these bytes is finished with held instead.

func (*RecordsTopicManager) GetDocumentation

func (t *RecordsTopicManager) GetDocumentation() string

GetDocumentation implements module.TopicManager.

func (*RecordsTopicManager) GetMetaData

func (t *RecordsTopicManager) GetMetaData() *overlay.MetaData

GetMetaData implements module.TopicManager.

func (*RecordsTopicManager) IdentifyAdmissibleOutputs

func (t *RecordsTopicManager) IdentifyAdmissibleOutputs(ctx context.Context, _ *transaction.Beef, _ *chainhash.Hash, previousCoins []uint32) (overlay.AdmittanceInstructions, error)

IdentifyAdmissibleOutputs implements bcommon's module.TopicManager over the submission's bytes in ctx.

func (*RecordsTopicManager) IdentifyNeededInputs

IdentifyNeededInputs implements module.InputIdentifier: nothing is needed, since a carrier carries its funding tree, a token its parent and a mined object its own proof.

func (*RecordsTopicManager) Precheck

Precheck decides the submission in ctx (bcommon module.WithSubmission) on every rule but the range of its previous coins (storerec.Prepare) and returns ctx carrying the verdict, which Admit finishes under the lock. No rule reads what the topic holds, so a host that runs this before it takes the topic's lock (a Go host's admission pipeline can) holds the lock only for what the topic holds. It counts and logs nothing: Admit does, when the host shows it the transaction.

type Refused

type Refused struct {
	Reason string
	Detail string
}

Refused is raised for every refusal. The engine counts it as a failed topic for this submission and stores nothing.

func (*Refused) Error

func (r *Refused) Error() string

type RouteAnswerer

type RouteAnswerer struct{ LS *Service }

RouteAnswerer is ls_bstore as the terms route asks its questions: a priced answer is hydrated as the engine hydrates one.

func (RouteAnswerer) Answer

Answer implements termsroute.Answerer.

func (RouteAnswerer) Classify

Classify implements termsroute.Answerer.

func (RouteAnswerer) Restored

func (r RouteAnswerer) Restored() bool

Restored implements termsroute.Answerer.

type Service

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

Service is ls_bstore: one lookup service for every bucket a host carries (spec sections 11 and 12.2 to 12.6).

Two stores back it. The engine's storage holds the outputs the host keeps: bucket tokens, entry, outcome and front carriers, advertisements, hold outputs and sweeps' output 0, which this service indexes in memory and rebuilds from storage on start. The journal holds what storage cannot: the first carrier of each funding outpoint, the input outpoints of every admitted sweep, the retraction marks, first sights, and which held outputs a later transaction spent.

Every status is a function of what the host holds, never of arrival order, except where the contract makes it one (the first carrier per funding outpoint, the first 16 front statements, first sights):

  • a token is rooted when the host holds every token from it back to its chain's first by spends, pending until then; a rooted token of a served chain takes the status its branch's fold gives it (consistent, or map-mismatch, sticky). Only rooted, consistent tokens are answered as latest;
  • an entry is anchored while a served chain's current map holds it, replaced once a consistent token named it and the map no longer does, pending while no token of the chain names it, and retracted when an admitted sweep spends its funding outpoint or the outpoint carries a retraction mark. A retracted carrier is dropped at once and never answered;
  • an advertisement is live until a renewal (or any admitted transaction) spends it or its expiry passes the host's clock.

To drop an object is to delete its output from the topic and evict the engine's record that its transaction was applied, so the same object offered again is decided afresh, through the storage a restore is handed (Deleter, Evicter).

func NewService

func NewService(o Options) (*Service, error)

NewService builds ls_bstore and loads the journal.

func (*Service) AdmissionMode

func (*Service) AdmissionMode() bmodule.AdmissionMode

AdmissionMode implements module.LookupService.

func (*Service) Answer

func (s *Service) Answer(ctx context.Context, c *Classified, paid bool) ([]Formula, error)

Answer answers a validated question. paid says the question was paid for (or asked where no payment is due); a class this host prices is refused otherwise.

func (*Service) Classify

func (s *Service) Classify(service string, query []byte) (*Classified, error)

Classify validates a question and names its class, as the terms route and the engine ask it: exactly the members of one class, every value checked, a bucket this host carries, and a chain it serves for a map class; anything else is an error.

func (*Service) Counts

func (s *Service) Counts() Counts

Counts are the gauges' values now.

func (*Service) FirstOn

func (s *Service) FirstOn(op string) (string, bool)

FirstOn is the first carrier the host admitted on funding outpoint op.

func (*Service) Flush

func (s *Service) Flush(ctx context.Context)

Flush deletes dropped outputs from storage and evicts the engine's record that their transactions were applied once the index holds no output of them, so the same object offered again is decided afresh. A drop decided while the engine admits the object waits until the engine has recorded the admission (it records it after the lookup services are told), for at most SettleMs. A store that cannot delete keeps what was dropped, unanswered; a store that cannot evict leaves a dropped object a duplicate when it is offered again. Each is said once in the log.

Flush takes the drops waiting when it starts in chunks of FlushChunk, releasing the lock between chunks: under a put load nearly every object leaves a drop (the entry it supersedes), so one pass every FlushEvery can carry thousands of storage deletes, and admissions (OutputAdmittedByTopic) and lookups wait on the lock while a chunk runs, never for the whole pass. Each drop is decided under the lock when its chunk runs, as before.

func (*Service) GetDocumentation

func (*Service) GetDocumentation() string

GetDocumentation implements module.LookupService.

func (*Service) GetMetaData

func (*Service) GetMetaData() *overlay.MetaData

GetMetaData implements module.LookupService.

func (*Service) HoldsCarrier

func (s *Service) HoldsCarrier(c string) bool

HoldsCarrier is whether the host holds the carrier with commitment c (hash byte order hex).

func (*Service) Hydrate

func (s *Service) Hydrate(ctx context.Context, formulas []Formula) ([]bmodule.HydratedOutput, error)

Hydrate is an answer with each output's BEEF, as the engine hydrates one, read from the host's storage. A context rides along.

func (*Service) Lookup

Lookup implements module.LookupService: asked through the engine, a class the host prices is refused here. The answer is hydrated here and carries each output's context (bcommon module.HydratedOutput).

func (*Service) Mark

func (s *Service) Mark(op string) (key string, at int64, life bool, ok bool)

Mark is the retraction mark of outpoint op, when the host keeps one: its owner, its time and whether it is kept for the host's life.

func (*Service) OutputAdmittedByTopic

func (s *Service) OutputAdmittedByTopic(ctx context.Context, p *bmodule.OutputAdmittedByTopic) error

OutputAdmittedByTopic implements module.LookupService: it indexes an admitted output, then reads back tokens whose predecessor is rooted now. What it drops is deleted by the next Flush, once the engine has recorded the admission.

func (*Service) OutputEvicted

func (s *Service) OutputEvicted(_ context.Context, op *transaction.Outpoint) error

OutputEvicted implements module.LookupService.

func (*Service) OutputNoLongerRetainedInHistory

func (s *Service) OutputNoLongerRetainedInHistory(_ context.Context, op *transaction.Outpoint, topic string) error

OutputNoLongerRetainedInHistory implements module.RetentionListener.

func (*Service) Prune

func (s *Service) Prune(ctx context.Context) int

Prune applies retention at the host's time (spec section 12.3), never against a restore in flight: it drops every carrier, token, advertisement, hold output and sweep whose floor has passed, forgets the outpoints, marks and rows whose floor has passed, ages the windows unanchored, outcomes and ads answer from, and rewrites the journal. It answers how many objects were dropped.

func (*Service) Replay

Replay implements bcommon module.Replayer for tm_bstore_ topics. A blob topic holds nothing (no host admits a piece), so its walk is over at once.

func (*Service) Restore

func (s *Service) Restore(ctx context.Context, outputs []bmodule.Output, storage bmodule.RestoreStorage) (int, error)

Restore implements module.Restorer (spec section 12.5): it rebuilds the index. The journal's state, then every output of this module's topics the host hands over (a row handed without its BEEF is read again with it), then every token and mined output the journal names that the unspent rows did not carry, and then each held token's predecessors through the input that spends them. A token is read as the engine stores it. Chains are rooted and folded from seq 0 whatever order storage returns rows in. A storage failure propagates: a restore that skipped a sweep would answer retracted carriers.

func (*Service) Restored

func (s *Service) Restored() bool

Restored is whether the index is restored and ready to answer.

func (*Service) SpendNotificationMode

func (*Service) SpendNotificationMode() bmodule.SpendNotificationMode

SpendNotificationMode implements module.LookupService.

func (*Service) Swept

func (s *Service) Swept(op string) bool

Swept is whether the host keeps an admitted sweep's spend of outpoint op.

func (*Service) TokenStatus

func (s *Service) TokenStatus(txid string) (string, bool)

TokenStatus is the status of the token with txid (display order), when the host holds it.

Jump to

Keyboard shortcuts

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