boc

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: MIT Imports: 13 Imported by: 27

README

TON bag-of-cells (BOC) and Cell implementation.

This library implements structures and methods to interact with TON bag-of-cells (BOC) and Cells.

BOC and Cell description:

Usage

Example

Documentation

Index

Constants

View Source
const BOCSizeLimit = 65536
View Source
const CellBits = 1023

Variables

View Source
var ErrBitStingOverflow = errors.New("BitString overflow")
View Source
var ErrCellRefsOverflow = errors.New("too many refs")
View Source
var ErrDepthIsTooBig = errors.New("depth is too big")
View Source
var ErrInvalidHex = errors.New("invalid hex representation of bitstring")
View Source
var ErrNotEnoughBits = errors.New("not enough bits")
View Source
var ErrNotEnoughRefs = errors.New("not enough refs")
View Source
var ErrNotSingleRoot = errors.New("should be one root cell")

Functions

func SerializeBoc

func SerializeBoc(cell *Cell, idx bool, hasCrc32 bool, cacheBits bool, flags uint) ([]byte, error)

Types

type BitString

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

func BitStringFromFiftHex added in v1.0.1

func BitStringFromFiftHex(hexRepr string) (*BitString, error)

BitStringFromFiftHex constructs a new BitString from the given hex representation.

func NewBitString

func NewBitString(bitLen int) BitString

func (*BitString) Append

func (s *BitString) Append(b BitString)

func (*BitString) BinaryString

func (s *BitString) BinaryString() string

func (*BitString) BitsAvailableForRead

func (s *BitString) BitsAvailableForRead() int

func (*BitString) BitsAvailableForWrite

func (s *BitString) BitsAvailableForWrite() int

func (*BitString) Buffer

func (s *BitString) Buffer() []byte

func (*BitString) Copy

func (s *BitString) Copy() BitString

func (*BitString) GetTopUppedArray

func (s *BitString) GetTopUppedArray() ([]byte, error)

func (*BitString) GetWriteCursor

func (s *BitString) GetWriteCursor() int

func (*BitString) Grow

func (s *BitString) Grow(bitLen int)

func (BitString) MarshalJSON added in v1.0.1

func (s BitString) MarshalJSON() ([]byte, error)

func (*BitString) Off

func (s *BitString) Off(n int) error

func (*BitString) On

func (s *BitString) On(n int) error

func (*BitString) PickUint

func (s *BitString) PickUint(bitLen int) (uint64, error)

func (*BitString) Print

func (s *BitString) Print()

func (*BitString) ReadBigInt

func (s *BitString) ReadBigInt(bitLen int) (*big.Int, error)

func (*BitString) ReadBigUint

func (s *BitString) ReadBigUint(bitLen int) (*big.Int, error)

func (*BitString) ReadBit

func (s *BitString) ReadBit() (bool, error)

func (*BitString) ReadBits

func (s *BitString) ReadBits(n int) (BitString, error)

func (*BitString) ReadByte

func (s *BitString) ReadByte() (byte, error)

func (*BitString) ReadBytes

func (s *BitString) ReadBytes(size int) ([]byte, error)

func (*BitString) ReadInt

func (s *BitString) ReadInt(bitLen int) (int64, error)

func (*BitString) ReadLimUint

func (s *BitString) ReadLimUint(n int) (uint, error)

ReadLimUint #<= n

func (*BitString) ReadRemainingBits

func (s *BitString) ReadRemainingBits() BitString

func (*BitString) ReadUint

func (s *BitString) ReadUint(bitLen int) (uint64, error)

func (*BitString) ReadUnary

func (s *BitString) ReadUnary() (uint, error)

func (*BitString) ResetCounter

func (s *BitString) ResetCounter()

func (*BitString) SetTopUppedArray

func (s *BitString) SetTopUppedArray(arr []byte, fulfilledBytes bool) error

func (*BitString) Skip

func (s *BitString) Skip(n int) error

func (*BitString) ToFiftHex

