| 1 | package iface |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "errors" |
| 6 | |
| 7 | "github.com/ipfs/boxo/ipns" |
| 8 | "github.com/ipfs/boxo/path" |
| 9 | "github.com/ipfs/kubo/core/coreiface/options" |
| 10 | ) |
| 11 | |
| 12 | var ErrResolveFailed = errors.New("could not resolve name") |
| 13 | |
| 14 | type IpnsResult struct { |
| 15 | path.Path |
| 16 | Err error |
| 17 | } |
| 18 | |
| 19 | // NameAPI specifies the interface to IPNS. |
| 20 | // |
| 21 | // IPNS is a PKI namespace, where names are the hashes of public keys, and the |
| 22 | // private key enables publishing new (signed) values. In both publish and |
| 23 | // resolve, the default name used is the node's own PeerID, which is the hash of |
| 24 | // its public key. |
| 25 | // |
| 26 | // You can use .Key API to list and generate more names and their respective keys. |
| 27 | type NameAPI interface { |
| 28 | // Publish announces new IPNS name |
| 29 | Publish(ctx context.Context, path path.Path, opts ...options.NamePublishOption) (ipns.Name, error) |
| 30 | |
| 31 | // Resolve attempts to resolve the newest version of the specified name |
| 32 | Resolve(ctx context.Context, name string, opts ...options.NameResolveOption) (path.Path, error) |
| 33 | |
| 34 | // Search is a version of Resolve which outputs paths as they are discovered, |
| 35 | // reducing the time to first entry |
| 36 | // |
| 37 | // Note: by default, all paths read from the channel are considered unsafe, |
| 38 | // except the latest (last path in channel read buffer). |
| 39 | Search(ctx context.Context, name string, opts ...options.NameResolveOption) (<-chan IpnsResult, error) |
| 40 | } |