node

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChainConfigFileName     = "config.json"
	ChainGenesisZipFileName = "genesis.zip"
)
View Source
const (
	UrlSystem   = "/system"
	UrlUser     = "/user"
	UrlStats    = "/stats"
	UrlChain    = "/chain"
	ParamCID    = "cid"
	UrlChainRes = "/:" + ParamCID
	ParamID     = "id"
	UrlUserRes  = "/:" + ParamID
)
View Source
const (
	AuthScheme = "goloop"
)
View Source
const (
	BaseUnixDomainSockHttpEndpoint = "http://localhost"
)
View Source
const (
	DefaultEEInstances = 1
)
View Source
const (
	RestoreDirectoryPrefix = ".restore"
)

Variables

View Source
var (
	ErrAlreadyExists = errors.New("already exists")
	ErrNotExists     = errors.New("not exists")
)

Functions

func EqualsSyscallErrno

func EqualsSyscallErrno(err error, sen syscall.Errno) bool

func FileDownload

func FileDownload(resp *http.Response) (b []byte, fileName string, err error)

func GetFileMultipart

func GetFileMultipart(ctx echo.Context, fieldname string) ([]byte, error)

func GetJsonMultipart

func GetJsonMultipart(ctx echo.Context, ptr interface{}) error

func MultipartCopy

func MultipartCopy(mw *multipart.Writer, fieldName string, r io.Reader) error

func MultipartFile

func MultipartFile(mw *multipart.Writer, fieldName, fileName string) error

func MultipartJson

func MultipartJson(mw *multipart.Writer, fieldName string, v interface{}) error

func NewRestError

func NewRestError(r *http.Response) error

func RegisterInspectFunc

func RegisterInspectFunc(name string, f InspectFunc) error

func RegisterRest

func RegisterRest(n *Node)

func ResolveAbsolute

func ResolveAbsolute(baseFile, targetPath string) string

func UrlWithParams

func UrlWithParams(reqUrl string, reqParams ...*url.Values) string

Types

type Auth

type Auth struct {
	SkipIfEmptyUsers bool
	// contains filtered or unexported fields
}

func NewAuth

func NewAuth(filePath, prefix string) *Auth

func (*Auth) AddUser

func (a *Auth) AddUser(id string) error

func (*Auth) GetUsers

func (a *Auth) GetUsers() []string

func (*Auth) IsEmptyUsers

func (a *Auth) IsEmptyUsers() bool

func (*Auth) MiddlewareFunc

func (a *Auth) MiddlewareFunc() echo.MiddlewareFunc

func (*Auth) RemoveUser

func (a *Auth) RemoveUser(id string) error

func (*Auth) SetSkip

func (a *Auth) SetSkip(r *echo.Route, skip bool)

type BackupInfo

type BackupInfo struct {
	Name string `json:"name"`
	Size int64  `json:"size"`
	chain.BackupInfo
}

type Chain

type Chain struct {
	module.Chain
	// contains filtered or unexported fields
}

type ChainConfig

type ChainConfig struct {
	DBType           string `json:"dbType"`
	Platform         string `json:"platform"`
	SeedAddr         string `json:"seedAddress"`
	Role             uint   `json:"role"`
	ConcurrencyLevel int    `json:"concurrencyLevel,omitempty"`
	NormalTxPoolSize int    `json:"normalTxPool,omitempty"`
	PatchTxPoolSize  int    `json:"patchTxPool,omitempty"`
	MaxBlockTxBytes  int    `json:"maxBlockTxBytes,omitempty"`
	NodeCache        string `json:"nodeCache,omitempty"`
	Channel          string `json:"channel"`
	SecureSuites     string `json:"secureSuites"`
	SecureAeads      string `json:"secureAeads"`
	DefWaitTimeout   int64  `json:"defaultWaitTimeout"`
	MaxWaitTimeout   int64  `json:"maxWaitTimeout"`
	TxTimeout        int64  `json:"txTimeout"`
	AutoStart        bool   `json:"autoStart"`
}

func NewChainConfig

func NewChainConfig(cfg *chain.Config) *ChainConfig

type ChainImportParam

type ChainImportParam struct {
	DBPath string `json:"dbPath"`
	Height int64  `json:"height"`
}

type ChainInspectView