func (s *BitString) ToFiftHex() string

ToFiftHex returns a TON hex representation of this bit string.

func (*BitString) UnmarshalJSON added in v1.0.1

func (s *BitString) UnmarshalJSON(b []byte) error

func (*BitString) WriteBigInt

func (s *BitString) WriteBigInt(val *big.Int, bitLen int) error

func (*BitString) WriteBigUint

func (s *BitString) WriteBigUint(val *big.Int, bitLen int) error

func (*BitString) WriteBit

func (s *BitString) WriteBit(val bool) error

func (*BitString) WriteBitArray

func (s *BitString) WriteBitArray(val []bool) error

func (*BitString) WriteBitString

func (s *BitString) WriteBitString(bs BitString) error

func (*BitString) WriteByte

func (s *BitString) WriteByte(val byte) error

func (*BitString) WriteBytes

func (s *BitString) WriteBytes(data []byte) error

func (*BitString) WriteInt

func (s *BitString) WriteInt(val int64, bitLen int) error

func (*BitString) WriteLimUint

func (s *BitString) WriteLimUint(val, n int) error

WriteLimUint #<= n

func (*BitString) WriteUint

func (s *BitString) WriteUint(val uint64, bitLen int) error

func (*BitString) WriteUnary

func (s *BitString) WriteUnary(n uint) error

type Cell

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

func DeserializeBoc

func DeserializeBoc(boc []byte) ([]*Cell, error)

func DeserializeBocBase64

func DeserializeBocBase64(boc string) ([]*Cell, error)

func DeserializeBocHex

func DeserializeBocHex(boc string) ([]*Cell, error)

func DeserializeSinglRootBase64 added in v1.0.1

func DeserializeSinglRootBase64(boc string) (*Cell, error)

func NewCell

func NewCell() *Cell

func NewCellExotic

func NewCellExotic(cellType CellType) *Cell

func NewCellWithBits added in v1.0.1

func NewCellWithBits(b BitString) *Cell

func (*Cell) AddRef

func (c *Cell) AddRef(c2 *Cell) error

func (*Cell) BitSize

func (c *Cell) BitSize() int

func (*Cell) BitsAvailableForRead

func (c *Cell) BitsAvailableForRead() int

func (*Cell) BitsAvailableForWrite

func (c *Cell) BitsAvailableForWrite() int

func (*Cell) CellType

func (c *Cell) CellType() CellType

func (*Cell) CopyRemaining added in v1.3.0

func (c *Cell) CopyRemaining() *Cell

func (*Cell) Hash

func (c *Cell) Hash() ([]byte, error)

func (*Cell) Hash256 added in v1.2.0

func (c *Cell) Hash256() ([32]byte, error)

func (*Cell) HashString

func (c *Cell) HashString() (string, error)

func (*Cell) IsExotic

func (c *Cell) IsExotic() bool

func (*Cell) Level

func (c *Cell) Level() int

Level returns a level of this cell.

func (Cell) MarshalJSON added in v1.0.1

func (c Cell) MarshalJSON() ([]byte, error)

func (*Cell) NewRef

func (c *Cell) NewRef() (*Cell, error)

func (*Cell) NextRef

func (c *Cell) NextRef() (*Cell, error)

func (*Cell) PickUint

func (c *Cell) PickUint(bitLen int) (uint64, error)

func (*Cell) RawBitString

func (c *Cell) RawBitString() BitString

func (*Cell) ReadBigInt added in v1.0.1

func (c *Cell) ReadBigInt(n int) (*big.Int, error)

func (*Cell) ReadBigUint

func (c *Cell) ReadBigUint(n int) (*big.Int, error)

func (*Cell) ReadBit

func (c *Cell) ReadBit() (bool, error)

func (*Cell) ReadBits

func (c *Cell) ReadBits(n int) (BitString, error)

func (*Cell) ReadBytes

func (c *Cell) ReadBytes(n int) ([]byte, error)

func (*Cell) ReadInt

