Documentation ¶
Index ¶
- Constants
- func NewBlockService(b blockstore.Blockstore, ex exchange.Interface) blockservice.BlockService
- type BlockBuilder
- type Data
- type DataHasher
- type DataID
- func (s DataID) BlockFromFile(ctx context.Context, f file.EdsFile) (blocks.Block, error)
- func (s DataID) Cid() cid.Cid
- func (s DataID) GetHeight() uint64
- func (s DataID) MarshalBinary() ([]byte, error)
- func (s DataID) Namespace() share.Namespace
- func (s *DataID) UnmarshalBinary(data []byte) error
- func (s DataID) Verify(root *share.Root) error
- type Getter
- func (g *Getter) GetEDS(ctx context.Context, hdr *header.ExtendedHeader) (*rsmt2d.ExtendedDataSquare, error)
- func (g *Getter) GetShare(ctx context.Context, header *header.ExtendedHeader, row, col int) (share.Share, error)
- func (g *Getter) GetShares(ctx context.Context, hdr *header.ExtendedHeader, smplIdxs ...int) ([]share.Share, error)
- func (g *Getter) GetSharesByNamespace(ctx context.Context, hdr *header.ExtendedHeader, ns share.Namespace) (share.NamespacedShares, error)
- type Row
- type RowHasher
- type RowID
- func (rid RowID) BlockFromFile(ctx context.Context, f file.EdsFile) (blocks.Block, error)
- func (rid RowID) Cid() cid.Cid
- func (rid RowID) GetHeight() uint64
- func (rid RowID) MarshalBinary() ([]byte, error)
- func (rid RowID) MarshalTo(data []byte) (int, error)
- func (rid *RowID) UnmarshalBinary(data []byte) error
- func (rid *RowID) UnmarshalFrom(data []byte) (int, error)
- func (rid RowID) Verify(root *share.Root) error
- type Sample
- type SampleHasher
- type SampleID
- func (sid SampleID) BlockFromFile(ctx context.Context, f file.EdsFile) (blocks.Block, error)
- func (sid SampleID) Cid() cid.Cid
- func (sid SampleID) GetHeight() uint64
- func (sid SampleID) MarshalBinary() ([]byte, error)
- func (sid *SampleID) UnmarshalBinary(data []byte) error
- func (sid SampleID) Verify(root *share.Root) error
- type SampleProofType
Constants ¶
const ( // RowProofType is a sample proven via row root of the square. RowProofType = rsmt2d.Row // ColProofType is a sample proven via column root of the square. ColProofType = rsmt2d.Col )
const DataIDSize = RowIDSize + share.NamespaceSize
DataIDSize is the size of the DataID in bytes.
const RowIDSize = 10
RowIDSize is the size of the RowID in bytes
const SampleIDSize = RowIDSize + 2
SampleIDSize is the size of the SampleID in bytes
Variables ¶
This section is empty.
Functions ¶
func NewBlockService ¶
func NewBlockService(b blockstore.Blockstore, ex exchange.Interface) blockservice.BlockService
NewBlockService creates a new blockservice.BlockService with allowlist supporting the protocol.
Types ¶
type BlockBuilder ¶
type BlockBuilder interface { // TODO(@walldiss): don't like this name, but it collides with field name in RowID GetHeight() uint64 BlockFromFile(ctx context.Context, file file.EdsFile) (blocks.Block, error) }
BlockBuilder is an interface for building blocks from files.
func BlockBuilderFromCID ¶
func BlockBuilderFromCID(cid cid.Cid) (BlockBuilder, error)
BlockBuilderFromCID returns a BlockBuilder from a CID. it acts as multiplexer for different block types.
type Data ¶
func DataFromBlock ¶
DataFromBlock converts blocks.Block into Data.
func NewDataFromEDS ¶
func NewDataFromEDS( square *rsmt2d.ExtendedDataSquare, height uint64, namespace share.Namespace, ) ([]*Data, error)
NewDataFromEDS samples the EDS and constructs Data for each row with the given namespace.
func (*Data) MarshalBinary ¶
MarshalBinary marshals Data to binary.
func (*Data) UnmarshalBinary ¶
UnmarshalBinary unmarshal Data from binary.
type DataHasher ¶
type DataHasher struct {
// contains filtered or unexported fields
}
DataHasher implements hash.Hash interface for Data.
func (*DataHasher) BlockSize ¶
func (h *DataHasher) BlockSize() int
BlockSize returns the hash's underlying block size.
func (*DataHasher) Size ¶
func (h *DataHasher) Size() int
Size returns the number of bytes Sum will return.
func (*DataHasher) Sum ¶
func (h *DataHasher) Sum([]byte) []byte
Sum returns the "multihash" of the DataID.
type DataID ¶
type DataID struct { // TODO(@walldiss): why embed instead of just having a field? RowID // DataNamespace is the namespace of the data // It's string formatted to keep DataID comparable DataNamespace string }
DataID is an unique identifier of a namespaced Data inside EDS Row.
func DataIDFromCID ¶
DataIDFromCID coverts CID to DataID.
func NewDataID ¶
func NewDataID(height uint64, rowIdx uint16, namespace share.Namespace, root *share.Root) (DataID, error)
NewDataID constructs a new DataID.
func (DataID) BlockFromFile ¶
func (DataID) MarshalBinary ¶
MarshalBinary encodes DataID into binary form. NOTE: Proto is avoided because * Its size is not deterministic which is required for IPLD. * No support for uint16
func (*DataID) UnmarshalBinary ¶
UnmarshalBinary decodes DataID from binary form.
type Getter ¶
type Getter struct {
// contains filtered or unexported fields
}
TODO: GetRow method
func NewGetter ¶
func NewGetter(fetch exchange.SessionExchange, bstore blockstore.Blockstore) *Getter
func (*Getter) GetEDS ¶
func (g *Getter) GetEDS(ctx context.Context, hdr *header.ExtendedHeader) (*rsmt2d.ExtendedDataSquare, error)
GetEDS TODO(@Wondertan): Consider requesting randomized rows instead of ODS only
func (*Getter) GetShares ¶
func (g *Getter) GetShares(ctx context.Context, hdr *header.ExtendedHeader, smplIdxs ...int) ([]share.Share, error)
TODO: Make GetSamples so it provides proofs to users. GetShares fetches in the Block/EDS by their indexes. Automatically caches them on the Blockstore. Guarantee that the returned shares are in the same order as shrIdxs.
func (*Getter) GetSharesByNamespace ¶
func (g *Getter) GetSharesByNamespace( ctx context.Context, hdr *header.ExtendedHeader, ns share.Namespace, ) (share.NamespacedShares, error)
type Row ¶
Row represents a Row of an EDS.
func NewRowFromEDS ¶
NewRowFromEDS constructs a new Row from the given EDS.
func RowFromBlock ¶
RowFromBlock converts blocks.Block into Row.
func (*Row) MarshalBinary ¶
MarshalBinary marshals Row to binary.
func (*Row) UnmarshalBinary ¶
UnmarshalBinary unmarshal Row from binary.
type RowHasher ¶
type RowHasher struct {
// contains filtered or unexported fields
}
RowHasher implements hash.Hash interface for Row.
type RowID ¶
type RowID struct { // Height of the block. // Needed to identify block's data square in the whole chain Height uint64 // RowIndex is the index of the axis(row, col) in the data square RowIndex uint16 }
RowID is an unique identifier of a Row.
func RowIDFromCID ¶
RowIDFromCID coverts CID to RowID.
func (RowID) BlockFromFile ¶
func (RowID) MarshalBinary ¶
MarshalBinary encodes RowID into binary form.
func (RowID) MarshalTo ¶
MarshalTo encodes RowID into given byte slice. NOTE: Proto is avoided because * Its size is not deterministic which is required for IPLD. * No support for uint16
func (*RowID) UnmarshalBinary ¶
UnmarshalBinary decodes RowID from binary form.
func (*RowID) UnmarshalFrom ¶
UnmarshalFrom decodes RowID from given byte slice.
type Sample ¶
type Sample struct { SampleID // SampleProofType of the Sample SampleProofType SampleProofType // SampleProof of SampleShare inclusion in the NMT SampleProof nmt.Proof SampleShare share.Share }
Sample represents a sample of an NMT in EDS.
func NewSampleFromEDS ¶
func NewSampleFromEDS( proofType SampleProofType, smplIdx int, square *rsmt2d.ExtendedDataSquare, height uint64, ) (*Sample, error)
NewSampleFromEDS samples the EDS and constructs a new row-proven Sample.
func SampleFromBlock ¶
SampleFromBlock converts blocks.Block into Sample.
func (*Sample) MarshalBinary ¶
MarshalBinary marshals Sample to binary.
func (*Sample) UnmarshalBinary ¶
UnmarshalBinary unmarshal Sample from binary.
type SampleHasher ¶
type SampleHasher struct {
// contains filtered or unexported fields
}
SampleHasher implements hash.Hash interface for Sample.
func (*SampleHasher) BlockSize ¶
func (h *SampleHasher) BlockSize() int
BlockSize returns the hash's underlying block size.
func (*SampleHasher) Reset ¶
func (h *SampleHasher) Reset()
Reset resets the Hash to its initial state.
func (*SampleHasher) Size ¶
func (h *SampleHasher) Size() int
Size returns the number of bytes Sum will return.
func (*SampleHasher) Sum ¶
func (h *SampleHasher) Sum([]byte) []byte
Sum returns the "multihash" of the SampleID.
type SampleID ¶
type SampleID struct { // TODO(@walldiss): why embed instead of just having a field? RowID ShareIndex uint16 }
SampleID is an unique identifier of a Sample.
func NewSampleID ¶
NewSampleID constructs a new SampleID.
func SampleIDFromCID ¶
SampleIDFromCID coverts CID to SampleID.
func (SampleID) BlockFromFile ¶
func (SampleID) MarshalBinary ¶
MarshalBinary encodes SampleID into binary form. NOTE: Proto is avoided because * Its size is not deterministic which is required for IPLD. * No support for uint16
func (*SampleID) UnmarshalBinary ¶
UnmarshalBinary decodes SampleID from binary form.
type SampleProofType ¶
SampleProofType is either row or column proven Sample.