types

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinPeers                  = 1
	MaxPeers                  = 250
	MinMonikerLength          = 4
	MaxMonikerLength          = 32
	MinIntervalSetSessions    = 10 * time.Second
	MaxIntervalSetSessions    = 10 * time.Minute
	MinIntervalUpdateSessions = (2 * time.Hour) / 2
	MaxIntervalUpdateSessions = (2 * time.Hour) - (5 * time.Minute)
	MinIntervalUpdateStatus   = (1 * time.Hour) / 2
	MaxIntervalUpdateStatus   = (1 * time.Hour) - (5 * time.Minute)
)
View Source
const (
	ConfigFileName   = "config.toml"
	DatabaseFileName = "data.db"
	IPv4CIDR         = "10.8.0.2/24"
	IPv6CIDR         = "fd86:ea04:1115::2/120"
	KeyringName      = "sentinel"
)
View Source
const (
	FlagForce = "force"
)

Variables

View Source
var (
	DefaultHomeDirectory = func() string {
		home, err := os.UserHomeDir()
		if err != nil {
			panic(err)
		}

		return filepath.Join(home, ".sentinelnode")
	}()
)

Functions

This section is empty.

Types

type ChainConfig

type ChainConfig struct {
	GasAdjustment      float64 `json:"gas_adjustment" mapstructure:"gas_adjustment"`
	GasPrices          string  `json:"gas_prices" mapstructure:"gas_prices"`
	Gas                uint64  `json:"gas" mapstructure:"gas"`
	ID                 string  `json:"id" mapstructure:"id"`
	RPCAddress         string  `json:"rpc_address" mapstructure:"rpc_address"`
	SimulateAndExecute bool    `json:"simulate_and_execute" mapstructure:"simulate_and_execute"`
}

func NewChainConfig

func NewChainConfig() *ChainConfig

func (*ChainConfig) Validate

func (c *ChainConfig) Validate() error

func (*ChainConfig) WithDefaultValues

func (c *ChainConfig) WithDefaultValues() *ChainConfig

type Config

type Config struct {
	Chain     *ChainConfig     `json:"chain" mapstructure:"chain"`
	Handshake *HandshakeConfig `json:"handshake" mapstructure:"handshake"`
	Keyring   *KeyringConfig   `json:"keyring" mapstructure:"keyring"`
	Node      *NodeConfig      `json:"node" mapstructure:"node"`
	QOS       *QOSConfig       `json:"qos" mapstructure:"qos"`
}

func NewConfig

func NewConfig() *Config

func ReadInConfig

func ReadInConfig(v *viper.Viper) (*Config, error)

func (*Config) SaveToPath

func (c *Config) SaveToPath(path string) error

func (*Config) String

func (c *Config) String() string

func (*Config) Validate

func (c *Config) Validate() error

func (*Config) WithDefaultValues

func (c *Config) WithDefaultValues() *Config

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Module  string `json:"module,omitempty"`
}

func NewError

func NewError(module string, code int, message string) *Error

type GeoIPLocation

type GeoIPLocation struct {
	City      string  `json:"city"`
	Country   string  `json:"country"`
	IP        string  `json:"ip"`
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

type HandshakeConfig

type HandshakeConfig struct {
	Enable bool   `json:"enable" mapstructure:"enable"`
	Peers  uint64 `json:"peers" mapstructure:"peers"`
}

func NewHandshakeConfig

func NewHandshakeConfig() *HandshakeConfig

func (*HandshakeConfig) Validate

func (c *HandshakeConfig) Validate() error

func (*HandshakeConfig) WithDefaultValues

func (c *HandshakeConfig) WithDefaultValues() *HandshakeConfig

type KeyringConfig

type KeyringConfig struct {
	Backend string `json:"backend" mapstructure:"backend"`
	From    string `json:"from" mapstructure:"from"`
}

func NewKeyringConfig

func NewKeyringConfig() *KeyringConfig

func (*KeyringConfig) Validate

func (c *KeyringConfig) Validate() error

func (*KeyringConfig) WithDefaultValues

func (c *KeyringConfig) WithDefaultValues() *KeyringConfig

type NodeConfig

type NodeConfig struct {
	IntervalSetSessions    time.Duration `json:"interval_set_sessions" mapstructure:"interval_set_sessions"`
	IntervalUpdateSessions time.Duration `json:"interval_update_sessions" mapstructure:"interval_update_sessions"`
	IntervalUpdateStatus   time.Duration `json:"interval_update_status" mapstructure:"interval_update_status"`
	ListenOn               string        `json:"listen_on" mapstructure:"listen_on"`
	Moniker                string        `json:"moniker" mapstructure:"moniker"`
	Price                  string        `json:"price" mapstructure:"price"`
	Provider               string        `json:"provider" mapstructure:"provider"`
	RemoteURL              string        `json:"remote_url" mapstructure:"remote_url"`
}

func NewNodeConfig

func NewNodeConfig() *NodeConfig

func (*NodeConfig) Validate

func (c *NodeConfig) Validate() error

func (*NodeConfig) WithDefaultValues

func (c *NodeConfig) WithDefaultValues() *NodeConfig

type Peer

type Peer struct {
	Key      string `json:"key"`
	Upload   int64  `json:"upload"`
	Download int64  `json:"download"`
}

type QOSConfig added in v0.2.1

type QOSConfig struct {
	MaxPeers int `json:"max_peers" mapstructure:"max_peers"`
}

func NewQOSConfig added in v0.2.1

func NewQOSConfig() *QOSConfig

func (*QOSConfig) Validate added in v0.2.1

func (c *QOSConfig) Validate() error

func (*QOSConfig) WithDefaultValues added in v0.2.1

func (c *QOSConfig) WithDefaultValues() *QOSConfig

type Response

type Response struct {
	Success bool        `json:"success"`
	Error   *Error      `json:"error,omitempty"`
	Result  interface{} `json:"result,omitempty"`
}

type Service

type Service interface {
	Type() uint64
	Info() []byte
	Init(home string) error
	Start() error
	Stop() error
	AddPeer(data []byte) ([]byte, error)
	RemovePeer(data []byte) error
	Peers() ([]Peer, error)
	PeersCount() int
}

type Session

type Session struct {
	*gorm.Model
	ID           uint64 `gorm:"primaryKey;uniqueIndex:idx_sessions_id"`
	Subscription uint64 `gorm:"index:idx_sessions_subscription_for_address"`
	Key          string `gorm:"uniqueIndex:idx_sessions_key"`
	Address      string `gorm:"index:idx_sessions_address;index:idx_sessions_subscription_for_address"`
	Available    int64
	Download     int64
	Upload       int64
}

func (*Session) GetAddress added in v0.2.0

func (s *Session) GetAddress() sdk.AccAddress

Jump to

Keyboard shortcuts

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