type ChainInspectView struct {
	*ChainView
	GenesisTx json.RawMessage `json:"genesisTx"`
	Config    *ChainConfig    `json:"config"`
	// TODO [TBD] define structure each module for inspect
	Module map[string]interface{} `json:"module"`
}

func NewChainInspectView

func NewChainInspectView(c *Chain) *ChainInspectView

type ChainPruneParam

type ChainPruneParam struct {
	DBType string `json:"dbType,omitempty"`
	Height int64  `json:"height"`
}

type ChainView

type ChainView struct {
	CID       common.HexInt32 `json:"cid"`
	NID       common.HexInt32 `json:"nid"`
	Channel   string          `json:"channel"`
	State     string          `json:"state"`
	Height    int64           `json:"height"`
	LastError string          `json:"lastError"`
}

func NewChainView

func NewChainView(c *Chain) *ChainView

type ConfigureParam

type ConfigureParam struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type InspectFunc

type InspectFunc func(c module.Chain, informal bool) map[string]interface{}

type JsonTemplate

type JsonTemplate struct {
	*template.Template
}

func NewJsonTemplate

func NewJsonTemplate(name string) *JsonTemplate

func (*JsonTemplate) Response

func (t *JsonTemplate) Response(format string, v interface{}, resp *echo.Response) error

type Node

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

func NewNode

func NewNode(
	w module.Wallet,
	cfg *StaticConfig,
	l log.Logger,
) *Node

func (*Node) BackupChain

func (n *Node) BackupChain(cid int) (string, error)

func (*Node) CanAdd

func (n *Node) CanAdd(cid, nid int, channel string, overwrite bool) error

func (*Node) Configure

func (n *Node) Configure(key string, value string) error

func (*Node) ConfigureChain

func (n *Node) ConfigureChain(cid int, key string, value string) error

func (*Node) GetBackups

func (n *Node) GetBackups() ([]BackupInfo, error)

func (*Node) GetChain

func (n *Node) GetChain(cid int) *Chain

func (*Node) GetChainByChannel

func (n *Node) GetChainByChannel(channel string) *Chain

func (*Node) GetChainBySelector

func (n *Node) GetChainBySelector(s string) *Chain

func (*Node) GetChains

func (n *Node) GetChains() []*Chain

func (*Node) GetRestore

func (n *Node) GetRestore() *RestoreView

GetRestore returns state of latest restore operations.

func (*Node) ImportChain

func (n *Node) ImportChain(cid int, s string, height int64) error

func (*Node) JoinChain

func (n *Node) JoinChain(
	p *ChainConfig,
	genesis []byte,
) (module.Chain, error)

TODO [TBD] using JoinChainParam struct

func (*Node) LeaveChain

func (n *Node) LeaveChain(cid int) error

func (*Node) PruneChain

func (n *Node) PruneChain(cid int, dbt string, height int64) error

func (*Node) ResetChain

func (n *Node) ResetChain(cid int) error

func (*Node) Start

func (n *Node) Start()

func (*Node) StartChain

func (n *Node) StartChain(cid int) error

func (*Node) StartRestore

func (n *Node) StartRestore(name string, overwrite bool) (ret error)

StartRestore start to restore chain.

func (*Node) Stop

func (n *Node) Stop()

func (*Node) StopChain

func (n *Node) StopChain(cid int) error

func (*Node) StopRestore

func (n *Node) StopRestore() error

StopRestore stops last restore operation. If there is no ongoing restore,then it clears already finished job.

func (*Node) VerifyChain

func (n *Node) VerifyChain(cid int) error

type Rest

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

func (*Rest) AddUser

func (r *Rest) AddUser(ctx echo.Context) error

func (*Rest) BackupChain

func (r *Rest) BackupChain(ctx echo.Context) error

func (*Rest) ChainInjector

func (r *Rest) ChainInjector(next echo.HandlerFunc) echo.HandlerFunc

func (*Rest) ConfigureChain

func (r *Rest) ConfigureChain(ctx echo.Context) error

func (*Rest) ConfigureSystem

func (r *Rest) ConfigureSystem(ctx echo.Context) error

func (*Rest) GetBackups

func (r *Rest) GetBackups(ctx echo.Context) error

func (*Rest) GetChain

func (r *Rest) GetChain(ctx echo.Context) error

func (*Rest) GetChainConfig

func (r *Rest) GetChainConfig(ctx echo.Context) error

func (*Rest) GetChainGenesis

