{"modulePath":"github.com/lightwebinc/bweb","version":"v0.10.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package module\n\nPackage module is bweb's overlay module, against bcommon's engine-neutral contract: tm\\_bweb\\_\\\u003csite\u003e for each site BWEB\\_SITES names, and ls\\_bweb for all of them. A Go overlay host mounts it as it mounts bstore's.\n\n| 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)                    |\n\n## Constants\n\n```go\nconst (\n\tKindSite     = \"site\"     // the site's latest token, unspent; nothing once closed\n\tKindTokens   = \"tokens\"   // every token the host holds of the site, by seq\n\tKindHost     = \"host\"     // the latest token of each public site that names the host\n\tKindTerms    = \"terms\"    // terms of the site's owner whose hosting output is unspent\n\tKindAds      = \"ads\"      // unspent advertisements for the site, not expired\n\tKindOutcomes = \"outcomes\" // outcomes for the site, newest first; of one advertisement with Ad\n\tKindAdChain  = \"ad-chain\" // freeform: an advertisement's first sight and renewal\n)\n```\nThe kinds of question.\n\n```go\nconst MaxAnswer = 1000\n```\nMaxAnswer bounds the outputs one answer lists.\n\n```go\nconst MaxSites = 4096\n```\nMaxSites bounds BWEB\\_SITES: each site is a topic.\n\n```go\nconst Name = \"bweb\"\n```\nName is the module's name, as a host's module list names it.\n\n## Variables\n\n```go\nvar Build = \"unversioned\"\n```\nBuild is the version the host logs; a binary sets it.\n\n```go\nvar ErrNoSubmission = errors.New(\"bweb: the host did not hand the manager the submission's bytes (bcommon module.WithSubmission)\")\n```\nErrNoSubmission is a host that hands the manager a parsed BEEF without the submission's bytes (bcommon module.WithSubmission).\n\n```go\nvar Kinds = []string{KindSite, KindTokens, KindHost, KindTerms, KindAds, KindOutcomes, KindAdChain}\n```\nKinds lists every kind, for documentation and metrics.\n\n## Functions\n\n```go\nfunc CheckNoSync(raw string) error\n```\nCheckNoSync 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.\n\n## Types\n\n```go\ntype AdChain struct {\n\tAd          string `json:\"ad\"`\n\tFirst       string `json:\"first\"`\n\tFirstHeight uint32 `json:\"firstHeight\"`\n\tHeight      uint32 `json:\"height\"`\n\tSpent       bool   `json:\"spent\"`\n\tRenewedBy   string `json:\"renewedBy,omitempty\"`\n}\n```\nAdChain 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.\n\n```go\ntype Config struct {\n\tSites      [][32]byte\n\tHeadersURL string\n\tMaxBEEF    int\n}\n```\nConfig is the module's configuration.\n\n```go\nfunc ParseConfig(getenv func(string) string) (*Config, error)\n```\nParseConfig reads the configuration from getenv.\n\n```go\ntype Mounted struct {\n\tModule bmodule.Module\n\tLS     *Service\n\t// contains filtered or unexported fields\n}\n```\nMounted is the module for one configuration.\n\n```go\nfunc Mount(host bmodule.Host, c *Config, hdrs chaintracker.ChainTracker, now func() time.Time) (*Mounted, error)\n```\nMount builds the module for c. hdrs replaces the configured header source and now the clock, for tests.\n\n```go\nfunc New(host bmodule.Host, getenv func(string) string) (*Mounted, error)\n```\nNew is the factory a host calls: the configuration from getenv, checked against OVERLAY\\_SYNC\\_PEERS.\n\n```go\nfunc (m *Mounted) Start(ctx context.Context) error\n```\nStart runs the module's background work until ctx ends: none yet.\n\n```go\ntype Query struct {\n\tKind string `json:\"kind\"`\n\tSite string `json:\"site,omitempty\"`\n\tHost string `json:\"host,omitempty\"`\n\tAd   string `json:\"ad,omitempty\"`\n}\n```\nQuery 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 \"\\\u003ctxid\u003e.\\\u003cvout\u003e\".\n\n```go\ntype Refused struct {\n\tReason string\n\tDetail string\n}\n```\nRefused 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.\n\n```go\nfunc (r *Refused) Error() string\n```\n\n```go\ntype Service struct {\n\n\t// Tip is the header source's height, which tells terms past their\n\t// deadline from open ones; nil (or an answer that fails) filters none.\n\t// It is read at most every tipEvery.\n\tTip func(context.Context) (uint32, error)\n\t// contains filtered or unexported fields\n}\n```\nService is ls\\_bweb: every site this host carries, indexed from what its topics admit, rebuilt from the host's rows at startup (Restore).\n\n```go\nfunc NewService(host bmodule.Host, now func() time.Time) *Service\n```\nNewService is an empty index. now is the clock an advertisement's expiry is read against; nil is time.Now.\n\n```go\nfunc (*Service) AdmissionMode() bmodule.AdmissionMode\n```\nAdmissionMode implements module.LookupService: the whole transaction, since an advertisement's renewal is read from its inputs.\n\n```go\nfunc (s *Service) Counts() map[siterec.Claim]int\n```\nCounts is what the index holds, by claim.\n\n```go\nfunc (*Service) GetDocumentation() string\n```\nGetDocumentation implements module.LookupService.\n\n```go\nfunc (*Service) GetMetaData() *overlay.MetaData\n```\nGetMetaData implements module.LookupService.\n\n```go\nfunc (s *Service) Lookup(ctx context.Context, q *lookup.LookupQuestion) (*lookup.LookupAnswer, error)\n```\nLookup implements module.LookupService. Every kind but ad-chain is a formula answer, outpoints the engine hydrates with their proofs.\n\n```go\nfunc (s *Service) OutputAdmittedByTopic(ctx context.Context, p *bmodule.OutputAdmittedByTopic) error\n```\nOutputAdmittedByTopic 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.\n\n```go\nfunc (s *Service) OutputEvicted(_ context.Context, op *transaction.Outpoint) error\n```\nOutputEvicted implements module.LookupService.\n\n```go\nfunc (s *Service) OutputSpent(_ context.Context, p *bmodule.OutputSpent) error\n```\nOutputSpent implements module.SpendListener.\n\n```go\nfunc (s *Service) Restore(ctx context.Context, outputs []bmodule.Output, storage bmodule.RestoreStorage) (int, error)\n```\nRestore 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.\n\n```go\nfunc (s *Service) Sites() int\n```\nSites is how many sites the index holds a row of.\n\n```go\nfunc (*Service) SpendNotificationMode() bmodule.SpendNotificationMode\n```\nSpendNotificationMode implements module.LookupService.\n\n```go\ntype TopicManager struct {\n\tTopic string\n\tSite  [32]byte\n\t// contains filtered or unexported fields\n}\n```\nTopicManager is tm\\_bweb\\_\\\u003csite\u003e, 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.\n\n```go\nfunc NewTopicManager(site [32]byte, host bmodule.Host, headers chaintracker.ChainTracker, maxBEEF int) (*TopicManager, error)\n```\nNewTopicManager makes the manager of one site's topic, siterec.Topic(site).\n\n```go\nfunc (t *TopicManager) Admit(ctx context.Context, raw []byte, held []int) (overlay.AdmittanceInstructions, error)\n```\nAdmit applies the rules to the submission's bytes with the held inputs.\n\n```go\nfunc (t *TopicManager) GetDocumentation() string\n```\nGetDocumentation implements module.TopicManager.\n\n```go\nfunc (t *TopicManager) GetMetaData() *overlay.MetaData\n```\nGetMetaData implements module.TopicManager.\n\n```go\nfunc (t *TopicManager) IdentifyAdmissibleOutputs(ctx context.Context, _ *transaction.Beef, _ *chainhash.Hash, previousCoins []uint32) (overlay.AdmittanceInstructions, error)\n```\nIdentifyAdmissibleOutputs 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.\n\n```go\nfunc (*TopicManager) IdentifyNeededInputs(context.Context, *transaction.Beef, *chainhash.Hash) ([]*transaction.Outpoint, error)\n```\nIdentifyNeededInputs implements module.InputIdentifier: nothing, since a token carries its parent, a carrier its funding tree and a mined record its own proof.\n\n","path":"github.com/lightwebinc/bweb/module","name":"module","synopsis":"Package module is bweb's overlay module, against bcommon's engine-neutral contract: tm_bweb_\u003csite\u003e for each site BWEB_SITES names, and ls_bweb for all of them.","isRedistributable":true}
