ipldbindcode

package
v0.7.14 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: AGPL-3.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPiecesNotAvailable = errors.New("transaction pieces are not available")
	ErrMetadataNotFound   = errors.New("transaction metadata not found")
)
View Source
var DisableHashVerification bool
View Source
var Prototypes schemaSlab

Functions

func EncodeArrayWith16BitLen added in v0.7.1

func EncodeArrayWith16BitLen(values ...any) ([]byte, error)

func LoadDataFromDataFrames added in v0.7.8

func LoadDataFromDataFrames(
	firstDataFrame *DataFrame,
	dataFrameGetter func(ctx context.Context, wantedCid cid.Cid) (*DataFrame, error),
) ([]byte, error)

func VerifyHash

func VerifyHash(data []byte, hash uint64) error

VerifyHash verifies that the provided data matches the provided hash. In case of DataFrames, the hash is stored in the 'Hash' field, and it is the hash of the concatenated 'Data' fields of all the DataFrames.

Types

type Block

type Block struct {
	Kind      int             `json:"kind" yaml:"kind"`
	Slot      int             `json:"slot" yaml:"slot"`
	Shredding List__Shredding `json:"shredding" yaml:"shredding"`
	Entries   List__Link      `json:"entries" yaml:"entries"`
	Meta      SlotMeta        `json:"meta" yaml:"meta"`
	Rewards   datamodel.Link  `json:"rewards" yaml:"rewards"`
}

func (Block) GetBlockHeight

func (n Block) GetBlockHeight() (uint64, bool)

GetBlockHeight returns the 'block_height' field, which indicates the height of the block, and a flag indicating whether the field has a value.

func (*Block) GetBlocktime added in v0.7.8

func (b *Block) GetBlocktime() int64

func (*Block) GetParentSlot added in v0.7.8

func (b *Block) GetParentSlot() uint64

func (Block) GetRewards added in v0.7.8

func (n Block) GetRewards() (cid.Cid, bool)

func (*Block) GetSlot added in v0.7.8

func (b *Block) GetSlot() uint64

GetSlot returns the slot of the block.

func (Block) HasRewards added in v0.7.1

func (n Block) HasRewards() bool

Block.HasRewards

func (*Block) MarshalCBOR added in v0.7.0

func (x *Block) MarshalCBOR() ([]byte, error)

func (Block) Node added in v0.7.8

func (b Block) Node()

func (*Block) Reset added in v0.7.8

func (b *Block) Reset()

Reset resets the Block to an empty state.

func (*Block) UnmarshalCBOR added in v0.6.0

func (x *Block) UnmarshalCBOR(data []byte) error

type Buffer

type Buffer []uint8

func (*Buffer) FromString

func (b *Buffer) FromString(s string) error

func (Buffer) MarshalJSON

func (b Buffer) MarshalJSON() ([]byte, error)

Buffer.MarshalJSON() returns the JSON representation of the Buffer in base64.

func (Buffer) String

func (b Buffer) String() string

Buffer.String() returns the string representation of the Buffer in base64.

func (*Buffer) UnmarshalJSON

func (b *Buffer) UnmarshalJSON(data []byte) error

Buffer.UnmarshalJSON() decodes the JSON representation of the Buffer in base64.

type DataFrame

type DataFrame struct {
	Kind  int          `json:"kind" yaml:"kind"`
	Hash  **int        `json:"hash" yaml:"hash"`
	Index **int        `json:"index" yaml:"index"`
	Total **int        `json:"total" yaml:"total"`
	Data  Buffer       `json:"data" yaml:"data"`
	Next  **List__Link `json:"next" yaml:"next"`
}

func (DataFrame) Bytes

func (n DataFrame) Bytes() []uint8

GetData returns the value of the 'Data' field and a flag indicating whether the field has a value.

func (DataFrame) GetHash

func (n DataFrame) GetHash() (uint64, bool)

GetHash returns the value of the 'Hash' field and a flag indicating whether the field has a value.

func (DataFrame) GetIndex

func (n DataFrame) GetIndex() (int, bool)

GetIndex returns the value of the 'Index' field and a flag indicating whether the field has a value. If the field is not present, assume the index is 0.

func (DataFrame) GetNext

func (n DataFrame) GetNext() (List__Link, bool)

GetNext returns the value of the 'Next' field and a flag indicating whether the field has a value.

func (DataFrame) GetTotal

func (n DataFrame) GetTotal() (int, bool)

GetTotal returns the value of the 'Total' field and a flag indicating whether the field has a value. If the field is not present, assume the total is 1.

func (DataFrame) HasHash

func (n DataFrame) HasHash() bool

