ledgerapi

package
v0.0.0-...-270c4ab Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeKey

func MakeKey(keyParts ...string) string

MakeKey joins key parts using colon

func SplitKey

func SplitKey(key string) []string

SplitKey splits a key on colon

Types

type StateInterface

type StateInterface interface {
	// GetSplitKey return components that combine to form the key
	GetSplitKey() []string
	Serialize() ([]byte, error)
}

StateInterface interface states must implement for use in a list

type StateList

type StateList struct {
	Ctx         contractapi.TransactionContextInterface
	Name        string
	Deserialize func([]byte, StateInterface) error
}

StateList useful for managing putting data in and out of the ledger. Implementation of StateListInterface

func (*StateList) AddState

func (sl *StateList) AddState(state StateInterface) error

AddState puts state into world state

func (*StateList) GetState

func (sl *StateList) GetState(key string, state StateInterface) error

GetState returns state from world state. Unmarshalls the JSON into passed state. Key is the split key value used in Add/Update joined using a colon

func (*StateList) GetStateByPartialCompositeKey

func (sl *StateList) GetStateByPartialCompositeKey(state StateInterface, key ...string) ([]StateInterface, error)

func (*StateList) GetStateByRange

func (sl *StateList) GetStateByRange(state StateInterface, startKey, endKey string) ([]StateInterface, error)

func (*StateList) UpdateState

func (sl *StateList) UpdateState(state StateInterface) error

UpdateState puts state into world state. Same as AddState but separate as semantically different

type StateListInterface

type StateListInterface interface {
	AddState(StateInterface) error
	GetState(string, StateInterface) error
	UpdateState(StateInterface) error
	GetStateByRange(StateInterface, string, string) ([]StateInterface, error)
	GetStateByPartialCompositeKey(StateInterface, ...string) ([]StateInterface, error)
}

StateListInterface functions that a state list should have

Jump to

Keyboard shortcuts

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