model

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTransferNotFound = errors.New("transfer not found")
	ErrUnknown          = errors.New("unknown error")
)

Standardized errors for working with business logic.

Functions

This section is empty.

Types

type BlockData

type BlockData struct {
	BlockNum uint64
	Txs      []Transaction
}

func (*BlockData) IsEmpty

func (d *BlockData) IsEmpty() bool

func (*BlockData) ItemsCount

func (d *BlockData) ItemsCount() uint

type Checkpoint

type Checkpoint struct {
	Channel                 ID
	Ver                     int64
	SrcCollectFromBlockNums uint64
}

func (*Checkpoint) Clone

func (cp *Checkpoint) Clone() data.Object

func (*Checkpoint) Instance

func (cp *Checkpoint) Instance() data.Type

func (*Checkpoint) MarshalBinary

func (cp *Checkpoint) MarshalBinary() (data []byte, err error)

func (*Checkpoint) UnmarshalBinary

func (cp *Checkpoint) UnmarshalBinary(data []byte) error

type CompositeKeysPrefixes

type CompositeKeysPrefixes struct {
	BatchPrefix string
}

type ID

type ID string

ID is defined as a separate data type for requests to get the status by ID.

type StatusKind

type StatusKind int
const (
	InProgressTransferFrom StatusKind = iota
	ErrorTransferFrom
	CompletedTransferFrom
	FromBatchNotFound

	InProgressTransferTo
	ErrorTransferTo
	CompletedTransferTo
	ToBatchNotFound

	CommitTransferFrom

	InProgressTransferToDelete
	CompletedTransferToDelete
	ErrorTransferToDelete

	InProgressTransferFromDelete
	CompletedTransferFromDelete
	ErrorTransferFromDelete

	Canceled
	Completed
	UnknownTransferStatus

	InternalErrorTransferStatus
	ErrorChannelToNotFound
	ExistsChannelTo
)

func (StatusKind) Is

func (sk StatusKind) Is(status string) bool

func (StatusKind) String

func (sk StatusKind) String() string

type Transaction

type Transaction struct {
	Channel        string
	BlockNum       uint64
	TxID           string
	FuncName       string
	Args           [][]byte
	TimeNs         uint64
	ValidationCode int32
	BatchResponse  *proto.TxResponse
	Response       *peer.Response
}

type TransactionKind

type TransactionKind int
const (
	TxCancelCCTransferFrom TransactionKind = iota
	TxChannelTransferByAdmin
	TxChannelTransferByCustomer
	TxCreateCCTransferTo
	NbTxCommitCCTransferFrom
	NbTxDeleteCCTransferFrom
	NbTxDeleteCCTransferTo
	QueryChannelTransfersFrom
	QueryChannelTransferTo
	QueryChannelTransferFrom
	TxChannelMultiTransferByAdmin
	TxChannelMultiTransferByCustomer
)

func (TransactionKind) Is

func (tk TransactionKind) Is(method string) bool

func (TransactionKind) String

func (tk TransactionKind) String() string

type TransferBlock

type TransferBlock struct {
	Channel      ID
	Transfer     ID
	Transactions []Transaction
}

func (*TransferBlock) Clone

func (tb *TransferBlock) Clone() data.Object

func (*TransferBlock) Instance

func (tb *TransferBlock) Instance() data.Type

func (*TransferBlock) MarshalBinary

func (tb *TransferBlock) MarshalBinary() (data []byte, err error)

func (*TransferBlock) UnmarshalBinary

func (tb *TransferBlock) UnmarshalBinary(data []byte) error

type TransferItem added in v0.0.5

type TransferItem struct {
	Token  string `json:"token"`
	Amount string `json:"amount"`
}

type TransferRequest

type TransferRequest struct {
	TransferResult

	Request   ID
	Transfer  ID
	User      ID
	Method    string
	Chaincode string
	Channel   string
	Nonce     string
	PublicKey string
	Sign      string
	To        string
	Token     string
	Amount    string
	Items     []TransferItem
}

TransferRequest contains the internal representation of a request to transfer funds from one channel to another. This structure is filled from the request and enters the queue for processing.

func (*TransferRequest) Clone

func (tr *TransferRequest) Clone() data.Object

Clone should create an exact copy of the object, located in a different memory location from the original. This is necessary in case of cache optimization to avoid marshalling the object in some cases. Clone is also used as a template for finding an object in the repository.

func (*TransferRequest) Instance

func (tr *TransferRequest) Instance() data.Type

Instance should return a unique object type to share namespace between the stored data. In the simplest case, you can return the type name via InstanceOf, but keep in mind that you need to preserve compatibility or provide for migration when refactoring.

func (*TransferRequest) MarshalBinary

func (tr *TransferRequest) MarshalBinary() (data []byte, err error)

func (*TransferRequest) UnmarshalBinary

func (tr *TransferRequest) UnmarshalBinary(data []byte) error

type TransferResult

type TransferResult struct {
	Status  string
	Message string
}

TransferResult is the result of processing a request to transfer funds from one channel to another. The statuses are symmetrical to proto. TODO: Custom statuses should be added later.

Jump to

Keyboard shortcuts

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