blocks

package
v0.0.0-...-8b9b725 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2019 License: MIT, MIT Imports: 5 Imported by: 82

README

go-block-format

Coverage Status Travis CI

go-block-format is a set of interfaces that a type needs to implement in order to be a CID addressable block of data.

Table of Contents

Install

make install

Contribute

PRs are welcome!

Small note: If editing the Readme, please conform to the standard-readme specification.

License

MIT © Juan Batiz-Benet

Documentation

Overview

Package blocks contains the lowest level of IPLD data structures. A block is raw data accompanied by a CID. The CID contains the multihash corresponding to the block.

Index

Constants

This section is empty.

Variables

View Source
var ErrWrongHash = errors.New("data did not match given hash")

ErrWrongHash is returned when the Cid of a block is not the expected according to the contents. It is currently used only when debugging.

Functions

This section is empty.

Types

type BasicBlock

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

A BasicBlock is a singular block of data in ipfs. It implements the Block interface.

func NewBlock

func NewBlock(data []byte) *BasicBlock

NewBlock creates a Block object from opaque data. It will hash the data.

func NewBlockWithCid

func NewBlockWithCid(data []byte, c cid.Cid) (*BasicBlock, error)

NewBlockWithCid creates a new block when the hash of the data is already known, this is used to save time in situations where we are able to be confident that the data is correct.

func (*BasicBlock) Cid

func (b *BasicBlock) Cid() cid.Cid

Cid returns the content identifier of the block.

func (*BasicBlock) Loggable

func (b *BasicBlock) Loggable() map[string]interface{}

Loggable returns a go-log loggable item.

func (*BasicBlock) Multihash

func (b *BasicBlock) Multihash() mh.Multihash

Multihash returns the hash contained in the block CID.

func (*BasicBlock) RawData

func (b *BasicBlock) RawData() []byte

RawData returns the block raw contents as a byte slice.

func (*BasicBlock) String

func (b *BasicBlock) String() string

String provides a human-readable representation of the block CID.

type Block

type Block interface {
	RawData() []byte
	Cid() cid.Cid
	String() string
	Loggable() map[string]interface{}
}

Block provides abstraction for blocks implementations.

Jump to

Keyboard shortcuts

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