cell

package
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 16 Imported by: 29

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAddressTypeNotSupported = errors.New("address type is not supported")
View Source
var ErrNegative = errors.New("value should be non negative")
View Source
var ErrNoMoreRefs = errors.New("no more refs exists")
View Source
var ErrNoSuchKeyInDict = errors.New("no such key in dict")
View Source
var ErrNotEnoughData = func(has, need int) error {
	return fmt.Errorf("not enough data in reader, need %d, has %d", need, has)
}
View Source
var ErrNotFit1023 = errors.New("cell data size should fit into 1023 bits")
View Source
var ErrRefCannotBeNil = errors.New("ref cannot be nil")
View Source
var ErrSmallSlice = errors.New("too small slice for this size")
View Source
var ErrTooBigSize = errors.New("too big size")
View Source
var ErrTooBigValue = errors.New("too big value")
View Source
var ErrTooMuchRefs = errors.New("too much refs")

Functions

func CheckProof added in v1.6.0

func CheckProof(proof *Cell, hash []byte) error

func ToBOCWithFlags added in v1.8.0

func ToBOCWithFlags(roots []*Cell, flags ...bool) []byte

ToBOCWithFlags - flags are: first - withCRC, second - withIndex, third - withCache

Types

type Builder

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

func BeginCell

func BeginCell() *Builder

func (*Builder) BitsLeft added in v0.6.0

func (b *Builder) BitsLeft() uint

func (*Builder) BitsUsed added in v0.5.0

func (b *Builder) BitsUsed() uint

func (*Builder) Copy added in v0.5.0

func (b *Builder) Copy() *Builder

func (*Builder) EndCell

func (b *Builder) EndCell() *Cell

func (*Builder) MustStoreAddr added in v0.4.0

func (b *Builder) MustStoreAddr(addr *address.Address) *Builder

func (*Builder) MustStoreBigCoins

func (b *Builder) MustStoreBigCoins(value *big.Int) *Builder

func (*Builder) MustStoreBigInt

func (b *Builder) MustStoreBigInt(value *big.Int, sz uint) *Builder

func (*Builder) MustStoreBigUInt added in v1.0.0

func (b *Builder) MustStoreBigUInt(value *big.Int, sz uint) *Builder

func (*Builder) MustStoreBigVarUInt added in v1.7.0

func (b *Builder) MustStoreBigVarUInt(val *big.Int, sz uint) *Builder

func (*Builder) MustStoreBinarySnake added in v1.1.0

func (b *Builder) MustStoreBinarySnake(data []byte) *Builder

func (*Builder) MustStoreBoolBit added in v0.6.0

func (b *Builder) MustStoreBoolBit(value bool) *Builder

func (*Builder) MustStoreBuilder added in v0.6.0

func (b *Builder) MustStoreBuilder(builder *Builder) *Builder

func (*Builder) MustStoreCoins

func (b *Builder) MustStoreCoins(value uint64) *Builder

func (*Builder) MustStoreDict added in v1.0.0

func (b *Builder) MustStoreDict(dict *Dictionary) *Builder

func (*Builder) MustStoreInt added in v1.0.0

func (b *Builder) MustStoreInt(value int64, sz uint) *Builder

func (*Builder) MustStoreMaybeRef added in v0.7.0

func (b *Builder) MustStoreMaybeRef(ref *Cell) *Builder

func (*Builder) MustStoreRef

func (b *Builder) MustStoreRef(ref *Cell) *Builder

func (*Builder) MustStoreSlice

func (b *Builder) MustStoreSlice(bytes []byte, sz uint) *Builder

func (*Builder) MustStoreStringSnake added in v1.1.0

func (b *Builder) MustStoreStringSnake(str string) *Builder

func (*Builder) MustStoreUInt

func (b *Builder) MustStoreUInt(value uint64, sz uint) *Builder

func (*Builder) MustStoreVarUInt added in v1.7.0

func (b *Builder) MustStoreVarUInt(val uint64, sz uint) *Builder

func (*Builder) RefsLeft added in v0.6.0

func (b *Builder) RefsLeft() uint

func (*Builder) RefsUsed added in v0.6.0

func (b *Builder) RefsUsed() int

func (*Builder) StoreAddr added in v0.4.0

func (b *Builder) StoreAddr(addr *address.Address) error

func (*Builder) StoreBigCoins

func (b *Builder) StoreBigCoins(value *big.Int) error

func (*Builder) StoreBigInt

func (b *Builder) StoreBigInt(value *big.Int, sz uint) error

func (*Builder) StoreBigUInt added in v1.0.0

