Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CertSource ¶
type CertSource interface {
GetCert(ctx context.Context, instance uint64) (*certs.FinalityCertificate, error)
GetLatest(ctx context.Context) (*certs.FinalityCertificate, error)
}
CertSource pulls F3 certs over the wire.
type JSONRPCSource ¶
JSONRPCSource implements CertSource via a Lotus-compatible JSON-RPC endpoint (Filecoin.F3GetCertificate / Filecoin.F3GetLatestCertificate).
func NewJSONRPCSource ¶
func NewJSONRPCSource(url string) *JSONRPCSource
NewJSONRPCSource returns a JSONRPCSource with a 20s default timeout.
func (*JSONRPCSource) GetCert ¶
func (s *JSONRPCSource) GetCert(ctx context.Context, instance uint64) (*certs.FinalityCertificate, error)
GetCert calls Filecoin.F3GetCertificate(instance).
func (*JSONRPCSource) GetLatest ¶
func (s *JSONRPCSource) GetLatest(ctx context.Context) (*certs.FinalityCertificate, error)
GetLatest calls Filecoin.F3GetLatestCertificate.
type Options ¶
type Options struct {
// Anchor is the embedded F3 trust anchor (Instance, committee).
Anchor *anchor.Anchor
// Manifest is the F3 network manifest (NetworkName).
Manifest *manifest.Manifest
// Source is the cert source (Forest/Lotus RPC).
Source CertSource
// DB is an optional BadgerDB for persistence of (instance, powerTable).
DB *badger.DB
}
Options configures a Subscriber.
type PeerProvider ¶
type PeerProvider interface {
// Peers returns the currently known-good Lantern beacon set. May
// return an empty slice during cold start; callers handle that by
// falling back to the JSON-RPC fallback.
Peers() []peer.AddrInfo
}
PeerProvider is the minimal callback shape the SwarmCertSource needs to discover Lantern beacons it can query. The beacon's startup wires this to the DHT rendezvous discovery loop; tests pass a static slice via StaticPeerProvider.
type State ¶
type State struct {
NetworkName gpbft.NetworkName
Instance uint64 // next instance to verify
PowerTable gpbft.PowerEntries // committee at Instance
Latest *certs.FinalityCertificate // most recently verified cert
LatestChain *gpbft.ECChain // its EC chain (head = finalized)
}
State is the in-memory follower state.
type StaticPeerProvider ¶
StaticPeerProvider returns a fixed peer list. Used by tests and by operators who want to pin a specific beacon set instead of relying on DHT discovery.
func (StaticPeerProvider) Peers ¶
func (s StaticPeerProvider) Peers() []peer.AddrInfo
Peers returns the fixed peer list.
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber walks F3 certs from anchor forward.
func New ¶
func New(opts Options) (*Subscriber, error)
New builds a Subscriber. Caller must call Bootstrap before Walk.
func (*Subscriber) State ¶
func (s *Subscriber) State() State
State returns a snapshot of the current follower state.
type SwarmCertSource ¶
type SwarmCertSource struct {
// contains filtered or unexported fields
}
SwarmCertSource implements CertSource over a pool of libp2p Lantern beacons, with a JSON-RPC fallback. Goroutine-safe.
func NewSwarmCertSource ¶
func NewSwarmCertSource(cfg SwarmConfig) (*SwarmCertSource, error)
NewSwarmCertSource constructs a SwarmCertSource. Host and Fallback are required; everything else has defaults.
func (*SwarmCertSource) GetCert ¶
func (s *SwarmCertSource) GetCert(ctx context.Context, instance uint64) (*certs.FinalityCertificate, error)
GetCert tries the swarm first, then falls back. Unlike GetLatest there's no staleness to evaluate; we just want the specific instance.
func (*SwarmCertSource) GetLatest ¶
func (s *SwarmCertSource) GetLatest(ctx context.Context) (*certs.FinalityCertificate, error)
GetLatest tries the swarm first, then falls back.
func (*SwarmCertSource) Stats ¶
func (s *SwarmCertSource) Stats() SwarmStats
Stats returns a snapshot of activity counters.
type SwarmConfig ¶
type SwarmConfig struct {
// Host is the libp2p host used to dial Lantern beacons.
Host host.Host
// NetworkName is the F3 network name baked into the protocol id.
// Defaults to "filecoin" (mainnet).
NetworkName string
// Provider returns the current pool of Lantern beacons.
Provider PeerProvider
// Fallback is the CertSource used when no swarm peer answers in time
// or when all answers are stale. Typically a JSONRPCSource pointing
// at Glif or a sibling Forest/Lotus.
Fallback CertSource
// PerPeerTimeout caps each libp2p call. Default 4s.
PerPeerTimeout time.Duration
// StaleAfter declares a swarm answer stale and triggers a fallback
// when the cert's timestamp is older than this. Default 5 minutes.
StaleAfter time.Duration
}
SwarmConfig configures a SwarmCertSource.