transfer

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const StatusOptionFilterName = "excludeStatus"

Variables

View Source
var (
	ErrBadRequest        = errors.New("bad request")
	ErrInvalidStatusCode = errors.New("invalid status code")
	ErrBadChannel        = errors.New("channel not in configuration list")
	ErrPubKey            = errors.New("public key of the signer of the request undefined")
	ErrNonce             = errors.New("nonce undefined")
	ErrChaincode         = errors.New("chaincode undefined")
	ErrMethod            = errors.New("method name undefined")
	ErrUnknownMethod     = errors.New("unknown method name")
	ErrSign              = errors.New("sign undefined")
)

Errors related to request processing.

Functions

func BlockToRequest

func BlockToRequest(block model.TransferBlock) (request model.TransferRequest)

func Execute

func Execute(
	ctx context.Context,
	group *errgroup.Group,
	cfg *config.ListenAPI,
	channels []string,
	output chan model.TransferRequest,
	storage *redis.Storage,
	grpcMetrics *grpcprom.ServerMetrics,
) error

Execute - Run grpc and http server

func LedgerBlockToTransferBlock

func LedgerBlockToTransferBlock(channel string, block model.BlockData) map[model.ID]*model.TransferBlock

Types

type APIServer

type APIServer struct {
	dto.UnimplementedAPIServer
	// contains filtered or unexported fields
}

APIServer implements the logic for processing user requests and serves as the application server layer for working with the business logic of the app.

func NewAPIServer

func NewAPIServer(ctx context.Context, output chan<- model.TransferRequest, ctrl RequestController, actualChannels []string) *APIServer

NewAPIServer creates a new instance of the structure with the specified controller.

func (*APIServer) TransferByAdmin

func (api *APIServer) TransferByAdmin(
	ctx context.Context,
	req *dto.TransferBeginAdminRequest,
) (*dto.TransferStatusResponse, error)

TransferByAdmin registers a new transfer from one channel to another on behalf of the contract administrator, using business logic and maps the result to DTO request objects.

func (*APIServer) TransferByCustomer

func (api *APIServer) TransferByCustomer(
	ctx context.Context,
	req *dto.TransferBeginCustomerRequest,
) (*dto.TransferStatusResponse, error)

TransferByCustomer registers a new transfer from one channel to another on behalf of the contract administrator, using business logic and maps the result to DTO request objects.

func (*APIServer) TransferStatus

func (api *APIServer) TransferStatus(
	ctx context.Context,
	req *dto.TransferStatusRequest,
) (*dto.TransferStatusResponse, error)

TransferStatus returns the current status of the transfer. It requests the status from the business logic and maps it to DTO request objects.

type BlockCheckpoint

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

func NewBlockCheckpoint

func NewBlockCheckpoint(storage *redis.Storage) *BlockCheckpoint

func (*BlockCheckpoint) CheckpointLoad

func (ckp *BlockCheckpoint) CheckpointLoad(ctx context.Context, id model.ID) (model.Checkpoint, error)

func (*BlockCheckpoint) CheckpointSave

func (ckp *BlockCheckpoint) CheckpointSave(ctx context.Context, checkpoint model.Checkpoint) (model.Checkpoint, error)

type BlockController

type BlockController interface {
	// BlockSave storages the block of ledger data.
	BlockSave(context.Context, model.TransferBlock) error

	// BlockLoad retrieves the block of ledger data.
	BlockLoad(context.Context, model.ID) (model.TransferBlock, error)
}

type CheckpointController

type CheckpointController interface {
	// CheckpointSave saves the checkpoint of the processed data of the ledger channel.
	CheckpointSave(context.Context, model.Checkpoint) (model.Checkpoint, error)

	// CheckpointLoad retrieves the checkpoint of the processed data of the ledger channel.
	CheckpointLoad(context.Context, model.ID) (model.Checkpoint, error)
}

type LedgerBlock

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

func NewLedgerBlock

func NewLedgerBlock(storage *redis.Storage) *LedgerBlock

func (*LedgerBlock) BlockLoad

func (lb *LedgerBlock) BlockLoad(ctx context.Context, id model.ID) (model.TransferBlock, error)

func (*LedgerBlock) BlockSave

func (lb *LedgerBlock) BlockSave(ctx context.Context, transferBlock model.TransferBlock, ttl time.Duration) error

func (*LedgerBlock) Key

func (lb *LedgerBlock) Key(channel model.ID, transfer model.ID) model.ID

type Request

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

func NewRequest

func NewRequest(storage *redis.Storage) *Request

func (*Request) IsChangeableStatus

func (r *Request) IsChangeableStatus(status string) bool

func (*Request) Registry

func (r *Request) Registry(ctx context.Context) ([]*model.TransferRequest, error)

func (*Request) TransferFetch

func (r *Request) TransferFetch(ctx context.Context, transfer model.ID) (model.TransferRequest, error)

func (*Request) TransferKeep

func (r *Request) TransferKeep(ctx context.Context, transferRequest model.TransferRequest) error

func (*Request) TransferModify

func (r *Request) TransferModify(ctx context.Context, transferRequest model.TransferRequest, ttl time.Duration) error

func (*Request) TransferResultModify

func (r *Request) TransferResultModify(ctx context.Context, transferID model.ID, result model.TransferResult) error

type RequestController

type RequestController interface {
	// TransferKeep storage a request to transfer funds from one channel to
	// another.
	TransferKeep(context.Context, model.TransferRequest) error

	// TransferFetch retrieves the transfer by ID with updated status and the
	// result of processing the transfer request.
	TransferFetch(context.Context, model.ID) (model.TransferRequest, error)
}

RequestController is responsible for implementing the processing of user and administrator requests to perform transfer operations from one channel to another.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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