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 ¶
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.