server

package
v1.0.1-stable-30a703f Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2019 License: GPL-3.0 Imports: 27 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHandlerIsShuttingDown = fmt.Errorf("Http handler is shutting down")
View Source
var ErrReceiverIsShuttingDown = errors.New("receiver is shutting down")

Functions

func NewService

func NewService(cap int, receiver *Receiver) tau.Task

Types

type AcceptRequest

type AcceptRequest struct {
}

func (AcceptRequest) IsMessage

func (req AcceptRequest) IsMessage()

type AcceptedRequest

type AcceptedRequest struct {
	Message tau.Message
}

func NewAcceptedRequest

func NewAcceptedRequest(msg tau.Message) AcceptedRequest

func (AcceptedRequest) IsMessage

func (req AcceptedRequest) IsMessage()

type GetAddressResponse

type GetAddressResponse string

type GetAddressesResponse

type GetAddressesResponse map[tokens.Name]string

type GetBalanceResponse

type GetBalanceResponse blockchain.Balance

type GetBalancesResponse

type GetBalancesResponse map[tokens.Name]blockchain.Balance

type GetInfoResponse

type GetInfoResponse struct {
	Version         string         `json:"version"`
	Bootloaded      bool           `json:"bootloaded"`
	SupportedTokens []tokens.Token `json:"supportedTokens"`
}

type GetSignatureResponseJSON

type GetSignatureResponseJSON struct {
	Message   json.RawMessage `json:"message"`
	Signature string          `json:"signature"`
}

type GetSignatureResponseString

type GetSignatureResponseString struct {
	Message   string `json:"message"`
	Signature string `json:"signature"`
}

type GetSwapResponse

type GetSwapResponse swap.SwapReceipt

type GetSwapsResponse

type GetSwapsResponse struct {
	Swaps []swap.SwapReceipt `json:"swaps"`
}

type GetTransfersResponse

type GetTransfersResponse struct {
	Transfers []transfer.TransferReceipt `json:"transfers"`
}

func MarshalGetTransfersResponse

func MarshalGetTransfersResponse(receiptMap transfer.TransferReceiptMap) GetTransfersResponse

type Handler

type Handler interface {
	GetID(password string, idType string) (string, error)
	GetInfo(password string) GetInfoResponse
	GetSwap(password string, id swap.SwapID) (GetSwapResponse, error)
	GetSwaps(password string) (GetSwapsResponse, error)
	GetBalances(password string) (GetBalancesResponse, error)
	GetBalance(password string, token tokens.Token) (GetBalanceResponse, error)
	GetAddresses(password string) (GetAddressesResponse, error)
	GetAddress(password string, token tokens.Token) (GetAddressResponse, error)
	GetTransfers(password string) (GetTransfersResponse, error)
	GetJSONSignature(password string, message json.RawMessage) (GetSignatureResponseJSON, error)
	GetBase64Signature(password string, message string) (GetSignatureResponseString, error)
	GetHexSignature(password string, message string) (GetSignatureResponseString, error)
	PostTransfers(PostTransfersRequest) error
	PostSwaps(PostSwapRequest) (PostSwapResponse, error)
	PostDelayedSwaps(PostSwapRequest) error
	Shutdown()
}

The Handler for swapperd requests

func NewHandler

func NewHandler(cap int, version string, wallet wallet.Wallet, storage Storage, receiver *Receiver) Handler

type PostRedeemSwapResponse

type PostRedeemSwapResponse struct {
	ID swap.SwapID `json:"id"`
}

type PostSwapRequest

type PostSwapRequest swap.SwapBlob

type PostSwapResponse

type PostSwapResponse struct {
	ID        swap.SwapID   `json:"id"`
	Swap      swap.SwapBlob `json:"swap,omitempty"`
	Signature string        `json:"signature,omitempty"`
}

type PostTransfersRequest

type PostTransfersRequest struct {
	Token    string                      `json:"token"`
	To       string                      `json:"to"`
	Amount   string                      `json:"amount"`
	Speed    blockchain.TxExecutionSpeed `json:"speed"`
	SendAll  bool                        `json:"sendAll"`
	Password string                      `json:"password"`
}

type PostTransfersResponse

type PostTransfersResponse transfer.TransferReceipt

type Receiver

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

func NewReceiver

func NewReceiver(cap int) *Receiver

func (*Receiver) Receive

func (receiver *Receiver) Receive() (tau.Message, error)

Receive blocks until a message can be read from the Receiver buffer.

func (*Receiver) Shutdown

func (receiver *Receiver) Shutdown()

Shutdown shuts down the receiver, by closing the done channel.

func (*Receiver) Write

func (receiver *Receiver) Write(ctx context.Context, msg tau.Message) error

Write tries to write to the buffer if the buffer is full, it waits until the context expires before returning context deadline exceeded error.

type Server

type Server interface {
	Run(doneCh <-chan struct{})
}

func NewHttpServer

func NewHttpServer(cap int, port, version string, receiver *Receiver, storage Storage, wallet wallet.Wallet, logger logrus.FieldLogger) Server

type Storage

type Storage interface {
	Receipts() ([]swap.SwapReceipt, error)
	Transfers() ([]transfer.TransferReceipt, error)
}

Jump to

Keyboard shortcuts

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