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.
type Block ¶
type Block interface { RawData() []byte Cid() cid.Cid String() string Loggable() map[string]interface{} }
Block provides abstraction for blocks implementations.
type DataProcessedBlock ¶ added in v0.0.3
type DataProcessedBlock struct {
// contains filtered or unexported fields
}
func NewProcessedBlock ¶ added in v0.0.3
func NewProcessedBlock(b *BasicBlock, processedData []byte) *DataProcessedBlock
NewProcessedBlock creates a DataProcessedBlock object from processed data. It will hash the data.
func NewProcessedBlockWithCid ¶ added in v0.0.3
func NewProcessedBlockWithCid(b *BasicBlock, processedData []byte, c cid.Cid) (*DataProcessedBlock, error)
NewProcessedBlockWithCid 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 (*DataProcessedBlock) Cid ¶ added in v0.0.3
func (dpb *DataProcessedBlock) Cid() cid.Cid
Cid Get processed block cid
func (*DataProcessedBlock) GetBasicBlock ¶ added in v0.0.3
func (dpb *DataProcessedBlock) GetBasicBlock() *BasicBlock
func (*DataProcessedBlock) Loggable ¶ added in v0.0.3
func (dpb *DataProcessedBlock) Loggable() map[string]interface{}
Loggable returns a go-log loggable item.
func (*DataProcessedBlock) RawData ¶ added in v0.0.3
func (dpb *DataProcessedBlock) RawData() []byte
RawData Get raw processed data
func (*DataProcessedBlock) String ¶ added in v0.0.3
func (dpb *DataProcessedBlock) String() string
String provides a human-readable representation of the processed block CID.