算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
lightning-gossip【设计与创意】BOLT 7 gossip: node_announcement, channel_announcement, channel_update. Sync via gossip_queries, channel range queries, gossip rate limiting, pruning stale announcements. USE WHEN: implementing/debugging gossip sync, managing graph storage, designing rate limits.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
LN nodes gossip about themselves and channels so the network can build a routing graph. Each node maintains a local copy.
channel_announcement (256)Announces a public channel between two nodes:
{
features,
chain_hash,
short_channel_id (block × tx-index × output-index),
node_id_1, node_id_2,
bitcoin_key_1, bitcoin_key_2,
node_signature_1, node_signature_2, # signed by node keys
bitcoin_signature_1, bitcoin_signature_2, # signed by funding keys
}
Bitcoin signatures prove ownership of the funding outpoint. Without those, anyone could forge announcements.
node_announcement (257)Node metadata:
{
signature, # by node_id
features, timestamp,
node_id,
rgb_color, alias,
addresses (IPv4, IPv6, Tor v3, etc.),
TLV (extras),
}
Newer timestamps replace older for same node_id.
channel_update (258)Per-direction routing policy:
{
signature,
chain_hash, short_channel_id,
timestamp, message_flags, channel_flags, # incl. enabled bit
cltv_expiry_delta,
htlc_minimum_msat,
fee_base_msat, fee_proportional_millionths,
htlc_maximum_msat,
}
Two channel_updates per channel (one per direction). Latest timestamp
wins; older replaced.
For channel_announcement:
For channel_update:
For node_announcement:
Failed validation → drop, possibly disconnect peer if many bad messages.
When connecting to a new peer:
gossip_queries (feature bit 6/7) enables on-demand sync.query_channel_range{
chain_hash,
first_blocknum,
number_of_blocks,
query_options TLV (with checksums for incremental update),
}
Peer responds with reply_channel_range listing SCIDs (and optionally
checksums) in that range.
query_short_channel_idsRequest the actual channel_announcement + channel_updates for
specific SCIDs.
Peers gossip in real-time:
channel_announcement → flood (one hop, then forward to all).channel_update updates → similar.node_announcement → similar.Rate-limited per IP / connection to prevent spam.
Channels with no channel_update for ~14 days are considered stale
and dropped from local graph.
Closed channels (funding output spent) detected via:
channel_update with disabled flag.Full prune: when funding output is spent on chain, drop the channel edge.
LN graph as of 30 August 2026 (mempool.space, the most recent datapoint published as of September 2026): ~32,700 public channels, ~14,200 announced nodes (~16,200 counting unannounced), ~3,790 BTC public capacity. Storage: ~50-100 MB.
The graph shrank steadily through 2026: ~41,600 channels and ~5,740 BTC capacity on 1 January 2026, ~38,200 channels on 1 August 2026, ~32,700 by 30 August 2026. Crawlers disagree substantially — 1ML reported ~19,900 channels and ~5,900 nodes on 15 September 2026 — because each explorer sees a different slice of the gossip network; treat any single explorer's count as a lower bound.
Periodic full re-gossip on cold start can be 5-30 minutes depending
on peer count and bandwidth. Caching the graph locally + diff sync
(via query_channel_range checksums) is essential.
Per BOLT 7 recommendations:
channel_update per direction per channel per second.Gossip is fully public:
Private channels (announce_channel = false):
route_hints (BOLT 11 'r' tag) in invoices
so senders can reach you.channel_announcement → injected
fake channels.channel_update from disabled channel as routable.