Documentation
¶
Overview ¶
Package peerheads records the chain heads libp2p peers announce to us (#154), so a bridge-off Lantern (--no-fallback-rpc) has a continuous, RPC-free head quorum instead of none.
Feeders:
- Hello (/fil/hello/1.0.0): the peer's heaviest tipset at connect time.
- Gossipsub /fil/blocks: every block a peer forwards (continuous, fresh).
Honest boundary: peer IDs are Sybil-cheap, so peers are grouped by network prefix (IPv4 /16, IPv6 /32). A swarm of sybils in one prefix is one voter. Peers without an IP address (relayed / unknown) are ignored. This raises the cost of an eclipse from "N peer IDs" to "N networks"; finality (F3) is what fully closes the unfinalized tip.
Index ¶
Constants ¶
const DefaultCap = 512
DefaultCap bounds how many peers the book remembers.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Book ¶
type Book struct {
// contains filtered or unexported fields
}
Book is a bounded, concurrency-safe per-peer head record.
func New ¶
New builds a Book. addrOf resolves a peer's current remote address (the daemon passes the first live connection's RemoteMultiaddr).
func (*Book) Observe ¶
Observe records that peer p announced a tipset (cids) at height h. Only moves forward per peer. Peers with no IP-derived group are dropped.
func (*Book) ObserveBlock ¶
ObserveBlock records a gossiped block (CID, height, parents) from peer p.
type Head ¶
type Head struct {
Peer peer.ID
Group string // network prefix voter key, never empty
Cids []cid.Cid
Height abi.ChainEpoch
// Parents of the announced block (gossip only; nil for Hello). Lets
// the head quorum check the peer is on OUR chain, not just our height.
Parents []cid.Cid
At time.Time
}
Head is the latest head one peer announced.