types

package
v0.1.9 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	MinMonikerLength          = 5
	MaxMonikerLength          = 30
	MinIntervalSetSessions    = 2 * time.Minute
	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"
	FlagForce       = "force"
	KeyringName     = "sentinel"
	DefaultIPv4CIDR = "10.8.0.2/24"
	DefaultIPv6CIDR = "fd86:ea04:1115::2/120"
)

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"`
}

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 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 {
	ID          uint64         `json:"id,omitempty"`
	Key         string         `json:"key,omitempty"`
	Address     sdk.AccAddress `json:"address,omitempty"`
	Available   sdk.Int        `json:"available,omitempty"`
	Download    int64          `json:"download,omitempty"`
	Upload      int64          `json:"upload,omitempty"`
	ConnectedAt time.Time      `json:"connected_at,omitempty"`
}

func (Session) Empty added in v0.1.2

func (s Session) Empty() bool

type Sessions

type Sessions struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSessions

func NewSessions() *Sessions

func (*Sessions) DeleteByAddress added in v0.1.2

func (s *Sessions) DeleteByAddress(k sdk.AccAddress)

func (*Sessions) DeleteByKey added in v0.1.2

func (s *Sessions) DeleteByKey(k string)

func (*Sessions) GetByAddress added in v0.1.2

func (s *Sessions) GetByAddress(k sdk.AccAddress) Session

func (*Sessions) GetByKey added in v0.1.2

func (s *Sessions) GetByKey(k string) Session

func (*Sessions) Iterate added in v0.1.2

func (s *Sessions) Iterate(fn func(v Session) bool)

func (*Sessions) Len

func (s *Sessions) Len() int

func (*Sessions) Set added in v0.1.2

func (s *Sessions) Set(v Session)

func (*Sessions) Update added in v0.1.2

func (s *Sessions) Update(v Session)

Jump to

Keyboard shortcuts

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