Documentation
¶
Overview ¶
Package combined wires multiple BlockGetters into a single fall-through chain: cache → bitswap → HTTP gateway. Successful fetches from upstream sources are written back into the local cache.
This is the BlockGetter the state accessor takes in production.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
Cache is the local-cache half of a combined fetcher. It must support CID-keyed reads and writes. The state/cache package satisfies this in production; tests use hamt.MemBlockStore.
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
Fetcher wires Cache + N Sources into the standard cache-first fallback chain. Sources are tried in order; the first successful CID-matching response wins. Successful responses are written into Cache.
func (*Fetcher) AddSource ¶
AddSource appends a block source at runtime (thread-safe). Used by the embedded daemon to mount the libp2p Bitswap source once the host is up (lantern#50): on calibration the gateway+glif sources both point at Glif, so without a p2p source a bridge-off daemon has no non-Glif way to fetch message/receipt blocks. prepend=true puts it ahead of existing sources (so p2p is tried before the HTTP fallbacks). Idempotent on Name.
func (*Fetcher) Get ¶
Get implements hamt.BlockGetter. Cache-first; then race-tier sources in parallel; then sequential fallback sources. The first CID-matching response wins, is cached, and the rest are abandoned via ctx cancel.
Issue #3: racing the gateway against Bitswap cuts cold-block latency from "5s Bitswap timeout + gateway fetch" to "gateway fetch (~100ms) OR Bitswap fast deadline", whichever fires first. State-tree walks that previously took 30s+ now complete in low single seconds.
type Source ¶
Source is any networked BlockGetter (Bitswap, HTTP gateway).
Race=true sources are fired in parallel; the first successful response wins and the rest are abandoned. Race=false sources are tried sequentially AFTER all Race sources have failed.
Use Race=true for fast, low-cost alternative paths to the same blocks (e.g. our HTTP gateway and Bitswap both serve cold IPLD blocks). Use Race=false for last-resort fallbacks with different semantics or cost (e.g. Glif RPC, which is a public service and has a fee structure).