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
- Variables
- func CheckNoSync(raw string) error
- type AdChain
- type Config
- type Mounted
- type Query
- type Refused
- type Service
- func (*Service) AdmissionMode() bmodule.AdmissionMode
- func (s *Service) Counts() map[siterec.Claim]int
- func (*Service) GetDocumentation() string
- func (*Service) GetMetaData() *overlay.MetaData
- func (s *Service) Lookup(_ context.Context, q *lookup.LookupQuestion) (*lookup.LookupAnswer, error)
- func (s *Service) OutputAdmittedByTopic(ctx context.Context, p *bmodule.OutputAdmittedByTopic) error
- func (s *Service) OutputEvicted(_ context.Context, op *transaction.Outpoint) error
- func (s *Service) OutputSpent(_ context.Context, p *bmodule.OutputSpent) error
- func (s *Service) Restore(ctx context.Context, outputs []bmodule.Output, storage bmodule.RestoreStorage) (int, error)
- func (s *Service) Sites() int
- func (*Service) SpendNotificationMode() bmodule.SpendNotificationMode
- type TopicManager
- func (t *TopicManager) Admit(ctx context.Context, raw []byte, held []int) (overlay.AdmittanceInstructions, error)
- func (t *TopicManager) GetDocumentation() string
- func (t *TopicManager) GetMetaData() *overlay.MetaData
- func (t *TopicManager) IdentifyAdmissibleOutputs(ctx context.Context, _ *transaction.Beef, _ *chainhash.Hash, ...) (overlay.AdmittanceInstructions, error)
- func (*TopicManager) IdentifyNeededInputs(context.Context, *transaction.Beef, *chainhash.Hash) ([]*transaction.Outpoint, error)
Constants ¶
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.
const MaxAnswer = 1000
MaxAnswer bounds the outputs one answer lists.
const MaxSites = 4096
MaxSites bounds BWEB_SITES: each site is a topic.
const Name = "bweb"
Name is the module's name, as a host's module list names it.
Variables ¶
var Build = "unversioned"
Build is the version the host logs; a binary sets it.
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).
var Kinds = []string{KindSite, KindTokens, KindHost, KindTerms, KindAds, KindOutcomes, KindAdChain}
Kinds lists every kind, for documentation and metrics.
Functions ¶
func CheckNoSync ¶
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 Mounted ¶
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.
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 ¶
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.
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 ¶
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) GetDocumentation ¶
GetDocumentation implements module.LookupService.
func (*Service) GetMetaData ¶
GetMetaData implements module.LookupService.
func (*Service) Lookup ¶
func (s *Service) Lookup(_ context.Context, q *lookup.LookupQuestion) (*lookup.LookupAnswer, error)
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 ¶
OutputEvicted implements module.LookupService.
func (*Service) OutputSpent ¶
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) SpendNotificationMode ¶
func (*Service) SpendNotificationMode() bmodule.SpendNotificationMode
SpendNotificationMode implements module.LookupService.
type TopicManager ¶
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 ¶
func (*TopicManager) IdentifyNeededInputs(context.Context, *transaction.Beef, *chainhash.Hash) ([]*transaction.Outpoint, error)
IdentifyNeededInputs implements module.InputIdentifier: nothing, since a token carries its parent, a carrier its funding tree and a mined record its own proof.