Documentation
¶
Overview ¶
Package module is bdns's overlay module, against bcommon's engine-neutral contract: tm_bdns_<z> for each chain BDNS_ZONES names, and ls_bdns for all of them. A Go overlay host mounts it as it mounts bweb's.
| Variable | Meaning | | BDNS_ZONES | identifiers of record sets and origins, lower-case hex, comma | | | separated: the topics mounted | | BDNS_HEADERS_URL | a native header source proofs are checked against; else | | | OVERLAY_CHAIN_TRACKER_URL when it is an http or https URL | | BDNS_MAX_BEEF | the BEEF bound, at least 262144 (the default) |
Index ¶
- Constants
- Variables
- func CheckNoSync(raw string) error
- func ParseZone(s string) ([32]byte, bool)
- type Config
- type Mounted
- type ProofAnswer
- type Query
- type Refused
- type Service
- func (*Service) AdmissionMode() bmodule.AdmissionMode
- func (s *Service) Buffered() int
- func (s *Service) Builds() int64
- func (s *Service) Carry(zone [32]byte) zonerec.View
- func (*Service) GetDocumentation() string
- func (*Service) GetMetaData() *overlay.MetaData
- func (s *Service) Lookup(ctx context.Context, q *lookup.LookupQuestion) (*lookup.LookupAnswer, error)
- func (s *Service) OutputAdmittedByTopic(_ context.Context, p *bmodule.OutputAdmittedByTopic) error
- func (s *Service) OutputEvicted(_ context.Context, op *transaction.Outpoint) error
- func (s *Service) Pieces() int
- func (s *Service) Restore(ctx context.Context, outputs []bmodule.Output, storage bmodule.RestoreStorage) (int, error)
- func (*Service) SpendNotificationMode() bmodule.SpendNotificationMode
- func (s *Service) States() int
- type StateAnswer
- 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 ( KindState = "state" // freeform: the latest state, whether it is mined and renderable KindLog = "log" // the chain's states from a seq onward, as outputs KindLeaves = "leaves" // a state's leaves object: its pieces in order, as outputs KindProof = "proof" // freeform: a proof for a name and type, or a whole name, against the latest state )
The kinds of question.
const MaxAnswer = 1000
MaxAnswer bounds the outputs one answer lists.
const MaxQuestion = 4096
MaxQuestion bounds a question's bytes.
const MaxZones = 4096
MaxZones bounds BDNS_ZONES: each chain is a topic.
const Name = "bdns"
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("bdns: 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{KindState, KindLog, KindLeaves, KindProof}
Kinds lists every kind, for documentation and metrics.
Functions ¶
func CheckNoSync ¶
CheckNoSync refuses OVERLAY_SYNC_PEERS naming a bdns topic: a state is admitted only after the state before it and its leaves, which synchronizing unspent outputs carries in no order, so a node takes a chain as it is published or by replay from seq 0, never by sync.
Types ¶
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 ProofAnswer ¶
type ProofAnswer struct {
StateAnswer
Count *uint64 `json:"count,omitempty"`
Root string `json:"root,omitempty"`
Proof string `json:"proof,omitempty"`
}
ProofAnswer is the proof answer: the state, and when it is renderable its count and root and the proof's byte form (zonerec.Proof), in base64.
type Query ¶
type Query struct {
Kind string `json:"kind"`
Zone string `json:"zone"`
// From and Limit page a log: states from seq From, at most Limit.
From uint64 `json:"from,omitempty"`
Limit int `json:"limit,omitempty"`
// Seq names the state whose leaves are asked for; absent is the latest.
Seq *uint64 `json:"seq,omitempty"`
// Name, Type and Scope name what a proof is about: a name's labels,
// leftmost first (no labels is the apex); a type, 0 or absent for the
// whole name; a scope in hex, absent for none.
Name *[]string `json:"name,omitempty"`
Type uint16 `json:"type,omitempty"`
Scope string `json:"scope,omitempty"`
}
Query is a question to ls_bdns, as JSON. Kind is one of the Kinds; Zone is an identifier in lower-case hex.
func ParseQuery ¶
ParseQuery reads a question: at most MaxQuestion bytes, one JSON object of the known members and nothing after it, a known kind, a zone, and what its kind needs.
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: a state refused while its leaves were still on their way, or while the host's headers lagged, would stay refused.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is ls_bdns: every chain this host carries, indexed from what its topics admit, rebuilt from the host's rows at startup (Restore). Its one lock is never held across a read of the host's storage or headers.
func NewService ¶
func NewService(host bmodule.Host, headers chaintracker.ChainTracker, now func() time.Time) *Service
NewService is an empty index. headers is what a stored proof is checked against; now is the clock a lapse time is read against, nil is time.Now.
func (*Service) AdmissionMode ¶
func (*Service) AdmissionMode() bmodule.AdmissionMode
AdmissionMode implements module.LookupService: the whole transaction, since a token's BEEF shows whether it and the state before it are proven.
func (*Service) GetDocumentation ¶
GetDocumentation implements module.LookupService.
func (*Service) GetMetaData ¶
GetMetaData implements module.LookupService.
func (*Service) Lookup ¶
func (s *Service) Lookup(ctx context.Context, q *lookup.LookupQuestion) (*lookup.LookupAnswer, error)
Lookup implements module.LookupService. log and leaves are formula answers, outpoints the engine hydrates with their BEEF; state and proof are freeform. A chain the host does not carry, or holds nothing of, is an empty answer, never an error.
func (*Service) OutputAdmittedByTopic ¶
OutputAdmittedByTopic implements module.LookupService. What a topic manager admitted is indexed; an output the index cannot place (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: a state or a piece the host no longer holds is never answered again. A state takes every state after it with it, since the chain is kept without a gap.
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. A chain's spent tokens are not among them, so each unspent token is walked back to seq 0 through storage. Where two states stand at one seq (an unmined rival a mined state replaced stays in the host's storage) the mined one is kept, else the one admitted first. The new index is built beside the old one, with no lock held while storage is read, and then put in its place.
func (*Service) SpendNotificationMode ¶
func (*Service) SpendNotificationMode() bmodule.SpendNotificationMode
SpendNotificationMode implements module.LookupService: a chain's order is its states' seq, so no spend is read.
type StateAnswer ¶
type StateAnswer struct {
Zone string `json:"zone"`
Chain string `json:"chain"`
Seq uint64 `json:"seq"`
// Token is the state's token, "<txid>.<vout>".
Token string `json:"token"`
// Mined says the host knows the token mined; Height is its block.
Mined bool `json:"mined"`
Height uint32 `json:"height,omitempty"`
Lapse uint64 `json:"lapse"`
// Renderable is false when the state, or a state before it in the
// chain, has a critical extension this host does not know (Critical is
// the kind of the first such), or when the state itself fails one of
// checks C2 to C6 (Check is its label).
Renderable bool `json:"renderable"`
Critical *uint64 `json:"critical,omitempty"`
Check string `json:"check,omitempty"`
// Held is the highest seq the host keeps: above Seq while an unmined
// state past its lapse time is not answered.
Held uint64 `json:"held"`
}
StateAnswer is the state answer, and the head of the proof answer: which state the host answers from, and what a token's bytes do not show.
type TopicManager ¶
TopicManager is tm_bdns_<z>, one chain's topic. The rules are zonerec.Admit's, on the submission's own bytes, the host's headers and clock, and the three things section 12 lets a verdict read of the topic: the state before, a rival at the same seq, and the leaves pieces.
func NewTopicManager ¶
NewTopicManager makes the manager of one chain's topic. h carries the chain, the headers, the bound, the clock and the view of the 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 what its inputs spend and a leaves piece its funding tree.