func (b *Builder) StoreBigUInt(value *big.Int, sz uint) error

func (*Builder) StoreBigVarUInt added in v1.7.0

func (b *Builder) StoreBigVarUInt(val *big.Int, sz uint) error

func (*Builder) StoreBinarySnake added in v1.1.0

func (b *Builder) StoreBinarySnake(data []byte) error

func (*Builder) StoreBoolBit added in v0.6.0

func (b *Builder) StoreBoolBit(value bool) error

func (*Builder) StoreBuilder added in v0.6.0

func (b *Builder) StoreBuilder(builder *Builder) error

func (*Builder) StoreCoins

func (b *Builder) StoreCoins(value uint64) error

func (*Builder) StoreDict added in v1.0.0

func (b *Builder) StoreDict(dict *Dictionary) error

func (*Builder) StoreInt added in v1.0.0

func (b *Builder) StoreInt(value int64, sz uint) error

func (*Builder) StoreMaybeRef added in v0.7.0

func (b *Builder) StoreMaybeRef(ref *Cell) error

func (*Builder) StoreRef

func (b *Builder) StoreRef(ref *Cell) error

func (*Builder) StoreSlice

func (b *Builder) StoreSlice(bytes []byte, sz uint) error

func (*Builder) StoreStringSnake added in v1.1.0

func (b *Builder) StoreStringSnake(str string) error

func (*Builder) StoreUInt

func (b *Builder) StoreUInt(value uint64, sz uint) error

func (*Builder) StoreVarUInt added in v1.7.0

func (b *Builder) StoreVarUInt(val uint64, sz uint) error

func (*Builder) ToSlice added in v1.9.0

func (b *Builder) ToSlice() *Slice

type Cell

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

func FromBOC

func FromBOC(data []byte) (*Cell, error)

func FromBOCMultiRoot added in v0.5.0

func FromBOCMultiRoot(data []byte) ([]*Cell, error)

func UnwrapProof added in v1.8.0

func UnwrapProof(proof *Cell, hash []byte) (*Cell, error)

func (*Cell) AsDict added in v1.9.0

func (c *Cell) AsDict(keySz uint) *Dictionary

func (*Cell) BeginParse

func (c *Cell) BeginParse() *Slice

func (*Cell) BitsSize added in v0.6.0

func (c *Cell) BitsSize() uint

func (*Cell) CreateProof added in v1.6.0

func (c *Cell) CreateProof(skeleton *ProofSkeleton) (*Cell, error)

func (*Cell) Depth added in v1.9.0

func (c *Cell) Depth(level ...int) uint16

func (*Cell) Dump added in v0.1.2

func (c *Cell) Dump(limitLength ...int) string

func (*Cell) DumpBits added in v0.5.0

func (c *Cell) DumpBits(limitLength ...int) string

func (*Cell) GetType added in v1.8.0

func (c *Cell) GetType() Type

func (*Cell) Hash added in v0.5.0

func (c *Cell) Hash(level ...int) []byte

Hash - calculates a hash of cell recursively Once calculated, it is cached and can be reused cheap.

func (*Cell) MarshalJSON added in v1.7.1

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

func (*Cell) MustPeekRef added in v1.8.0

func (c *Cell) MustPeekRef(i int) *Cell

func (*Cell) PeekRef added in v1.8.0

func (c *Cell) PeekRef(i int) (*Cell, error)

func (*Cell) RefsNum added in v0.6.0

func (c *Cell) RefsNum() uint

func (*Cell) Sign added in v0.6.0

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

func (*Cell) ToBOC

func (c *Cell) ToBOC() []byte

func (*Cell) ToBOCWithFlags

func (c *Cell) ToBOCWithFlags(flags ...bool) []byte

func (*Cell) ToBuilder added in v0.6.0

func (c *Cell) ToBuilder() *Builder

func (*Cell) UnmarshalJSON added in v1.7.1

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

func (*Cell) UnsafeModify added in v1.8.0

func (c *Cell) UnsafeModify(levelMask LevelMask, special bool)

func (*Cell) Verify added in v1.8.2

func (c *Cell) Verify(key ed25519.PublicKey, signature []byte) bool

type DictKV added in v1.9.0

type DictKV struct {
	Key   *Slice
	Value *Slice
}

type Dictionary added in v0.5.0

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

func NewDict added in v1.0.0

func NewDict(keySz uint) *Dictionary

func (*Dictionary) All deprecated added in v0.5.0

func (d *Dictionary) All() []*HashmapKV

Deprecated: use LoadAll, dict was reimplemented, so it will be parsed during this call, and it can return error now.

