storage

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BalanceChunks uint16 = 1
	AssetChunks   uint16 = 5
	OrderChunks   uint16 = 2
	LoanChunks    uint16 = 1
)

Variables

View Source
var ErrInvalidBalance = errors.New("invalid balance")

Functions

func AddBalance

func AddBalance(
	ctx context.Context,
	mu state.Mutable,
	pk ed25519.PublicKey,
	asset ids.ID,
	amount uint64,
	create bool,
) error

func AddLoan

func AddLoan(
	ctx context.Context,
	mu state.Mutable,
	asset ids.ID,
	destination ids.ID,
	amount uint64,
) error

func AssetKey added in v0.3.0

func AssetKey(asset ids.ID) (k []byte)

[assetPrefix] + [address]

func BalanceKey added in v0.3.0

func BalanceKey(pk ed25519.PublicKey, asset ids.ID) (k []byte)

[accountPrefix] + [address] + [asset]

func DeleteAsset

func DeleteAsset(ctx context.Context, mu state.Mutable, asset ids.ID) error

func DeleteBalance

func DeleteBalance(
	ctx context.Context,
	mu state.Mutable,
	pk ed25519.PublicKey,
	asset ids.ID,
) error

func DeleteOrder

func DeleteOrder(ctx context.Context, mu state.Mutable, order ids.ID) error

func FeeKey added in v0.3.0

func FeeKey() (k []byte)

func GetAsset

func GetAsset(
	ctx context.Context,
	im state.Immutable,
	asset ids.ID,
) (bool, []byte, uint8, []byte, uint64, ed25519.PublicKey, bool, error)

func GetAssetFromState

func GetAssetFromState(
	ctx context.Context,
	f ReadState,
	asset ids.ID,
) (bool, []byte, uint8, []byte, uint64, ed25519.PublicKey, bool, error)

Used to serve RPC queries

func GetBalance

func GetBalance(
	ctx context.Context,
	im state.Immutable,
	pk ed25519.PublicKey,
	asset ids.ID,
) (uint64, error)

If locked is 0, then account does not exist

func GetBalanceFromState

func GetBalanceFromState(
	ctx context.Context,
	f ReadState,
	pk ed25519.PublicKey,
	asset ids.ID,
) (uint64, error)

Used to serve RPC queries

func GetLoan

func GetLoan(
	ctx context.Context,
	im state.Immutable,
	asset ids.ID,
	destination ids.ID,
) (uint64, error)

func GetLoanFromState

func GetLoanFromState(
	ctx context.Context,
	f ReadState,
	asset ids.ID,
	destination ids.ID,
) (uint64, error)

Used to serve RPC queries

func GetOrder

func GetOrder(
	ctx context.Context,
	im state.Immutable,
	order ids.ID,
) (
	bool,
	ids.ID,
	uint64,
	ids.ID,
	uint64,
	uint64,
	ed25519.PublicKey,
	error,
)

func GetOrderFromState added in v0.3.0

func GetOrderFromState(
	ctx context.Context,
	f ReadState,
	order ids.ID,
) (
	bool,
	ids.ID,
	uint64,
	ids.ID,
	uint64,
	uint64,
	ed25519.PublicKey,
	error,
)

Used to serve RPC queries

func HeightKey

func HeightKey() (k []byte)

func IncomingWarpKeyPrefix

func IncomingWarpKeyPrefix(sourceChainID ids.ID, msgID ids.ID) (k []byte)

func LoanKey added in v0.3.0

func LoanKey(asset ids.ID, destination ids.ID) (k []byte)

[loanPrefix] + [asset] + [destination]

func OrderKey added in v0.3.0

func OrderKey(txID ids.ID) (k []byte)

[orderPrefix] + [txID]

func OutgoingWarpKeyPrefix

func OutgoingWarpKeyPrefix(txID ids.ID) (k []byte)

func PrefixBlockKey added in v0.3.0

func PrefixBlockKey(block ids.ID, parent ids.ID) (k []byte)

func SetAsset

func SetAsset(
	ctx context.Context,
	mu state.Mutable,
	asset ids.ID,
	symbol []byte,
	decimals uint8,
	metadata []byte,
	supply uint64,
	owner ed25519.PublicKey,
	warp bool,
) error

func SetBalance

func SetBalance(
	ctx context.Context,
	mu state.Mutable,
	pk ed25519.PublicKey,
	asset ids.ID,
	balance uint64,
) error

func SetLoan

func SetLoan(
	ctx context.Context,
	mu state.Mutable,
	asset ids.ID,
	destination ids.ID,
	amount uint64,
) error

func SetOrder

func SetOrder(
	ctx context.Context,
	mu state.Mutable,
	txID ids.ID,
	in ids.ID,
	inTick uint64,
	out ids.ID,
	outTick uint64,
	supply uint64,
	owner ed25519.PublicKey,
) error

func StoreTransaction

func StoreTransaction(
	_ context.Context,
	db database.KeyValueWriter,
	id ids.ID,
	t int64,
	success bool,
	units chain.Dimensions,
	fee uint64,
) error

func SubBalance

func SubBalance(
	ctx context.Context,
	mu state.Mutable,
	pk ed25519.PublicKey,
	asset ids.ID,
	amount uint64,
) error

func SubLoan

func SubLoan(
	ctx context.Context,
	mu state.Mutable,
	asset ids.ID,
	destination ids.ID,
	amount uint64,
) error

func TimestampKey added in v0.3.0

func TimestampKey() (k []byte)

func TxKey added in v0.3.0

func TxKey(id ids.ID) (k []byte)

[txPrefix] + [txID]

Types

type ReadState

type ReadState func(context.Context, [][]byte) ([][]byte, []error)

Jump to

Keyboard shortcuts

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