resolver

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2021 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver represents a resolver that can resolve data in a CAS based on a CID and WebCAS URL.

func New

func New(casClient casapi.Client, ipfsReader ipfsReader, httpClient httpClient) *Resolver

New returns a new Resolver.

func (*Resolver) Resolve

func (h *Resolver) Resolve(webCASURL *url.URL, cidWithPossibleHint string,
	data []byte) ([]byte, error)

Resolve does the following:

  1. If data is provided (not nil), then it will be stored via the local CAS. That data passed in will then simply be returned back to the caller.
  2. If data is not provided (is nil), then the local CAS will be checked to see if it has data at the cid provided. If it does, then it is returned. If it doesn't, and a webCASURL is provided, then the data will be retrieved by querying the webCASURL. This data will then get stored in the local CAS. Finally, the data is returned to the caller.

In both cases above, the CID produced by the local CAS will be checked against the cid passed in to ensure they are the same.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL