app

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathParamErrorCode = 20001
	FormParamErrorCode = 20002
)
View Source
const (
	ResponseStateSuccess = "success"
	ResponseStateError   = "error"
)

Variables

View Source
var (
	ErrUnexpected = NewError(10000, "unexpected error")

	ErrBlockchainNotSynchronized = NewError(10001, "blockchain is not synchronized")

	ErrMempoolFull                    = NewError(11001, core.ErrMempoolFull.Error())
	ErrBlockNotFound                  = NewError(11002, core.ErrBlockNotFound.Error())
	ErrEmptyBlock                     = NewError(11003, core.ErrEmptyBlock.Error())
	ErrTxNotFound                     = NewError(11004, core.ErrTxNotFound.Error())
	ErrInvalidTxSignature             = NewError(11005, core.ErrInvalidTxSignature.Error())
	ErrInvalidTxConfirmationSignature = NewError(11006, core.ErrInvalidTxConfirmationSignature.Error())
	ErrInvalidTxBalance               = NewError(11007, core.ErrInvalidTxBalance.Error())
	ErrTxInNotFound                   = NewError(11008, core.ErrTxInNotFound.Error())
	ErrInvalidTxIn                    = NewError(11009, core.ErrInvalidTxIn.Error())
	ErrNullTxInConfirmation           = NewError(11010, core.ErrNullTxInConfirmation.Error())
	ErrTxOutNotFound                  = NewError(11011, core.ErrTxOutNotFound.Error())
	ErrTxOutAlreadySpent              = NewError(11012, core.ErrTxOutAlreadySpent.Error())
	ErrTxOutAlreadyExited             = NewError(11013, core.ErrTxOutAlreadyExited.Error())
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Port      int                  `json:"port"`
	DB        DBConfig             `json:"db"`
	Operator  OperatorConfig       `json:"operator"`
	RootChain core.RootChainConfig `json:"rootchain"`
	Heartbeat HeartbeatConfig      `json:"heartbeat"`
}

type Context

type Context struct {
	echo.Context
}

func NewContext

func NewContext(c echo.Context) *Context

func (*Context) GetAddressFromPath

func (c *Context) GetAddressFromPath() (common.Address, error)

func (*Context) GetAmountFromForm added in v0.3.0

func (c *Context) GetAmountFromForm() (*big.Int, error)

func (*Context) GetBlockNumberFromPath

func (c *Context) GetBlockNumberFromPath() (uint64, error)

func (*Context) GetConfirmationSignatureFromForm

func (c *Context) GetConfirmationSignatureFromForm() (types.Signature, error)

func (*Context) GetExitedFromForm added in v0.4.0

func (c *Context) GetExitedFromForm() (bool, error)

func (*Context) GetOwnerAddressFromForm added in v0.3.0

func (c *Context) GetOwnerAddressFromForm() (common.Address, error)

func (*Context) GetTxFromForm

func (c *Context) GetTxFromForm() (*types.Tx, error)

func (*Context) GetTxInPositionFromPath

func (c *Context) GetTxInPositionFromPath() (types.Position, error)

func (*Context) GetTxOutPositionFromPath added in v0.4.0

func (c *Context) GetTxOutPositionFromPath() (types.Position, error)

func (*Context) GetTxPositionFromPath

func (c *Context) GetTxPositionFromPath() (types.Position, error)

func (*Context) JSONError

func (c *Context) JSONError(err error) error

func (*Context) JSONSuccess

func (c *Context) JSONSuccess(result interface{}) error

type DB

type DB struct {
	*badger.DB
}

func NewDB

func NewDB(conf DBConfig) (*DB, error)

type DBConfig

type DBConfig struct {
	Dir string `json:"dir"`
}

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func NewError

func NewError(code int, msg string) *Error

func NewInvalidFormParamError

func NewInvalidFormParamError(key string) *Error

func NewInvalidPathParamError

func NewInvalidPathParamError(key string) *Error

func NewRequiredFormParamError

func NewRequiredFormParamError(key string) *Error

func (*Error) Error

func (err *Error) Error() string

type HandlerFunc

type HandlerFunc func(*Context) error

type HeartbeatConfig added in v0.3.0

type HeartbeatConfig struct {
	IsEnabled   bool `json:"enabled"`
	IntervalInt int  `json:"interval"`
}

func (HeartbeatConfig) Interval added in v0.3.0

func (conf HeartbeatConfig) Interval() (time.Duration, error)

type Heartbeater added in v0.3.0

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

func NewHeartbeater added in v0.3.0

func NewHeartbeater(beatFunc func() error) (*Heartbeater, error)

func (*Heartbeater) Beat added in v0.3.0

func (h *Heartbeater) Beat() (bool, error)

func (*Heartbeater) Stop added in v0.3.0

func (h *Heartbeater) Stop()

type OperatorConfig

type OperatorConfig struct {
	PrivateKeyStr string `json:"privkey"`
}

func (OperatorConfig) PrivateKey

func (conf OperatorConfig) PrivateKey() (*ecdsa.PrivateKey, error)

type Plasma

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

func NewPlasma

func NewPlasma(conf Config) (*Plasma, error)

func (*Plasma) Add

func (p *Plasma) Add(method, path string, h HandlerFunc, m ...echo.MiddlewareFunc)

func (*Plasma) Finalize

func (p *Plasma) Finalize()

func (*Plasma) GET

func (p *Plasma) GET(path string, h HandlerFunc, m ...echo.MiddlewareFunc)

func (*Plasma) GetAddressUTXOsHandler

func (p *Plasma) GetAddressUTXOsHandler(c *Context) error

func (*Plasma) GetBlockHandler

func (p *Plasma) GetBlockHandler(c *Context) error

func (*Plasma) GetTxHandler

func (p *Plasma) GetTxHandler(c *Context) error

func (*Plasma) GetTxProofHandler

func (p *Plasma) GetTxProofHandler(c *Context) error

func (*Plasma) Logger

func (p *Plasma) Logger() echo.Logger

func (*Plasma) POST

func (p *Plasma) POST(path string, h HandlerFunc, m ...echo.MiddlewareFunc)

func (*Plasma) PUT

func (p *Plasma) PUT(path string, h HandlerFunc, m ...echo.MiddlewareFunc)

func (*Plasma) PingHandler

func (p *Plasma) PingHandler(c *Context) error

func (*Plasma) PostBlockHandler

func (p *Plasma) PostBlockHandler(c *Context) error

TODO: can be executed by only the operator

func (*Plasma) PostDepositHandler added in v0.3.0

func (p *Plasma) PostDepositHandler(c *Context) error

TODO: can be executed by only the operator

func (*Plasma) PostTxHandler

func (p *Plasma) PostTxHandler(c *Context) error

func (*Plasma) PutTxInHandler

func (p *Plasma) PutTxInHandler(c *Context) error

func (*Plasma) PutTxOutHandler added in v0.4.0

func (p *Plasma) PutTxOutHandler(c *Context) error

TODO: can be executed by only the operator

func (*Plasma) Shutdown

func (p *Plasma) Shutdown(ctx context.Context) error

func (*Plasma) Start

func (p *Plasma) Start() error

type Response

type Response struct {
	State  string      `json:"state"`
	Result interface{} `json:"result"`
}

func NewErrorResponse

func NewErrorResponse(err *Error) *Response

func NewSuccessResponse

func NewSuccessResponse(result interface{}) *Response

Jump to

Keyboard shortcuts

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