module

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 22 Imported by: 1 module, 1 package

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 bweb's overlay module, against bcommon's engine-neutral contract: tm_bweb_<site> for each site BWEB_SITES names, and ls_bweb for all of them. A Go overlay host mounts it as it mounts bstore's.

| Variable | Meaning | | BWEB_SITES | site ids, lower-case hex, comma separated: the topics mounted | | BWEB_HEADERS_URL | a native header source proofs are checked against; else | | | OVERLAY_CHAIN_TRACKER_URL when it is an http or https URL | | BWEB_MAX_BEEF | the BEEF bound, at least 262144 (the default) |

Index

Constants

View Source
const (
	KindSite     = "site"     // the site's latest token, unspent; nothing once closed
	KindTokens   = "tokens"   // every token the host holds of the site, by seq
	KindHost     = "host"     // the latest token of each public site that names the host
	KindTerms    = "terms"    // terms of the site's owner whose hosting output is unspent
	KindAds      = "ads"      // unspent advertisements for the site, not expired
	KindOutcomes = "outcomes" // outcomes for the site, newest first; of one advertisement with Ad
	KindAdChain  = "ad-chain" // freeform: an advertisement's first sight and renewal
)

The kinds of question.

View Source
const MaxAnswer = 1000

MaxAnswer bounds the outputs one answer lists.

View Source
const MaxSites = 4096

MaxSites bounds BWEB_SITES: each site is a topic.

View Source
const Name = "bweb"

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

Variables

View Source
var Build = "unversioned"

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

View Source
var ErrNoSubmission = errors.New("bweb: 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).

Kinds lists every kind, for documentation and metrics.

Functions

func CheckNoSync

func CheckNoSync(raw string) error

CheckNoSync refuses OVERLAY_SYNC_PEERS naming a bweb topic: a site token is admitted only with its parent, which synchronizing unspent outputs does not carry, so a node takes a site's records as they are published (by interest), never by sync.

Types

type AdChain

type AdChain struct {
	Ad          string `json:"ad"`
	First       string `json:"first"`
	FirstHeight uint32 `json:"firstHeight"`
	Height      uint32 `json:"height"`
	Spent       bool   `json:"spent"`
	RenewedBy   string `json:"renewedBy,omitempty"`
}

AdChain is the ad-chain answer: what a proof cannot show, the first advertisement of a renewal chain (whose block ranks the chain in a race) and whether this one is spent or renewed.

type Config

type Config struct {
	Sites      [][32]byte
	HeadersURL string
	MaxBEEF    int
}

Config is the module's configuration.

func ParseConfig

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

ParseConfig reads the configuration from getenv.

type Mounted

type Mounted struct {
	Module bmodule.Module
	LS     *Service
	// contains filtered or unexported fields
}

Mounted is the module for one configuration.

func Mount

func Mount(host bmodule.Host, c *Config, hdrs chaintracker.ChainTracker, now func() time.Time) (*Mounted, error)

Mount builds the module for c. hdrs replaces the configured header source and now the 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_SYNC_PEERS.

func (*Mounted) Start

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

Start runs the module's background work until ctx ends: none yet.

type Query

type Query struct {
	Kind string `json:"kind"`
	Site string `json:"site,omitempty"`
	Host string `json:"host,omitempty"`
	Ad   string `json:"ad,omitempty"`
}

Query is a question to ls_bweb, as JSON. Kind is one of the Kinds; Site is a site id in lower-case hex; Host a host name; Ad an outpoint as "<txid>.<vout>".

type Refused

type Refused struct {
	Reason string
	Detail string
}

Refused is raised for every refusal, so the engine stores nothing and marks nothing spent. A refusal returned as empty instructions would be recorded as applied, and a later submission of the same txid never shown to a manager again: anyone could suppress a genuine token by submitting it first in a different BEEF, and a token refused while the host's headers lagged would stay refused.

func (*Refused) Error

func (r *Refused) Error() string

type Service

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

Service is ls_bweb: every site this host carries, indexed from what its topics admit, rebuilt from the host's rows at startup (Restore).

func NewService

func NewService(host bmodule.Host, now func() time.Time) *Service

NewService is an empty index. now is the clock an advertisement's expiry is read against; nil is time.Now.

func (*Service) AdmissionMode

func (*Service) AdmissionMode() bmodule.AdmissionMode

AdmissionMode implements module.LookupService: the whole transaction, since an advertisement's renewal is read from its inputs.

func (*Service) Counts

func (s *Service) Counts() map[siterec.Claim]int

Counts is what the index holds, by claim.

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. Every kind but ad-chain is a formula answer, outpoints the engine hydrates with their proofs.

func (*Service) OutputAdmittedByTopic

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

OutputAdmittedByTopic implements module.LookupService. What a topic manager admitted is indexed; an output the index cannot read (which the manager would not have admitted) is logged and left out, never an error that would fail the engine's admission.

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.

func (*Service) Restore

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

Restore implements module.Restorer: the index from the host's unspent rows, oldest block first, so a renewal finds the advertisement it renews. A renewal whose predecessor is spent (and so not among the rows) reads it through storage.

func (*Service) Sites

func (s *Service) Sites() int

Sites is how many sites the index holds a row of.

func (*Service) SpendNotificationMode

func (*Service) SpendNotificationMode() bmodule.SpendNotificationMode

SpendNotificationMode implements module.LookupService.

type TopicManager

type TopicManager struct {
	Topic string
	Site  [32]byte
	// contains filtered or unexported fields
}

TopicManager is tm_bweb_<site>, one site's topic. The rules are siterec.Admit's, on the submission's own bytes and the host's headers; nothing the topic holds is read.

func NewTopicManager

func NewTopicManager(topic string, host bmodule.Host, headers chaintracker.ChainTracker, maxBEEF int) (*TopicManager, error)

NewTopicManager makes the manager of one site's topic.

func (*TopicManager) Admit

func (t *TopicManager) Admit(ctx context.Context, raw []byte, held []int) (overlay.AdmittanceInstructions, error)

Admit applies the rules to the submission's bytes with the held inputs.

func (*TopicManager) GetDocumentation

func (t *TopicManager) GetDocumentation() string

GetDocumentation implements module.TopicManager.

func (*TopicManager) GetMetaData

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

GetMetaData implements module.TopicManager.

func (*TopicManager) IdentifyAdmissibleOutputs

func (t *TopicManager) 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: the rules read the wire form (which transactions a BEEF carries, with which proofs), which a parsed and merged BEEF no longer shows.

func (*TopicManager) IdentifyNeededInputs

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

Jump to

Keyboard shortcuts

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