client

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 24 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DCAS added in v0.1.1

type DCAS interface {
	// Put puts the data and returns the content ID (CID) for the value
	Put(data io.Reader, opts ...Option) (string, error)

	// Delete deletes the values for the given content IDs.
	Delete(cids ...string) error

	// Get retrieves the value for the given content ID (CID).
	Get(cid string, w io.Writer) error

	// GetNode retrieves the CAS Node for the given content ID (CID). A node contains data and/or links to other nodes.
	GetNode(cid string) (*Node, error)
}

DCAS defines the functions of a DCAS client

type DCASClient

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

DCASClient allows you to put and get DCASClient from outside of a chaincode

func (*DCASClient) Delete

func (d *DCASClient) Delete(ids ...string) error

Delete deletes the values for the given content IDs.

func (*DCASClient) Get

func (d *DCASClient) Get(id string, w io.Writer) error

Get retrieves the value for the given content ID.

func (*DCASClient) GetNode added in v0.1.5

func (d *DCASClient) GetNode(id string) (*Node, error)

GetNode retrieves the CAS Node for the given content ID. A node contains data and/or links to other nodes.

func (*DCASClient) Put

func (d *DCASClient) Put(data io.Reader, opts ...Option) (string, error)

Put stores the given content and returns the content ID (CID) for the value

type Format added in v0.1.5

type Format string

Format specifies the format of the stored data

const (
	// CborFormat is a Concise Binary Object Representation (CBOR) data format (see https://specs.ipld.io/block-layer/codecs/dag-cbor.html)
	CborFormat Format = "cbor"
	// ProtobufFormat stores a node which is marshalled using proto buf
	ProtobufFormat Format = "protobuf"
	// RawFormat stores the node as it was input
	RawFormat Format = "raw"
)

type InputEncoding added in v0.1.5

type InputEncoding string

InputEncoding specifies the input encoding of the data being stored

const (
	// JSONEncoding indicates that the input is encoded in JSON
	JSONEncoding InputEncoding = "json"
	// RawEncoding indicates that the input should not be interpreted
	RawEncoding InputEncoding = "raw"
	// CborEncoding indicates that the input is encoded in Concise Binary Object Representation (CBOR)
	// (see https://specs.ipld.io/block-layer/codecs/dag-cbor.html)
	CborEncoding InputEncoding = "cbor"
	// ProtobufEncoding indicates that the input is encoded as a protobuf
	ProtobufEncoding InputEncoding = "protobuf"
)
type Link struct {
	// Hash contains the content ID of the node
	Hash string `json:"hash"`
	// Name is an optional name for the link
	Name string `json:"name,omitempty"`
	// Size contains the size of the target node
	Size uint64 `json:"size,omitempty"`
}

Link is a link to another node in DCAS

type Node added in v0.1.5

type Node struct {
	// Data contains the raw data of the node
	Data []byte `json:"data,omitempty"`
	// Links contains zero or more links to other nodes
	Links []Link `json:"links,omitempty"`
}

Node contains data and optional links to other nodes

type NodeType added in v0.1.5

type NodeType string

NodeType specifies the type of node to be stored (object or file)

const (
	// ObjectNodeType stores the data as an object using a specified format
	ObjectNodeType NodeType = "object"

	// FileNodeType stores the data either as a single 'raw' node or, if the data is to large then the data
	// is broken up into equal-sized chunks and stored as a Merkle DAG (see https://docs.ipfs.io/concepts/merkle-dag/).
	FileNodeType NodeType = "file"
)

type Option added in v0.1.5

type Option func(opts *options)

Option is a DCAS client option

func WithFormat added in v0.1.5

func WithFormat(format Format) Option

WithFormat sets the format of the stored object Note: This option is only applicable to object node types.

func WithInputEncoding added in v0.1.5

func WithInputEncoding(encoding InputEncoding) Option

WithInputEncoding sets the encoding of the input data Note: This option is only applicable to object node types.

func WithMultihash added in v0.1.5

func WithMultihash(mhType uint64) Option

WithMultihash sets the multihash type

func WithNodeType added in v0.1.5

func WithNodeType(nodeType NodeType) Option

WithNodeType sets the type of node to use, i.e. object or file

type Provider added in v0.1.1

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

Provider manages multiple clients - one per channel

func NewProvider added in v0.1.1

func NewProvider(providers *olclient.Providers, cfg config) *Provider

NewProvider returns a new client provider

func (*Provider) CreateDCASClientStubWrapper added in v0.1.5

func (p *Provider) CreateDCASClientStubWrapper(coll string, stub shim.ChaincodeStubInterface) (DCAS, error)

CreateDCASClientStubWrapper returns a new DCAS client that wraps the given chaincode stub using the given collection

func (*Provider) GetDCASClient added in v0.1.5

func (p *Provider) GetDCASClient(channelID string, namespace string, coll string) (DCAS, error)

GetDCASClient returns the client for the given channel

Jump to

Keyboard shortcuts

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