Documentation
¶
Index ¶
Constants ¶
const PeerTag = "fcpeer"
PeerTag is the ConnManager tag we apply to peers who pass our Hello genesis check. Worth +10 score so the connmgr trim pass keeps them over random peers we picked up via DHT.
const PeerTagWeight = 10
const ProtocolID protocol.ID = "/fil/hello/1.0.0"
ProtocolID is the libp2p protocol ID for Filecoin Hello.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HeadProvider ¶
HeadProvider returns the current chain head: tipset CIDs, epoch, and parent weight. Lantern's daemon supplies a closure backed by the trusted root + (when set) the header store.
type HelloMessage ¶
type HelloMessage struct {
HeaviestTipSet []cid.Cid
HeaviestTipSetHeight abi.ChainEpoch
HeaviestTipSetWeight big.Int
GenesisHash cid.Cid
}
HelloMessage is the Filecoin /fil/hello/1.0.0 message. Wire format matches Lotus byte-for-byte; the CBOR codec is in cbor_gen.go.
HeaviestTipSet is the sender's current head tipset (one or more block CIDs). HeaviestTipSetHeight is the head epoch. HeaviestTipSetWeight is the cumulative parent weight at that head. GenesisHash is the CID of block 0 (network identity); receivers close the connection on mismatch.
func (*HelloMessage) MarshalCBOR ¶
func (t *HelloMessage) MarshalCBOR(w io.Writer) error
func (*HelloMessage) UnmarshalCBOR ¶
func (t *HelloMessage) UnmarshalCBOR(r io.Reader) (err error)
type LatencyMessage ¶
LatencyMessage is the optional reply sent by Lotus peers carrying their arrival + sent timestamps for clock-skew measurement. Lantern reads it to drain the stream cleanly but doesn't act on it.
func (*LatencyMessage) MarshalCBOR ¶
func (t *LatencyMessage) MarshalCBOR(w io.Writer) error
func (*LatencyMessage) UnmarshalCBOR ¶
func (t *LatencyMessage) UnmarshalCBOR(r io.Reader) (err error)
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service wires the Hello protocol onto a libp2p Host.
func NewService ¶
NewService constructs a Hello service. Caller must call Register to attach the stream handler.
genesis is the canonical genesis CID for this network (mainnet, calibnet). head is a callback that returns the current chain head; Service will call it on every outbound SayHello so the wire message reflects current state.
func (*Service) Register ¶
func (s *Service) Register()
Register attaches the Hello stream handler to the host. Idempotent.
func (*Service) SayHello ¶
SayHello dials the remote peer's Hello protocol and sends our HelloMessage. Idempotent (libp2p multiplexes streams). Bounded by streamOpenTimeout + streamDeadline.
func (*Service) WatchNewConns ¶
WatchNewConns spawns a goroutine that listens for new outbound libp2p connections and proactively SayHello to each remote. This is the loop that actually keeps peer count up over time: every new peer we dial gets a Hello within the first second, so remote connmgrs score us positively from the start.
Cancellation: stops when ctx is done.