syncprotocol

package
v0.0.0-...-9268282 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 10 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 syncprotocol contains the relay's NIP-45 count sketch and NIP-77 negentropy session wrappers. The wrappers exchange protocol strings while exposing relay-friendly event IDs and reconciliation results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HLLFilterOffset

func HLLFilterOffset(f event.Filter) (int, bool)

HLLFilterOffset derives the register byte offset from the single tag value used by the relay's count filter. Hashed values and address-style values are both accepted.

Types

type HLL

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

HLL is the NIP-45 256-register sketch used to merge counts from relays.

func NewHLL

func NewHLL(offset int) *HLL

func (*HLL) Add

func (h *HLL) Add(pubkeyHex string) error

Add incorporates one 32-byte hexadecimal public key into the sketch.

func (*HLL) Hex

func (h *HLL) Hex() string

Hex returns the 256 registers in their wire hexadecimal form.

func (*HLL) MergeHex

func (h *HLL) MergeHex(encoded string) error

MergeHex unions another 256-register sketch into h.

type Item

type Item = wire.EventRef

Item identifies one event in a reconciliation index.

type Result

type Result struct {
	Response string
	Have     []string
	Need     []string
	Done     bool
}

Result contains one negentropy response and the IDs discovered by the initiator when reconciliation completes.

type Session

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

Session holds one stateful negentropy exchange. A session is used by one initiator or responder for the lifetime of that exchange.

func NewSession

func NewSession(items []Item, initiator bool) (*Session, error)

NewSession builds a sealed negentropy index from the relay's event IDs and timestamps. The initiator flag selects the side that starts the exchange and receives Have and Need IDs.

func (*Session) Reconcile

func (s *Session) Reconcile(message string) (Result, error)

Reconcile consumes one peer message and returns the next response. An initiator receives IDs present on each side once the exchange is complete.

func (*Session) Start

func (s *Session) Start() (string, error)

Start begins an initiator session and returns its protocol message.

Jump to

Keyboard shortcuts

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