func (r *Rest) GetChainGenesis(ctx echo.Context) error

func (*Rest) GetChains

func (r *Rest) GetChains(ctx echo.Context) error

func (*Rest) GetRestore

func (r *Rest) GetRestore(ctx echo.Context) error

func (*Rest) GetSystem

func (r *Rest) GetSystem(ctx echo.Context) error

func (*Rest) GetSystemConfig

func (r *Rest) GetSystemConfig(ctx echo.Context) error

func (*Rest) ImportChain

func (r *Rest) ImportChain(ctx echo.Context) error

func (*Rest) JoinChain

func (r *Rest) JoinChain(ctx echo.Context) error

func (*Rest) LeaveChain

func (r *Rest) LeaveChain(ctx echo.Context) error

func (*Rest) PruneChain

func (r *Rest) PruneChain(ctx echo.Context) error

func (*Rest) RegisterChainHandlers

func (r *Rest) RegisterChainHandlers(g *echo.Group)

func (*Rest) RegisterStatsHandlers

func (r *Rest) RegisterStatsHandlers(g *echo.Group)

func (*Rest) RegisterSystemHandlers

func (r *Rest) RegisterSystemHandlers(g *echo.Group)

func (*Rest) RegisterUserHandlers

func (r *Rest) RegisterUserHandlers(g *echo.Group)

func (*Rest) RegistryBackupHandlers

func (r *Rest) RegistryBackupHandlers(g *echo.Group)

func (*Rest) RegistryRestoreHandlers

func (r *Rest) RegistryRestoreHandlers(g *echo.Group)

func (*Rest) RemoveUser

func (r *Rest) RemoveUser(ctx echo.Context) error

func (*Rest) ResetChain

func (r *Rest) ResetChain(ctx echo.Context) error

func (*Rest) ResponseStatsView

func (r *Rest) ResponseStatsView(resp *echo.Response) error

func (*Rest) RestoreBackup

func (r *Rest) RestoreBackup(ctx echo.Context) error

func (*Rest) StartChain

func (r *Rest) StartChain(ctx echo.Context) error

func (*Rest) StopChain

func (r *Rest) StopChain(ctx echo.Context) error

func (*Rest) StopRestore

func (r *Rest) StopRestore(ctx echo.Context) error

func (*Rest) StreamStats

func (r *Rest) StreamStats(ctx echo.Context) error

func (*Rest) Users

func (r *Rest) Users(ctx echo.Context) error

func (*Rest) VerifyChain

func (r *Rest) VerifyChain(ctx echo.Context) error

type RestError

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

func (*RestError) Error

func (e *RestError) Error() string

func (*RestError) Response

func (e *RestError) Response() string

func (*RestError) StatusCode

func (e *RestError) StatusCode() int

type RestoreBackupParam

type RestoreBackupParam struct {
	Name      string `json:"name"`
	Overwrite bool   `json:"overwrite"`
}

type RestoreManager

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

func (*RestoreManager) GetStatus

func (m *RestoreManager) GetStatus() *RestoreStatus

func (*RestoreManager) Start

func (m *RestoreManager) Start(node *Node, file string, baseDir string, overwrite bool) (ret error)

func (*RestoreManager) Stop

func (m *RestoreManager) Stop() error

type RestoreState

type RestoreState int
const (
	RestoreNone RestoreState = iota
	RestoreStarted
	RestoreFailed
	RestoreSuccess
	RestoreStopping
)

func (RestoreState) String

func (s RestoreState) String() string

type RestoreStatus

type RestoreStatus struct {
	File      string
	Overwrite bool
	State     string
	Error     error
}

type RestoreView

type RestoreView struct {
	State     string `json:"state"`
	Name      string `json:"name,omitempty"`
	Overwrite bool   `json:"overwrite,omitempty"`
	Error     string `json:"error,omitempty"`
}

type RuntimeConfig

type RuntimeConfig struct {
	EEInstances       int    `json:"eeInstances"`
	RPCDefaultChannel string `json:"rpcDefaultChannel"`
	RPCIncludeDebug   bool   `json:"rpcIncludeDebug"`

	FilePath string `json:"-"` // absolute path
}

type StaticConfig