func (*Dictionary) AsCell added in v1.9.0

func (d *Dictionary) AsCell() *Cell

func (*Dictionary) Delete added in v1.8.2

func (d *Dictionary) Delete(key *Cell) error

func (*Dictionary) DeleteIntKey added in v1.8.2

func (d *Dictionary) DeleteIntKey(key *big.Int) error

func (*Dictionary) Get deprecated added in v0.5.0

func (d *Dictionary) Get(key *Cell) *Cell

Deprecated: use LoadValue

func (*Dictionary) GetByIntKey deprecated added in v1.2.0

func (d *Dictionary) GetByIntKey(key *big.Int) *Cell

Deprecated: use LoadValueByIntKey

func (*Dictionary) IsEmpty added in v1.9.0

func (d *Dictionary) IsEmpty() bool

func (*Dictionary) LoadAll added in v1.9.0

func (d *Dictionary) LoadAll() ([]DictKV, error)

func (*Dictionary) LoadValue added in v1.9.0

func (d *Dictionary) LoadValue(key *Cell) (*Slice, error)

LoadValue - searches key in the underline dict cell and returns its value

If key is not found ErrNoSuchKeyInDict will be returned

func (*Dictionary) LoadValueByIntKey added in v1.9.0

func (d *Dictionary) LoadValueByIntKey(key *big.Int) (*Slice, error)

LoadValueByIntKey - same as LoadValue, but constructs cell key from int

func (*Dictionary) LoadValueWithProof added in v1.9.0

func (d *Dictionary) LoadValueWithProof(key *Cell, skeleton *ProofSkeleton) (*Slice, *ProofSkeleton, error)

LoadValueWithProof - searches key in the underline dict cell, constructs proof path and returns leaf

If key is not found ErrNoSuchKeyInDict will be returned

func (*Dictionary) MustToCell deprecated added in v1.0.0

func (d *Dictionary) MustToCell() *Cell

Deprecated: use AsCell

func (*Dictionary) Set added in v1.0.0

func (d *Dictionary) Set(key, value *Cell) error

func (*Dictionary) SetIntKey added in v1.1.0

func (d *Dictionary) SetIntKey(key *big.Int, value *Cell) error

func (*Dictionary) Size deprecated added in v1.8.0

func (d *Dictionary) Size() int

Deprecated: use IsEmpty or LoadAll and then len

func (*Dictionary) ToCell deprecated added in v1.0.0

func (d *Dictionary) ToCell() (*Cell, error)

Deprecated: use AsCell

type HashmapKV added in v0.5.0

type HashmapKV struct {
	Key   *Cell
	Value *Cell
}

type LevelMask added in v1.7.1

type LevelMask struct {
	Mask byte
}

func (LevelMask) Apply added in v1.8.0

func (m LevelMask) Apply(level int) LevelMask

func (LevelMask) GetLevel added in v1.8.0

func (m LevelMask) GetLevel() int

func (LevelMask) IsSignificant added in v1.8.0

func (m LevelMask) IsSignificant(level int) bool

type ProofSkeleton added in v1.9.0

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

func CreateProofSkeleton added in v1.9.0

func CreateProofSkeleton() *ProofSkeleton

func (*ProofSkeleton) AttachAt added in v1.9.0

func (s *ProofSkeleton) AttachAt(i int, sk *ProofSkeleton)

AttachAt - attach skeleton chain at specific ref slot

func (*ProofSkeleton) Copy added in v1.9.0

func (s *ProofSkeleton) Copy() *ProofSkeleton

func (*ProofSkeleton) Merge added in v1.9.0

func (s *ProofSkeleton) Merge(sk *ProofSkeleton)

Merge - merge 2 proof chains in a single proof tree

func (*ProofSkeleton) ProofRef added in v1.9.0

func (s *ProofSkeleton) ProofRef(i int) *ProofSkeleton

ProofRef - include ref with index i to proof

func (*ProofSkeleton) SetRecursive added in v1.9.0

func (s *ProofSkeleton) SetRecursive()

SetRecursive - include all underlying refs recursively in ordinary form to proof

type Slice added in v1.0.0

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

func (*Slice) BitsLeft added in v1.0.0

func (c *Slice) BitsLeft() uint

func (*Slice) Copy added in v1.0.0

func (c *Slice) Copy() *Slice

func (*Slice) IsSpecial added in v1.8.9

func (c *Slice) IsSpecial() bool

func (*Slice) LoadAddr added in v1.0.0

func (c *Slice) LoadAddr() (*address.Address, error)

func (*Slice) LoadBigCoins added in v1.0.0

