storage

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrContentAlreadyExists = errors.New("content already exists")
	ErrContentMissing       = errors.New("content does not exist")
	ErrWrongOwner           = errors.New("wrong owner")
	ErrInsufficientTip      = errors.New("insufficient tip")
	ErrInvalidBalance       = errors.New("invalid balance")
)

Functions

func AddUnlockedBalance

func AddUnlockedBalance(
	ctx context.Context,
	db chain.Database,
	pk crypto.PublicKey,
	amount uint64,
	dropIfGone bool,
) (bool, error)

[dropIfGone] is used if the address is cleared out

func DeleteBalance

func DeleteBalance(ctx context.Context, db chain.Database, pk crypto.PublicKey) error

func DeletePermissions

func DeletePermissions(
	ctx context.Context,
	db chain.Database,
	actor crypto.PublicKey,
	signer crypto.PublicKey,
) error

func GetBalance

func GetBalance(
	ctx context.Context,
	db chain.Database,
	pk crypto.PublicKey,
) (uint64, uint64, error)

If locked is 0, then account does not exist

func GetBalanceFromState

func GetBalanceFromState(
	ctx context.Context,
	f ReadState,
	pk crypto.PublicKey,
) (uint64, uint64, error)

Used to serve RPC queries

func GetContent

func GetContent(
	ctx context.Context,
	db chain.Database,
	contentID ids.ID,
) (crypto.PublicKey, uint64, bool, error)

func GetContentFromState

func GetContentFromState(
	ctx context.Context,
	f ReadState,
	contentID ids.ID,
) (crypto.PublicKey, uint64, bool, error)

func GetPermissions

func GetPermissions(
	ctx context.Context,
	db chain.Database,
	actor crypto.PublicKey,
	signer crypto.PublicKey,
) (uint8, uint8, error)

func GetTransaction

func GetTransaction(
	_ context.Context,
	db database.KeyValueReader,
	id ids.ID,
) (bool, int64, bool, uint64, error)

func IndexContent

func IndexContent(
	ctx context.Context,
	db chain.Database,
	contentID ids.ID,
	pk crypto.PublicKey,
	royalty uint64,
) error

func LockBalance

func LockBalance(ctx context.Context, db chain.Database, pk crypto.PublicKey, amount uint64) error

func PrefixBalanceKey

func PrefixBalanceKey(pk crypto.PublicKey) (k []byte)

[accountPrefix] + [address]

func PrefixContentKey

func PrefixContentKey(contentID ids.ID) (k []byte)

[contentPrefix] + [contentID]

func PrefixPermissionsKey

func PrefixPermissionsKey(actor crypto.PublicKey, signer crypto.PublicKey) (k []byte)

[accountPrefix] + [actor] + [signer]

func PrefixTxKey

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

[txPrefix] + [txID]

func RewardSearcher

func RewardSearcher(
	ctx context.Context,
	db chain.Database,
	contentID ids.ID,
	sender crypto.PublicKey,
) (crypto.PublicKey, error)

func SetBalance

func SetBalance(
	ctx context.Context,
	db chain.Database,
	pk crypto.PublicKey,
	unlockedBal uint64,
	lockedBal uint64,
) error

func SetContent

func SetContent(
	ctx context.Context,
	db chain.Database,
	contentID ids.ID,
	owner crypto.PublicKey,
	royalty uint64,
) error

func SetPermissions

func SetPermissions(
	ctx context.Context,
	db chain.Database,
	actor crypto.PublicKey,
	signer crypto.PublicKey,
	actionPerms uint8,
	miscPerms uint8,
) error

func StoreTransaction

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

func SubUnlockedBalance

func SubUnlockedBalance(
	ctx context.Context,
	db chain.Database,
	pk crypto.PublicKey,
	amount uint64,
) error

func UnindexContent

func UnindexContent(
	ctx context.Context,
	db chain.Database,
	contentID ids.ID,
	pk crypto.PublicKey,
) error

func UnlockBalance

func UnlockBalance(
	ctx context.Context,
	db chain.Database,
	pk crypto.PublicKey,
	amount uint64,
) error

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