type StaticConfig struct {
	// static
	CliSocket     string `json:"node_sock"` // relative path
	P2PAddr       string `json:"p2p"`
	P2PListenAddr string `json:"p2p_listen"`
	RPCAddr       string `json:"rpc_addr"`
	RPCDump       bool   `json:"rpc_dump"`
	EESocket      string `json:"ee_socket"`
	Engines       string `json:"engines"`
	BackupDir     string `json:"backup_dir"`

	AuthSkipIfEmptyUsers bool `json:"auth_skip_if_empty_users,omitempty"`
	NIDForP2P            bool `json:"nid_for_p2p,omitempty"`

	BaseDir  string `json:"node_dir"`
	FilePath string `json:"-"` // absolute path

	// build info
	BuildVersion string `json:"-"`
	BuildTags    string `json:"-"`
}

func (*StaticConfig) AbsBaseDir

func (c *StaticConfig) AbsBaseDir() string

func (*StaticConfig) FillEmpty

func (c *StaticConfig) FillEmpty(addr module.Address)

func (*StaticConfig) ResolveAbsolute

func (c *StaticConfig) ResolveAbsolute(targetPath string) string

func (*StaticConfig) ResolveRelative

func (c *StaticConfig) ResolveRelative(targetPath string) string

func (*StaticConfig) SetFilePath

func (c *StaticConfig) SetFilePath(path string) string

type StatsView

type StatsView struct {
	Chains    []map[string]interface{} `json:"chains"`
	Timestamp time.Time                `json:"timestamp"`
}

type StreamCallbackFunc

type StreamCallbackFunc func(respPtr interface{}) error

type SystemView

type SystemView struct {
	BuildVersion string `json:"buildVersion"`
	BuildTags    string `json:"buildTags"`
	Setting      struct {
		Address       string `json:"address"`
		P2PAddr       string `json:"p2p"`
		P2PListenAddr string `json:"p2pListen"`
		RPCAddr       string `json:"rpcAddr"`
		RPCDump       bool   `json:"rpcDump"`
	} `json:"setting"`
	Config interface{} `json:"config"`
}

type UnixDomainSockHttpClient

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

func NewUnixDomainSockHttpClient

func NewUnixDomainSockHttpClient(sockPath string) *UnixDomainSockHttpClient

func (*UnixDomainSockHttpClient) Delete

func (c *UnixDomainSockHttpClient) Delete(reqUrl string, respPtr interface{}) (resp *http.Response, err error)

func (*UnixDomainSockHttpClient) Do

func (c *UnixDomainSockHttpClient) Do(method, reqUrl string, reqPtr, respPtr interface{}) (resp *http.Response, err error)

func (*UnixDomainSockHttpClient) Get

func (c *UnixDomainSockHttpClient) Get(reqUrl string, respPtr interface{}, reqParams ...*url.Values) (resp *http.Response, err error)

func (*UnixDomainSockHttpClient) Post

func (c *UnixDomainSockHttpClient) Post(reqUrl string, respPtr interface{}) (resp *http.Response, err error)

func (*UnixDomainSockHttpClient) PostWithFile

func (c *UnixDomainSockHttpClient) PostWithFile(reqUrl string, reqPtr interface{}, fieldName, fileName string, respPtr interface{}) (resp *http.Response, err error)

func (*UnixDomainSockHttpClient) PostWithJson

func (c *UnixDomainSockHttpClient) PostWithJson(reqUrl string, reqPtr interface{}, respPtr interface{}) (resp *http.Response, err error)

func (*UnixDomainSockHttpClient) PostWithReader

func (c *UnixDomainSockHttpClient) PostWithReader(reqUrl string, reqPtr interface{}, fieldName string, r io.Reader, respPtr interface{}) (resp *http.Response, err error)

func (*UnixDomainSockHttpClient) Stream

func (c *UnixDomainSockHttpClient) Stream(reqUrl string, reqPtr, respPtr interface{},
	respFunc StreamCallbackFunc, cancelCh <-chan bool, reqParams ...*url.Values) (resp *http.Response, err error)

type UnixDomainSockHttpServer

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

func NewUnixDomainSockHttpServer

func NewUnixDomainSockHttpServer(sockPath string, e *echo.Echo) *UnixDomainSockHttpServer

func (*UnixDomainSockHttpServer) Start

func (s *UnixDomainSockHttpServer) Start() error

func (*UnixDomainSockHttpServer) Stop

func (s *UnixDomainSockHttpServer) Stop() error

Jump to

Keyboard shortcuts

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