DataFrame.HasHash returns whether the 'Hash' field is present.

func (DataFrame) HasIndex

func (n DataFrame) HasIndex() bool

HasIndex returns whether the 'Index' field is present. If the field is not present, assume the index is 0.

func (DataFrame) HasNext

func (n DataFrame) HasNext() bool

HasNext returns whether the 'Next' field is present and non-empty.

func (DataFrame) HasTotal

func (n DataFrame) HasTotal() bool

HasTotal returns whether the 'Total' field is present. If the field is not present, assume the total is 1.

func (*DataFrame) MarshalCBOR added in v0.7.0

func (x *DataFrame) MarshalCBOR() ([]byte, error)

func (DataFrame) MarshalJSON

func (n DataFrame) MarshalJSON() ([]byte, error)

DataFrame.MarshalJSON implements the json.Marshaler interface.

func (DataFrame) Node added in v0.7.8

func (d DataFrame) Node()

func (*DataFrame) Reset added in v0.7.8

func (d *DataFrame) Reset()

Reset resets the DataFrame to an empty state.

func (*DataFrame) UnmarshalCBOR added in v0.6.0

func (x *DataFrame) UnmarshalCBOR(data []byte) error

func (*DataFrame) UnmarshalJSON

func (n *DataFrame) UnmarshalJSON(data []byte) error

DataFrame.UnmarshalJSON implements the json.Unmarshaler interface.

type Entry

type Entry struct {
	Kind         int        `json:"kind" yaml:"kind"`
	NumHashes    int        `json:"num_hashes" yaml:"num_hashes"`
	Hash         Hash       `json:"hash" yaml:"hash"`
	Transactions List__Link `json:"transactions" yaml:"transactions"`
}

func (*Entry) MarshalCBOR added in v0.7.0

func (x *Entry) MarshalCBOR() ([]byte, error)

func (Entry) Node added in v0.7.8

func (e Entry) Node()

func (*Entry) Reset added in v0.7.8

func (e *Entry) Reset()

Reset resets the Entry to an empty state.

func (*Entry) UnmarshalCBOR added in v0.6.0

func (x *Entry) UnmarshalCBOR(data []byte) error

type Epoch

type Epoch struct {
	Kind    int        `json:"kind" yaml:"kind"`
	Epoch   int        `json:"epoch" yaml:"epoch"`
	Subsets List__Link `json:"subsets" yaml:"subsets"`
}

func (*Epoch) MarshalCBOR added in v0.7.0

func (x *Epoch) MarshalCBOR() ([]byte, error)

func (Epoch) Node added in v0.7.8

func (e Epoch) Node()

func (*Epoch) Reset added in v0.7.8

func (e *Epoch) Reset()

Reset resets the Epoch to an empty state.

func (*Epoch) UnmarshalCBOR added in v0.6.0

func (x *Epoch) UnmarshalCBOR(data []byte) error

implement the BinaryUnmarshaler interface for EpochFast

type Hash

type Hash []uint8

func (Hash) MarshalJSON

func (h Hash) MarshalJSON() ([]byte, error)

Hash.MarshalJSON() returns the JSON representation of the Hash in hex.

func (Hash) String

func (h Hash) String() string

Hash.String() returns the string representation of the Hash in hex.

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(data []byte) error

Hash.UnmarshalJSON() decodes the JSON representation of the Hash in hex.

type List__Link []datamodel.Link

func (*List__Link) Reset added in v0.7.8

func (l *List__Link) Reset()

Reset resets the List__Link to an empty state.

type List__Shredding

type List__Shredding []Shredding

func (*List__Shredding) Reset added in v0.7.8

func (l *List__Shredding) Reset()

Reset resets the List__Shredding to an empty state.

type Node added in v0.7.8

type Node interface {
	Node()
}

type Rewards

type Rewards struct {
	Kind int       `json:"kind" yaml:"kind"`
	Slot int       `json:"slot" yaml:"slot"`
	Data DataFrame `json:"data" yaml:"data"`
}

func (*Rewards) MarshalCBOR added in v0.7.0

func (x *Rewards) MarshalCBOR() ([]byte, error)

func (Rewards) Node added in v0.7.8

func (r Rewards) Node()

func (*Rewards) Reset added in v0.7.8

func (r *Rewards) Reset()

Reset resets the Rewards to an empty state.

func (*Rewards) UnmarshalCBOR added in v0.6.0

func (x *Rewards) UnmarshalCBOR(data []byte) error

type Shredding

type Shredding struct {
	EntryEndIdx int `json:"entry_end_idx" yaml:"entry_end_idx"`
	ShredEndIdx int `json:"shred_end_idx" yaml:"shred_end_idx"`
}

