module

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 27 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 finger overlay module in Go: tm_finger and ls_finger, 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, built from the Go core: the record is the record package's codec and rules, the token and funding tags and the key derivations are the token package's, the canonical encodings bcommon's.

The module takes no configuration: it manages the one topic tm_finger and serves the one lookup service ls_finger, and a host that mounts it must carry tm_finger. It prices no question, so there is no terms route.

Index

Constants

View Source
const LookupName = "ls_finger"

LookupName is the lookup service the module serves.

View Source
const Name = "finger"

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

View Source
const RebuildDelay = 500 * time.Millisecond

RebuildDelay is how long a burst of arrivals may run before the one rebuild of the chains it causes (see RebuildChains).

View Source
const Topic = "tm_finger"

Topic is the topic the module manages.

Variables

View Source
var AdmitKinds = []string{"token", "carrier", "funding", "spend"}

AdmitKinds are what an accepted submission was. "spend" is a transaction that admits nothing but consumes outputs the topic holds (the sweep of a funding tree): accepted for its inputs alone, and counted so that a sweep is visible on the same series as the objects it retracts.

View Source
var Build = "unversioned"

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

View Source
var ErrQuestion = errors.New(`ls_finger: ask { identityKey: "<66 hex>" }, { identityKey, pending: true } or { identityKey, carrier: "<64 hex>" }`)

ErrQuestion is a question ls_finger does not answer.

View Source
var JoinFailures = []string{
	"bad-record", "bad-lock", "duplicate-create", "no-current", "retired", "rotated",
	"successor-taken", "bad-prev", "bad-witness", "bad-seq", "not-spent", "killed",
}

JoinFailures are why a join was refused, the finger_join_failures_total reason label. "killed" is an object of an identity the kill switch retracted, arriving after the fact.

View Source
var KillReasons = []string{"funding-spent"}

KillReasons are why an identity was killed, the finger_killed_total reason label: one today, a label so that a second can be told apart.

View Source
var RefuseReasons = []string{"not-pushdrop", "bad-tag", "bad-sig", "bad-record", "bad-lock", "mineable", "non-canonical-unlocking", "other"}

RefuseReasons are the refusal vocabulary, the finger_refused_total reason label. Fixed and small because it is a label; the detail goes to the log.

Functions

This section is empty.

Types

type Counts

type Counts struct {
	Tokens, Carriers, Identities, Killed, Funding, Pending int
}

Counts are the service's sizes, for the host's gauges.

type Mounted

type Mounted struct {
	Module bmodule.Module
	TM     *TopicManager
	LS     *Service
}

Mounted is the module: the contract's Module, and its two halves.

func Mount

func Mount(host bmodule.Host, overlayTopics []string) (*Mounted, error)

Mount builds the module for a host. overlayTopics is OVERLAY_TOPICS, when known: a host that does not carry tm_finger has nothing for the module to manage, and is told so rather than mounting a manager for a topic it refuses.

func New

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

New is the factory a host calls, with OVERLAY_TOPICS from getenv.

type Service

type Service struct {

	// RebuildDelay is how long a burst of arrivals may run before the one
	// rebuild it causes.
	RebuildDelay time.Duration
	// contains filtered or unexported fields
}

Service is ls_finger, the join and the enforcement point (spec section 7).

The topic manager admits each object on its own validity; this service pairs a token with the carrier it commits to and checks the chain: the record's rules, the token's lock under the identity's profile derivation, prev naming the current carrier, the revealed witness hashing to the current commitment, the sequence advancing by one, and the new token having spent the current one. A join that fails does not become current: the previous state stays current and the failure is counted by reason.

It is also where the kill switch lands (spec sections 3 and 9). A carrier spends a funding output; a mined transaction that spends the same output makes the carrier a double spend and retracts the record. The service keeps funding outpoint to carrier and, on a spend of a funding outpoint by any final txid other than its carrier's, drops every state that carrier is part of. A killed identity answers nothing afterwards, and a token or carrier of it delivered late is refused rather than re-indexed.

Arrival order is unconstrained. A token with no carrier yet is pending; a carrier with no token yet waits; a transition that arrives before the one it follows is retried when that one joins. The index is in memory and derived from the engine's own storage, which holds every admitted output durably, so Restore rebuilds it from the unspent outputs on start and re-reads each carrier's funding outpoints so that a kill survives a restart.

Commitments are keyed as hex in hash byte order, the order the token carries and a transaction id's bytes hold. The engine's txid strings are display order, reversed, so a carrier's key is its txid reversed.

It indexes what tm_finger admitted and the spends of what tm_finger holds. An engine tells every lookup service of every topic's admissions and spends; the TypeScript service keeps what it hears of other topics too, which grows with every object a host admits and changes no answer.

func NewService

func NewService(host bmodule.Host) *Service

NewService makes ls_finger, presetting every join failure and kill reason at zero.

func (*Service) AdmissionMode

func (*Service) AdmissionMode() bmodule.AdmissionMode

AdmissionMode implements module.LookupService: whole-tx, because a carrier's kill switch is its INPUT, which a locking-script payload does not carry.

func (*Service) Answer

func (s *Service) Answer(query json.RawMessage) ([]transaction.Outpoint, error)

