Add share cards

This commit is contained in:
satoshi committed 2026-09-04 00:54:26 +03:00
1 parent ec42ce9b54
commit 4669bf10c0
51 files changed
+1193 -239

No files matched your search

+15 -15
View File
@@ -168,7 +168,7 @@ func (a *Aggregator) IngestBlockEvents(ctx context.Context, events <-chan logmon
// Best-effort enrich with hash + coinbase reward + miner via bitcoind.
// We look up the hash from height, then fetch the full block
// (verbosity 2) to sum the coinbase outputs and extract the
// payout address. Both are fire-and-forget — if bitcoind is
// payout address. Both are fire-and-forget, if bitcoind is
// down we still record the block with whatever we have.
if a.RPC != nil {
lookupCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
@@ -200,7 +200,7 @@ func (a *Aggregator) IngestBlockEvents(ctx context.Context, events <-chan logmon
if err != nil {
a.Log.Warn("block persist failed", "height", rec.Height, "err", err)
} else if !inserted {
a.Log.Warn("block at this height already recorded — duplicate or pre-existing entry, not counting as new",
a.Log.Warn("block at this height already recorded, duplicate or pre-existing entry, not counting as new",
"height", rec.Height, "hash", rec.Hash)
isNew = false
}
@@ -257,7 +257,7 @@ func (a *Aggregator) reconcileOnce(ctx context.Context) {
// We need the current chain for both enrichment and reorg detection.
// If the first refresh hasn't completed yet, currentChain is "" and
// any chain comparison would be meaningless — skip until the next tick.
// any chain comparison would be meaningless, skip until the next tick.
a.mu.RLock()
currentChain := ""
if a.snap.Chain != nil {
@@ -269,7 +269,7 @@ func (a *Aggregator) reconcileOnce(ctx context.Context) {
}
// Pass 1: enrichment. Fetch hash + reward for any missing-data rows.
// Skip blocks from a different chain — enriching a testnet block
// Skip blocks from a different chain, enriching a testnet block
// against mainnet RPC would overwrite its hash with the wrong value.
missing, err := a.Store.BlocksNeedingEnrichment(since)
if err != nil {
@@ -350,10 +350,10 @@ func (a *Aggregator) reconcileOnce(ctx context.Context) {
canonical, herr := a.RPC.GetBlockHash(lookupCtx, b.Height)
cancel()
if herr != nil {
continue // RPC transient error — retry next sweep
continue // RPC transient error, retry next sweep
}
if canonical == b.Hash {
continue // matches the canonical chain — all good
continue // matches the canonical chain, all good
}
// Hash mismatch. Determine whether it's a real reorg or a
// cross-network block by checking if our hash exists on this chain.
@@ -391,7 +391,7 @@ func (a *Aggregator) reconcileOnce(ctx context.Context) {
// Pass 3: un-orphan blocks that were previously false-positived.
// This covers two cases:
// a) Blocks with Chain != currentChain that got orphaned before this
// fix was deployed — un-orphan them now.
// fix was deployed, un-orphan them now.
// b) Same-chain blocks whose hash now matches the canonical chain
// (e.g. the "reorg" reverted before we checked again).
fixedAny := false
@@ -403,7 +403,7 @@ func (a *Aggregator) reconcileOnce(ctx context.Context) {
continue
}
if b.Chain != "" && b.Chain != currentChain {
// Cross-network orphan from before the fix — un-orphan.
// Cross-network orphan from before the fix, un-orphan.
if err := a.Store.UnmarkOrphaned(b.Height); err != nil {
a.Log.Warn("reconcile: unmark cross-network orphan failed", "height", b.Height, "err", err)
continue
@@ -418,7 +418,7 @@ func (a *Aggregator) reconcileOnce(ctx context.Context) {
_, berr := a.RPC.GetBlock(lookupCtx, b.Hash)
cancel()
if berr != nil {
// Block doesn't exist on this chain — cross-network.
// Block doesn't exist on this chain, cross-network.
otherChain := b.Chain
if otherChain == "" || otherChain == currentChain {
otherChain = inferOtherChain(currentChain)
@@ -432,7 +432,7 @@ func (a *Aggregator) reconcileOnce(ctx context.Context) {
fixedAny = true
continue
}
// Block exists on this chain — check if it's canonical again.
// Block exists on this chain, check if it's canonical again.
lookupCtx2, cancel2 := context.WithTimeout(ctx, 3*time.Second)
canonical, herr := a.RPC.GetBlockHash(lookupCtx2, b.Height)
cancel2()
@@ -444,7 +444,7 @@ func (a *Aggregator) reconcileOnce(ctx context.Context) {
a.Log.Warn("reconcile: unmark reverted-reorg failed", "height", b.Height, "err", err)
continue
}
a.Log.Info("reconcile: cleared orphan — hash matches canonical again",
a.Log.Info("reconcile: cleared orphan, hash matches canonical again",
"height", b.Height, "hash", b.Hash)
fixedAny = true
}
@@ -452,9 +452,9 @@ func (a *Aggregator) reconcileOnce(ctx context.Context) {
// Pass 4: stamp chain on legacy/mis-stamped blocks that have a hash.
// Handles Chain="" (never stamped), "other" (old fallback), and "test"
// (wrong identifier — testnet4 reports as "testnet4", not "test").
// (wrong identifier, testnet4 reports as "testnet4", not "test").
// Uses GetBlock(hash) to determine if the block belongs to the current
// network or a different one. No lookback restriction — this is a
// network or a different one. No lookback restriction, this is a
// one-time migration for pre-existing rows.
for _, b := range recent {
if (b.Chain != "" && b.Chain != "other" && b.Chain != "test") || b.Hash == "" {
@@ -464,7 +464,7 @@ func (a *Aggregator) reconcileOnce(ctx context.Context) {
_, berr := a.RPC.GetBlock(lookupCtx, b.Hash)
cancel()
if berr != nil {
// Block not found on this network — infer the other chain.
// Block not found on this network, infer the other chain.
inferredChain := inferOtherChain(currentChain)
if err := a.Store.StampChain(b.Height, inferredChain); err != nil {
a.Log.Warn("reconcile: stamp legacy block failed", "height", b.Height, "err", err)
@@ -545,7 +545,7 @@ func (a *Aggregator) appendBlock(rec BlockRecord) Snapshot {
}
// loadPersistedBlocks seeds a.blocks from the store so history survives
// restarts. Safe to call with a nil Store — becomes a no-op.
// restarts. Safe to call with a nil Store, becomes a no-op.
func (a *Aggregator) loadPersistedBlocks() {
if a.Store == nil {
return