func (c *Cell) ReadInt(n int) (int64, error)

func (*Cell) ReadLimUint

func (c *Cell) ReadLimUint(n int) (uint, error)

func (*Cell) ReadRemainingBits

func (c *Cell) ReadRemainingBits() BitString

func (*Cell) ReadUint

func (c *Cell) ReadUint(bitLen int) (uint64, error)

func (*Cell) ReadUnary

func (c *Cell) ReadUnary() (uint, error)

func (*Cell) Refs

func (c *Cell) Refs() []*Cell

func (*Cell) RefsAvailableForRead

func (c *Cell) RefsAvailableForRead() int

func (*Cell) RefsSize

func (c *Cell) RefsSize() int

func (*Cell) ResetCounters

func (c *Cell) ResetCounters()

func (*Cell) Sign

func (c *Cell) Sign(key ed25519.PrivateKey) ([]byte, error)

func (*Cell) Skip

func (c *Cell) Skip(n int) error

func (*Cell) ToBoc

func (c *Cell) ToBoc() ([]byte, error)

func (*Cell) ToBocBase64

func (c *Cell) ToBocBase64() (string, error)

func (*Cell) ToBocBase64Custom

func (c *Cell) ToBocBase64Custom(idx bool, hasCrc32 bool, cacheBits bool, flags uint) (string, error)

func (*Cell) ToBocCustom

func (c *Cell) ToBocCustom(idx bool, hasCrc32 bool, cacheBits bool, flags uint) ([]byte, error)

func (*Cell) ToBocCustomWithHasher added in v1.5.2

func (c *Cell) ToBocCustomWithHasher(hasher *Hasher, idx bool, hasCrc32 bool, cacheBits bool, flags uint) ([]byte, error)

func (*Cell) ToBocString

func (c *Cell) ToBocString() (string, error)

func (*Cell) ToBocStringCustom

func (c *Cell) ToBocStringCustom(idx bool, hasCrc32 bool, cacheBits bool, flags uint) (string, error)

func (Cell) ToString

func (c Cell) ToString() string

func (*Cell) UnmarshalJSON added in v1.0.1

func (c *Cell) UnmarshalJSON(b []byte) error

func (*Cell) WriteBigInt added in v1.0.1

func (c *Cell) WriteBigInt(val *big.Int, bitLen int) error

func (*Cell) WriteBigUint added in v1.0.1

func (c *Cell) WriteBigUint(val *big.Int, bitLen int) error

func (*Cell) WriteBit

func (c *Cell) WriteBit(val bool) error

func (*Cell) WriteBitString

func (c *Cell) WriteBitString(s BitString) error

func (*Cell) WriteBytes

func (c *Cell) WriteBytes(b []byte) error

func (*Cell) WriteInt

func (c *Cell) WriteInt(val int64, bitLen int) error

func (*Cell) WriteLimUint

func (c *Cell) WriteLimUint(val, n int) error

func (*Cell) WriteUint

func (c *Cell) WriteUint(val uint64, bitLen int) error

func (*Cell) WriteUnary

func (c *Cell) WriteUnary(n uint) error

type CellType

type CellType uint8
const (
	OrdinaryCell CellType = iota
	PrunedBranchCell
	LibraryCell
	MerkleProofCell
	MerkleUpdateCell
)

type Hasher added in v1.0.1

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

Hasher calculates a cell's hash more efficiently than calling Hash() directly on a cell.

This is a performance optimization hack and must be used only with a read-only tree of cells. Hasher relies on two facts: * some cells can be used multiple times in different places inside the tree * the tree is readonly and thus any hash, once calculated, won't change.

func NewHasher added in v1.0.1

func NewHasher() *Hasher

func (*Hasher) Hash added in v1.0.1

func (h *Hasher) Hash(c *Cell) ([]byte, error)

func (*Hasher) HashString added in v1.0.1

func (h *Hasher) HashString(c *Cell) (string, error)

Jump to

Keyboard shortcuts

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