Answer is one question's outpoints, in the order the answer gives them.

func (*Service) Counts

func (s *Service) Counts() Counts

Counts reads the sizes.

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) Lookup

Lookup implements module.LookupService: three questions,

{ identityKey: "<66 hex>" }                  the current token, the
                                             current carrier, and the
                                             previous carrier if any
{ identityKey: "<66 hex>", pending: true }   the same, plus any token
                                             under that identity's
                                             profile key whose carrier
                                             has not arrived
{ identityKey: "<66 hex>", carrier: "<64 hex>" }
                                             that carrier, when this
                                             host holds it under that
                                             identity

The previous carrier is always answered (spec section 7): a reader checks the witness against it. The engine hydrates each outpoint as BEEF; the record is inside the carrier's. A killed identity answers nothing.

func (*Service) OutputAdmittedByTopic

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

OutputAdmittedByTopic implements module.LookupService.

func (*Service) OutputEvicted

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

OutputEvicted implements module.LookupService.

func (*Service) OutputSpent

func (s *Service) OutputSpent(_ context.Context, p *bmodule.OutputSpent) error

OutputSpent implements module.SpendListener. The engine reports every spend of a held output, including by a submission the topic manager refused, and names only its txid: enough for the spend link, never enough to kill (see noteInputs).

func (*Service) RebuildChains

func (s *Service) RebuildChains()

RebuildChains re-derives every identity's chain from what is already indexed, the way Restore does, without reading storage.

A host that joins late (one that catches up from a peer, or is fed a backlog by hand) receives unspent outputs only: every carrier, since carriers are never spent, but only the CURRENT token of each identity, because every earlier one was spent by its successor. Live, a transition joins only with its token and only after the one before it, so the create, whose token is spent, never joins, and everything after it is refused no-current for good. The walk is Restore's: carriers by ascending sequence, each with its token when there is one, so the chain is checked by prev, witness and sequence and the current state gets its token.

It runs once after a burst of no-current refusals settles, and never during a restore. Kills are kept: the killed sets are not touched, and advance refuses a killed identity's carriers as it does live.

func (*Service) Restore

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

Restore implements module.Restorer: it rebuilds every index from the unspent outputs of tm_finger, in a deterministic order. Every funding output, carrier and token is indexed first; then each carrier's funding outpoints are re-read from storage and a carrier whose funding output was spent by any txid other than its own is killed, exactly as a live spend would have; then the carriers left are advanced by ascending sequence of their record (ties by commitment), each with its token when the token row is present, so a create always precedes its updates whatever order storage returned the rows in. Spent tokens are not among the rows and are not needed for the chain: a record's prev names the previous carrier, and carriers are never spent.

A carrier's funding outpoints come from its row's OutputsConsumed, which the engine fills with the previous coins the topic manager retained at admission; a carrier admitted while its funding output was not in storage has none, and then there is no spend for storage to have seen either. A storage failure here is returned: a restore that skipped the kill check would bring retracted records back, and the host's rule is to refuse to start rather than start wrong. Rows of other topics are not read.

func (*Service) Restored

func (s *Service) Restored() bool

Restored is whether the index has been rebuilt from storage.

func (*Service) SpendNotificationMode

func (*Service) SpendNotificationMode() bmodule.SpendNotificationMode

SpendNotificationMode implements module.LookupService: txid, which is what tells the join which token spent the current one.

type TopicManager

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

TopicManager is tm_finger: it admits each object on its own validity (spec section 7): a state token whose field signature verifies, the one record output of a carrier whose record decodes, whose lock is the identity's record key, whose signature verifies and which cannot be mined, and every funding output, so that a later spend of a funding output is one the engine sees and reports.

It cannot check the token's lock derivation, because the identity key is not in the token; that check, and every rule that needs the previous state, is the lookup service's. Its verdict never depends on what the host holds, so a refusal is returned, and recorded, rather than raised: the same object refused again is refused again.

func NewTopicManager

func NewTopicManager(host bmodule.Host) *TopicManager

NewTopicManager makes tm_finger, presetting every admission kind and refusal reason at zero: a lane refusing everything looks busier than a healthy one, and an alert needs the zero to compare against.

func (*TopicManager) Admit

func (t *TopicManager) Admit(beef []byte, previousCoins []uint32) overlay.AdmittanceInstructions

Admit decides one submission's BEEF with the previous coins (by input index), as the TypeScript manager's identifyAdmissibleOutputs does. It never fails: whatever arrived from an open plane is the sender's problem, not a host fault.

func (*TopicManager) GetDocumentation

func (*TopicManager) GetDocumentation() string

GetDocumentation implements module.TopicManager.

func (*TopicManager) GetMetaData

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

GetMetaData implements module.TopicManager.

func (*TopicManager) IdentifyAdmissibleOutputs

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

IdentifyAdmissibleOutputs implements bcommon's module.TopicManager. The rules read the submission as it arrived (bcommon module.WithSubmission), as the TypeScript manager reads the submitted BEEF; a host that does not hand the bytes over is answered from the parsed BEEF's transaction.

func (*TopicManager) IdentifyNeededInputs

IdentifyNeededInputs implements module.InputIdentifier: nothing is needed, since each object is admitted on its own validity.

Jump to

Keyboard shortcuts

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