func (*Shredding) Reset added in v0.7.8

func (s *Shredding) Reset()

Reset resets the Shredding to an empty state.

type SlotMeta

type SlotMeta struct {
	Parent_slot  int   `json:"parent_slot" yaml:"parent_slot"`
	Blocktime    int   `json:"blocktime" yaml:"blocktime"`
	Block_height **int `json:"block_height" yaml:"block_height"`
}

func (SlotMeta) Equivalent added in v0.7.0

func (n SlotMeta) Equivalent(other SlotMeta) bool

SlotMeta.Equivalent returns whether the two SlotMeta objects are equivalent.

func (SlotMeta) GetBlockHeight added in v0.6.0

func (n SlotMeta) GetBlockHeight() (uint64, bool)

GetBlockHeight returns the value of the 'Block_height' field and a flag indicating whether the field has a value.

func (*SlotMeta) GetBlocktime added in v0.7.8

func (m *SlotMeta) GetBlocktime() int64

GetBlocktime returns the blocktime of the block.

func (SlotMeta) HasBlockHeight added in v0.6.0

func (n SlotMeta) HasBlockHeight() bool

SlotMeta.HasBlockHeight returns whether the 'Block_height' field is present.

func (*SlotMeta) Reset added in v0.7.8

func (s *SlotMeta) Reset()

Reset resets the SlotMeta to an empty state.

type Subset

type Subset struct {
	Kind   int        `json:"kind" yaml:"kind"`
	First  int        `json:"first" yaml:"first"`
	Last   int        `json:"last" yaml:"last"`
	Blocks List__Link `json:"blocks" yaml:"blocks"`
}

func (*Subset) MarshalCBOR added in v0.7.0

func (x *Subset) MarshalCBOR() ([]byte, error)

func (Subset) Node added in v0.7.8

func (s Subset) Node()

func (*Subset) Reset added in v0.7.8

func (s *Subset) Reset()

Reset resets the Subset to an empty state.

func (*Subset) UnmarshalCBOR added in v0.6.0

func (x *Subset) UnmarshalCBOR(data []byte) error

type Transaction

type Transaction struct {
	Kind     int       `json:"kind" yaml:"kind"`
	Data     DataFrame `json:"data" yaml:"data"`
	Metadata DataFrame `json:"metadata" yaml:"metadata"`
	Slot     int       `json:"slot" yaml:"slot"`
	Index    **int     `json:"index" yaml:"index"`
}

func (*Transaction) GetMetadata added in v0.7.8

func (decodedTxObj *Transaction) GetMetadata() (*solanatxmetaparsers.TransactionStatusMetaContainer, error)

GetMetadata will parse and return the metadata of the transaction. NOTE: This will return ErrPiecesNotAvailable if the metadata is split into multiple dataframes. In that case, you should use GetMetadataWithFrameLoader instead.

func (*Transaction) GetMetadataWithFrameLoader added in v0.7.8

func (decodedTxObj *Transaction) GetMetadataWithFrameLoader(dataFrameGetter func(ctx context.Context, wantedCid cid.Cid) (*DataFrame, error)) (*solanatxmetaparsers.TransactionStatusMetaContainer, error)

GetMetadataWithFrameLoader will parse and return the metadata of the transaction. It uses the provided dataFrameGetter function to load the missing dataframes.

func (Transaction) GetPositionIndex

func (n Transaction) GetPositionIndex() (int, bool)

GetPositionIndex returns the 'Index' field, which indicates the index of the transaction in the block (0-based), and a flag indicating whether the field has a value.

func (*Transaction) GetSolanaTransaction added in v0.4.0

func (decoded *Transaction) GetSolanaTransaction() (*solana.Transaction, error)

func (Transaction) HasIndex

func (n Transaction) HasIndex() bool

Transaction.HasIndex returns whether the 'Index' field is present.

func (*Transaction) MarshalCBOR added in v0.7.0

func (x *Transaction) MarshalCBOR() ([]byte, error)

func (Transaction) Node added in v0.7.8

func (t Transaction) Node()

func (*Transaction) Reset added in v0.7.8

func (t *Transaction) Reset()

Reset resets the Transaction to an empty state.

func (*Transaction) Signature added in v0.4.0

func (decoded *Transaction) Signature() (solana.Signature, error)

func (*Transaction) Signatures added in v0.4.0

func (decoded *Transaction) Signatures() ([]solana.Signature, error)

func (*Transaction) UnmarshalCBOR added in v0.6.0

func (x *Transaction) UnmarshalCBOR(data []byte) error

Jump to

Keyboard shortcuts

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