Documentation
¶
Overview ¶
Package offline implements Routing with a client which is only able to perform offline operations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrOffline = errors.New("routing system in offline mode")
ErrOffline is returned when trying to perform operations that require connectivity.
Functions ¶
func NewOfflineRouter ¶
func NewOfflineRouter(dstore ds.Datastore, validator record.Validator, opts ...Option) routing.Routing
NewOfflineRouter returns a Routing implementation which only performs offline operations. It allows to Put and Get signed dht records to and from the local datastore.
Records are stored in the same datastore layout as the go-libp2p-kad-dht value store (go-libp2p-kad-dht v0.42.0 and later), so a node that shares dstore between this router and a DHT instance can resolve records offline that were published online and vice versa. Records stored by earlier versions of this package (root-level base32 keys, the pre-v0.42.0 kad-dht layout) are not read anymore.
A stored record is served for as long as it stays valid (for IPNS, until its EOL); see WithMaxRecordAge to also cap retention by store age.
Types ¶
type Option ¶ added in v0.42.0
type Option func(*offlineRouting)
Option configures a router returned by NewOfflineRouter.
func WithMaxRecordAge ¶ added in v0.42.0
WithMaxRecordAge caps how long a stored value record is served, measured from the time the record was stored: once a record is older than age it is treated as absent and dropped on the next read. This is independent of the record's own validity, an IPNS record is dropped once it passes its EOL regardless of this setting.
The default is no cap: records are served for as long as they stay valid. This fits the offline router's role as a local store of the node's own records, which have no republisher to refresh their stored timestamps. Set a cap to mirror the go-libp2p-kad-dht value store (amino.DefaultMaxRecordAge) or to bound a datastore that nothing else garbage-collects. A value <= 0 keeps the no-cap default.