Documentation
¶
Overview ¶
Package metadata implements protocols for publishing content claims on IPNI.
The goal is to enable partial publishing of content claims to IPNI.
In order to enable faster chaining of requests and general processing, we add additional fields in IPNI metadata that enables a client to quickly read the record and take action based on information in the claim, before it has retrieved the full claim.
The rules for publishing content claims records to IPNI are as follows:
Content claims should be published to IPNI by the original issuer of the content claim.
The ContextID for the content claim should be the CID of the content the claim is about, except in the case of a location commitment, where the content ID should be:
hash(audience public key, content cid multihash)
The claim record MUST be able to be looked up on IPNI from the content CID multihash (or double encryption thereof).
The claim MAY be able to be looked up by additional multihashes, particularly in the case of the IndexClaim, where the record should be accessible from any multihash inside the index.
The metadata for the claim is structured to maximize utility of the record while minimizing size.
To generally respect the 100 byte maximum size for IPNI records, we do not encode the claim itself, but rather its CID.
The full claim must be retrievable through an HTTP multiaddr of the provider which contains path segments of the form `{claim}`. To retrieve the claim, replace every `{claim}` with the string encoding of the claim CID.
For a location commitment, the content must retrievable through an HTTP multiaddr of the provider which contains path segments of the form `{blob}` or `{blobCID}`. One or the other or both may be present. To retrieve the claim: 1. Replace every `{blob}` with a multibase string encoding of the multihash of the shard CID in the metadata, or if not present, the multibase encoding of the multihash used to lookup the record. 2. Replace every `{blobCID}` with the default string serialization of the shard CID in the metadata, or if not present, the CIDv1 encoding with RAW codec of the multihash used to lookup the record.
Additionally, if Range parameter is present in the metadata, it should be translated into a range HTTP header when retrieving content.
Index ¶
- Constants
- Variables
- type EqualsClaimMetadata
- type HasClaim
- type IndexClaimMetadata
- type LocationCommitmentMetadata
- func (l *LocationCommitmentMetadata) GetClaim() cid.Cid
- func (l *LocationCommitmentMetadata) ID() multicodec.Code
- func (l *LocationCommitmentMetadata) MarshalBinary() ([]byte, error)
- func (l *LocationCommitmentMetadata) ReadFrom(r io.Reader) (n int64, err error)
- func (l *LocationCommitmentMetadata) UnmarshalBinary(data []byte) error
- type Range
Constants ¶
const EqualsClaimID = 0x3E0001
EqualsClaimID is the multicodec for equals claims
const IndexClaimID = 0x3E0000
IndexClaimID is the multicodec for index claims
const LocationCommitmentID = 0x3E0002
LocationCommitmentID is the multicodec for location commitments
Variables ¶
var MetadataContext ipnimd.MetadataContext
Functions ¶
This section is empty.
Types ¶
type EqualsClaimMetadata ¶
type EqualsClaimMetadata struct {
// Equals represents an equivalent cid to the content cid that was used for lookup
Equals cid.Cid
// Expiration as unix epoch in seconds
Expiration int64
// Claim indicates the cid of the claim - the claim should be fetchable by combining the http multiaddr of the provider with the claim cid
Claim cid.Cid
}
EqualsClaimMetadata represents metadata for an equals claim
func (*EqualsClaimMetadata) GetClaim ¶
func (e *EqualsClaimMetadata) GetClaim() cid.Cid
func (*EqualsClaimMetadata) ID ¶
func (e *EqualsClaimMetadata) ID() multicodec.Code
func (*EqualsClaimMetadata) MarshalBinary ¶
func (e *EqualsClaimMetadata) MarshalBinary() ([]byte, error)
func (*EqualsClaimMetadata) ReadFrom ¶
func (e *EqualsClaimMetadata) ReadFrom(r io.Reader) (n int64, err error)
func (*EqualsClaimMetadata) UnmarshalBinary ¶
func (e *EqualsClaimMetadata) UnmarshalBinary(data []byte) error
type IndexClaimMetadata ¶
type IndexClaimMetadata struct {
// Index represents the cid of the index for this claim
Index cid.Cid
// Expiration as unix epoch in seconds
Expiration int64
// Claim indicates the cid of the claim - the claim should be fetchable by combining the http multiaddr of the provider with the claim cid
Claim cid.Cid
}
IndexClaimMetadata represents metadata for an index claim Index claim metadata
func (*IndexClaimMetadata) GetClaim ¶
func (i *IndexClaimMetadata) GetClaim() cid.Cid
func (*IndexClaimMetadata) ID ¶
func (i *IndexClaimMetadata) ID() multicodec.Code
func (*IndexClaimMetadata) MarshalBinary ¶
func (i *IndexClaimMetadata) MarshalBinary() ([]byte, error)
func (*IndexClaimMetadata) ReadFrom ¶
func (i *IndexClaimMetadata) ReadFrom(r io.Reader) (n int64, err error)
func (*IndexClaimMetadata) UnmarshalBinary ¶
func (i *IndexClaimMetadata) UnmarshalBinary(data []byte) error
type LocationCommitmentMetadata ¶
type LocationCommitmentMetadata struct {
// Shard is an optional alternate cid to use to lookup this location -- if the looked up shard is part of a larger shard
Shard *cid.Cid
// Range is an optional byte range within a shard
Range *Range
// Expiration as unix epoch in seconds
Expiration int64
// Claim indicates the cid of the claim - the claim should be fetchable by combining the http multiaddr of the provider with the claim cid
Claim cid.Cid
}
LocationCommitmentMetadata represents metadata for an equals claim
func (*LocationCommitmentMetadata) GetClaim ¶
func (l *LocationCommitmentMetadata) GetClaim() cid.Cid
func (*LocationCommitmentMetadata) ID ¶
func (l *LocationCommitmentMetadata) ID() multicodec.Code
func (*LocationCommitmentMetadata) MarshalBinary ¶
func (l *LocationCommitmentMetadata) MarshalBinary() ([]byte, error)
func (*LocationCommitmentMetadata) ReadFrom ¶
func (l *LocationCommitmentMetadata) ReadFrom(r io.Reader) (n int64, err error)
func (*LocationCommitmentMetadata) UnmarshalBinary ¶
func (l *LocationCommitmentMetadata) UnmarshalBinary(data []byte) error