feat: republish third-party ipns record - #891
Conversation
|
Triage: in review |
|
сс @lidel for awareness |
|
Triage:
|
|
Turning this back into a draft. There should be a way to create a new record without publishing or republishing to public routers as part of this PR. |
|
I've replaced the |
|
this still needs some work. ill convert to ready when its ready for review. |
Adds the Upkeep enum (reissue/rebroadcast/none) plus keyName/lifetime fields to the stored IPNS record metadata, and a RecordObsoleteError that carries the more suitable record.
Adds routerName and isLocalStoreRouting helpers and an overwrite put option to the routing module, and makes the validator reject a record whose embedded non-identity public key does not hash to its routing key.
Adds a metadata merge that preserves keyName/lifetime on partial updates, tolerant metadata reads, a list method, and deleteMetadata.
Extracts the network-router query into a reusable findRoutingRecords helper, skips the local store on nocache, and honors validate:false on the network path.
publish stores an upkeep policy (default reissue). unpublish removes only the republishing metadata by default (keeping the record), with a removeRecord option to also delete the record.
Adds import (validate and store a record locally without publishing), republish (publish the local record, backing off if the routing has a newer one, best-effort on the network), and the background loop that reissues or rebroadcasts due records, adopting a newer network record when rebroadcasting.
Wires import/republish/unpublish through the IPNS class, adds the UpkeepPolicy, UnpublishOptions, RepublishOptions and RepublishResult types, and normalizeKeyName for unpublish.
Adds a republish example to the README and a dictionary entry.
cb409cc to
609b594
Compare
|
I'm pretty happy with where this is at now. I've updated the description to give a pretty good idea of whats changed. I did change the behavior of unpublish to not remove the record by default, just the metadata which sets the upkeep. I think this is the correct behavior because deleting the record loses the record sequence number. I've added an option removeRecord for the case where the user actually wants to remove the record. Not sure if this would be considered a breaking change. |
Title
feat: republish third-party ipns record
Description
Adds the ability to keep alive an IPNS record this node did not originally
publish, plus the upkeep-policy machinery around it.
New methods on the IPNS interface:
import(key, record): validate a record and store it locally without touchingthe network. No metadata is written, so the record is served on a GET but
dormant until
republishgives it an upkeep policy.republish(key, options): republish the record held locally for a key. Itcompares the local record against the network with
ipnsSelector, throwsRecordObsoleteErrorif a newer record is already published, otherwisepersists the chosen upkeep policy and publishes. Best-effort on the network (a
failing network router does not throw; use onProgress and the logs), but a
local-store persist failure throws, since that write saves the upkeep policy.
unpublish(key, options): stop republishing. By default it removes only themetadata (the record stays served until it expires);
removeRecord: truealsodeletes the record.
Upkeep policy (stored per key in the metadata, default
reissue):reissue: re-sign the record with a new sequence and validity. Needs thesigning key, so only
publishcan select it.rebroadcast: re-put the existing record as-is. The background loop resolvesthe network's latest record first and adopts a newer one instead of pushing a
stale copy.
none: no upkeep.Other changes:
resolveskips the local store whennocacheis set, and honorsvalidate: falseon the network path.not hash to its routing key.
The metadata
Upkeepenum replaces the earlierrefreshbool; its values arereissue/rebroadcast/none.Closes #877
Notes & open questions
publish()is all-or-nothing (a single router failure fails the publish)while
republish()is best-effort on the network.Change checklist