func (c *Slice) LoadBigCoins() (*big.Int, error)

func (*Slice) LoadBigInt added in v1.0.0

func (c *Slice) LoadBigInt(sz uint) (*big.Int, error)

func (*Slice) LoadBigUInt added in v1.0.0

func (c *Slice) LoadBigUInt(sz uint) (*big.Int, error)

func (*Slice) LoadBinarySnake added in v1.1.0

func (c *Slice) LoadBinarySnake() ([]byte, error)

func (*Slice) LoadBoolBit added in v1.0.0

func (c *Slice) LoadBoolBit() (bool, error)

func (*Slice) LoadCoins added in v1.0.0

func (c *Slice) LoadCoins() (uint64, error)

func (*Slice) LoadDict added in v1.0.0

func (c *Slice) LoadDict(keySz uint) (*Dictionary, error)

func (*Slice) LoadInt added in v1.0.0

func (c *Slice) LoadInt(sz uint) (int64, error)

func (*Slice) LoadMaybeRef added in v1.0.0

func (c *Slice) LoadMaybeRef() (*Slice, error)

func (*Slice) LoadRef added in v1.0.0

func (c *Slice) LoadRef() (*Slice, error)

func (*Slice) LoadRefCell added in v1.8.0

func (c *Slice) LoadRefCell() (*Cell, error)

func (*Slice) LoadSlice added in v1.0.0

func (c *Slice) LoadSlice(sz uint) ([]byte, error)

func (*Slice) LoadStringSnake added in v1.1.0

func (c *Slice) LoadStringSnake() (string, error)

func (*Slice) LoadUInt added in v1.0.0

func (c *Slice) LoadUInt(sz uint) (uint64, error)

func (*Slice) LoadVarUInt added in v1.0.0

func (c *Slice) LoadVarUInt(sz uint) (*big.Int, error)

func (*Slice) MustLoadAddr added in v1.0.0

func (c *Slice) MustLoadAddr() *address.Address

func (*Slice) MustLoadBigCoins added in v1.0.0

func (c *Slice) MustLoadBigCoins() *big.Int

func (*Slice) MustLoadBigUInt added in v1.0.0

func (c *Slice) MustLoadBigUInt(sz uint) *big.Int

func (*Slice) MustLoadBinarySnake added in v1.1.0

func (c *Slice) MustLoadBinarySnake() []byte

func (*Slice) MustLoadBoolBit added in v1.0.0

func (c *Slice) MustLoadBoolBit() bool

func (*Slice) MustLoadCoins added in v1.0.0

func (c *Slice) MustLoadCoins() uint64

func (*Slice) MustLoadDict added in v1.0.1

func (c *Slice) MustLoadDict(keySz uint) *Dictionary

func (*Slice) MustLoadInt added in v1.0.0

func (c *Slice) MustLoadInt(sz uint) int64

func (*Slice) MustLoadMaybeRef added in v1.0.0

func (c *Slice) MustLoadMaybeRef() *Slice

func (*Slice) MustLoadRef added in v1.0.0

func (c *Slice) MustLoadRef() *Slice

func (*Slice) MustLoadSlice added in v1.0.0

func (c *Slice) MustLoadSlice(sz uint) []byte

func (*Slice) MustLoadStringSnake added in v1.1.0

func (c *Slice) MustLoadStringSnake() string

func (*Slice) MustLoadUInt added in v1.0.0

func (c *Slice) MustLoadUInt(sz uint) uint64

func (*Slice) MustLoadVarUInt added in v1.7.0

func (c *Slice) MustLoadVarUInt(sz uint) *big.Int

func (*Slice) MustToCell added in v1.0.0

func (c *Slice) MustToCell() *Cell

func (*Slice) RefsNum added in v1.0.0

func (c *Slice) RefsNum() int

func (*Slice) RestBits added in v1.0.0

func (c *Slice) RestBits() (uint, []byte, error)

func (*Slice) ToBuilder added in v1.9.0

func (c *Slice) ToBuilder() *Builder

func (*Slice) ToCell added in v1.0.0

func (c *Slice) ToCell() (*Cell, error)

func (*Slice) ToDict added in v1.0.0

func (c *Slice) ToDict(keySz uint) (*Dictionary, error)

type Type added in v1.8.0

type Type uint8
const (
	OrdinaryCellType     Type = 0x00
	PrunedCellType       Type = 0x01
	LibraryCellType      Type = 0x02
	MerkleProofCellType  Type = 0x03
	MerkleUpdateCellType Type = 0x04
	UnknownCellType      Type = 0xFF
)

Jump to

Keyboard shortcuts

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