daemon

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: MIT Imports: 14 Imported by: 18

Documentation

Index

Constants

View Source
const (
	// RivineUserAgent is the user agent used by Rivine by default.
	RivineUserAgent = "Rivine-Agent"
)

Variables

View Source
var (
	GatewayModule = &Module{
		Name: "Gateway",
		Description: `The gateway maintains a peer to peer connection to the network and
enables other modules to perform RPC calls on peers.
The gateway is required by all other modules.`,
	}

	ConsensusSetModule = &Module{
		Name: "Consensus Set",
		Description: `The consensus set manages everything related to consensus and keeps the
blockchain in sync with the rest of the network.`,
		Dependencies: ForceNewIdentifierSet(
			GatewayModule.Identifier(),
		),
	}

	TransactionPoolModule = &Module{
		Name:        "Transaction Pool",
		Description: `The transaction pool manages unconfirmed transactions.`,
		Dependencies: ForceNewIdentifierSet(
			ConsensusSetModule.Identifier(),
			GatewayModule.Identifier(),
		),
	}

	WalletModule = &Module{
		Name:        "Wallet",
		Description: `The wallet stores and manages coins and blockstakes.`,
		Dependencies: ForceNewIdentifierSet(
			ConsensusSetModule.Identifier(),
			TransactionPoolModule.Identifier(),
		),
	}

	BlockCreatorModule = &Module{
		Name: "Block Creator",
		Description: `The block creator participates in the proof of block stake protocol
for creating new blocks. BlockStakes are required to participate.`,
		Dependencies: ForceNewIdentifierSet(
			ConsensusSetModule.Identifier(),
			TransactionPoolModule.Identifier(),
			WalletModule.Identifier(),
		),
	}

	ExplorerModule = &Module{
		Name: "Explorer",
		Description: `The explorer provides statistics about the blockchain and can be
queried for information about specific transactions or other objects on
the blockchain.`,
		Dependencies: ForceNewIdentifierSet(
			ConsensusSetModule.Identifier(),
		),
	}
)

all modules that ship with Rivine

Functions

func IsValidModuleIdentifier added in v1.2.0

func IsValidModuleIdentifier(id ModuleIdentifier) bool

IsValidModuleIdentifier checks if a given ModuleIdentifier can be is valid, meaning it represents a lowercase alphabetical ASCII character.

func VerifyAPISecurity added in v1.2.0

func VerifyAPISecurity(cfg Config) error

VerifyAPISecurity checks that the security values are consistent with a sane, secure system.

Types

type Config

type Config struct {
	BlockchainInfo types.BlockchainInfo

	// the password required to use the http api,
	// if `AuthenticateAPI` is true, and the password is the empty string,
	// a password will be prompted when the daemon starts
	APIPassword string

	// the host:port for the HTTP API to listen on.
	// If `AllowAPIBind` is false, only localhost hosts are allowed
	APIaddr string
	// the host:port to listen for RPC calls
	RPCaddr string
	// indicates that the http API can listen on a non localhost address.
	// If this is true, then the AuthenticateAPI parameter
	// must also be true
	AllowAPIBind bool

	// indicates that the daemon should not try to connect to
	// the bootstrap nodes
	NoBootstrap bool
	// the user agent required to connect to the http api.
	RequiredUserAgent string
	// indicates if the http api is password protected
	AuthenticateAPI bool

	// indicates if profile info should be collected while
	// the daemon is running
	Profile bool
	// name of the directory to store the profile info,
	// should this be collected
	ProfileDir string
	// the parent directory where the individual module
	// directories will be created
	RootPersistentDir string

	//Verbose (debug) logging
	VerboseLogging bool

	// Optional BootstrapPeers we want to use instead of the default NetworkConfigs.
	BootstrapPeers []modules.NetAddress

	// DebugConsensusDB is an optional filepath in which json encoded
	// consensus database stats will be saved
	DebugConsensusDB string
}

Config contains all configurable variables for rivined.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default daemon configuration

func ProcessConfig added in v1.2.0

func ProcessConfig(config Config) Config

ProcessConfig checks the configuration values and performs cleanup on incorrect-but-allowed values.

func (*Config) RegisterAsFlags added in v1.2.0

func (cfg *Config) RegisterAsFlags(flagSet *pflag.FlagSet)

RegisterAsFlags registers all properties —for which it makes sense— as a flag.

type HTTPServer added in v1.2.0

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

HTTPServer creates and serves a HTTP server that offers communication using a REST API.

func NewHTTPServer added in v1.2.0

func NewHTTPServer(bindAddr string) (*HTTPServer, error)

NewHTTPServer creates a new net.http server listening on bindAddr.

func (*HTTPServer) Close added in v1.2.0

func (srv *HTTPServer) Close() error

Close closes the Server's listener, causing the HTTP server to shut down.

func (*HTTPServer) Handle added in v1.2.0

func (srv *HTTPServer) Handle(pattern string, handler http.Handler)

Handle the given pattern using the given handler.

func (*HTTPServer) Serve added in v1.2.0

func (srv *HTTPServer) Serve() error

Serve all registered endpoins as a REST API over HTTP endpoints.

type Module added in v1.2.0

type Module struct {
	// Name of the Module (required)
	Name string
	// Description of the Module (required)
	Description string
	// Dependencies of a module (optional),
	// if given, all listed dependencies have to be unqiue
	// and refernce an existing/available module.
	Dependencies ModuleIdentifierSet
}

Module is the type of a module that can be used in combination with other modules in order to form a client, whether or not as a daemon.

Module is NOT thread-safe.

func (Module) Identifier added in v1.2.0

func (m Module) Identifier() ModuleIdentifier

Identifier returns the lower-cased first letter of the module's name as its identifier.

func (Module) WriteDescription added in v1.2.0

func (m Module) WriteDescription(w io.Writer) error

WriteDescription writes a discription of the Module in a full detailed way.

type ModuleIdentifier added in v1.2.0

type ModuleIdentifier rune

ModuleIdentifier is the type used to represent a Module's identifier

type ModuleIdentifierSet added in v1.2.0

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

ModuleIdentifierSet is a string which can contain only unique and valid Module Identifiers.

ModuleIdentifierSet is NOT thread-safe.

func ForceNewIdentifierSet added in v1.2.0

func ForceNewIdentifierSet(identifiers ...ModuleIdentifier) ModuleIdentifierSet

ForceNewIdentifierSet creates an identifier set with the given unique identifiers, panicking if a given identifier is invalid or not unique.

func NewIdentifierSet added in v1.2.0

func NewIdentifierSet(identifiers ...ModuleIdentifier) (set ModuleIdentifierSet, err error)

NewIdentifierSet creates an identifier set with the given unique identifiers, returning an error if a given identifier is invalid or not unique.

func (*ModuleIdentifierSet) Append added in v1.2.0

func (set *ModuleIdentifierSet) Append(id ModuleIdentifier) error

Append appends a unique module identifier to this identifier set, returning an error in case the given identifier (byte) is not valid or not unique.

func (*ModuleIdentifierSet) AppendIfUnique added in v1.2.0

func (set *ModuleIdentifierSet) AppendIfUnique(id ModuleIdentifier) (bool, error)

AppendIfUnique appends a unique module identifier to this identifier set, returning an error in case the given identifier (byte) is not valid, and returning false if the given identifier (byte) If it is not unique.

func (ModuleIdentifierSet) Contains added in v1.2.0

func (set ModuleIdentifierSet) Contains(id ModuleIdentifier) bool

Contains returns True if the set contains the given id.

func (ModuleIdentifierSet) Difference added in v1.2.0

Difference returns the symmetric difference set of symmetric difference of this set and the other set. Symmetric difference meaning that it will return a new set containing the elements which are in this set, but not in the other set, as well as elements which are in the other set but not in this set.

func (ModuleIdentifierSet) Identifiers added in v1.2.0

func (set ModuleIdentifierSet) Identifiers() (ids []ModuleIdentifier)

Identifiers returns a copy of the internal identifier slice.

func (ModuleIdentifierSet) Len added in v1.2.0

func (set ModuleIdentifierSet) Len() int

Length returns the length of the module identifier set.

func (ModuleIdentifierSet) Less added in v1.2.0

func (set ModuleIdentifierSet) Less(i, j int) bool

Less implemenets sort.Interface.Less

func (ModuleIdentifierSet) String added in v1.2.0

func (set ModuleIdentifierSet) String() (str string)

String returns the identifier set as a string, one byte per identifier in this set.

An empty string can be returned in case the identifier set is empty.

func (ModuleIdentifierSet) Swap added in v1.2.0

func (set ModuleIdentifierSet) Swap(i, j int)

Swap implemenets sort.Interface.Swap

type ModuleSet added in v1.2.0

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

ModuleSet is the type which represents a unique set of Modules.

ModuleSet is NOT thread-safe.

func DefaultModuleSet added in v1.2.0

func DefaultModuleSet() ModuleSet

DefaultModuleSet returns the default module set, containing all the modules that ship with Rivine.

func NewModuleSet added in v1.2.0

func NewModuleSet(modules ...*Module) (set ModuleSet, err error)

NewModuleSet ensures that all given modules are valid and unique, returning them as a module set with no error if they are all valid indeed.

func (*ModuleSet) Append added in v1.2.0

func (ms *ModuleSet) Append(mod *Module) error

Append the a copy of the given module to the module set.

func (ModuleSet) CreateDependencySetFor added in v1.2.0

func (ms ModuleSet) CreateDependencySetFor(identifier ModuleIdentifier) (set ModuleIdentifierSet, err error)

CreateDependencySetFor creates a set of identifiers that the given identifier indirectly or directly references within the context of this Module set.

func (*ModuleSet) Set added in v1.2.0

func (ms *ModuleSet) Set(mod *Module)

Set a copy of the given module in the module set, overwriting an existing module if it has the same identifier as the given module.

func (ModuleSet) String added in v1.2.0

func (ms ModuleSet) String() (str string)

String returns the module set as a string, one byte per module in this set, and where each byte the identifier of that module is.

An empty string can be returned in case the module set is empty.

func (ModuleSet) ValidateIdentifierSet added in v1.2.0

func (ms ModuleSet) ValidateIdentifierSet(set ModuleIdentifierSet) error

ValidateIdentifierSet validates that all given identifiers exist within this module set, and that all dependencies of a referenced module are referenced within the given set of module identifiers.

func (ModuleSet) WriteDescription added in v1.2.0

func (ms ModuleSet) WriteDescription(w io.Writer) error

WriteDescription writes a full stringified description of all the modules in the module set.

type ModuleSetFlag added in v1.2.0

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

ModuleSetFlag can be used as a CLI flag within a Cobra-made CLI client, as a way to define a set of modules by their identifier, given a set of available modules, a default identifier set and the flag name which is used.

ModuleSetFlag is NOT thread-safe.

func DefaultModuleSetFlag added in v1.2.0

func DefaultModuleSetFlag() ModuleSetFlag

DefaultModuleSetFlag returns a new ModuleSetFlag, using the default available modules, flag names and a Rivine-defined default module set.

func NewModuleSetFlag added in v1.2.0

func NewModuleSetFlag(longFlag, shortFlag string, defaultIdentifiers ModuleIdentifierSet, availableModules ModuleSet) (flag ModuleSetFlag, err error)

NewModuleSetFlag creates a new module set flag

func (*ModuleSetFlag) AppendModuleIdentifier added in v1.2.0

func (msf *ModuleSetFlag) AppendModuleIdentifier(id ModuleIdentifier) error

AppendModuleIdentifier appends a given identifier to the registered set of identifiers

func (*ModuleSetFlag) ModuleIdentifiers added in v1.2.0

func (msf *ModuleSetFlag) ModuleIdentifiers() ModuleIdentifierSet

ModuleIdentifiers returns a copy of either the default identifier set, or if registered a copy of the set of registered identifiers.

func (*ModuleSetFlag) RegisterFlag added in v1.2.0

func (msf *ModuleSetFlag) RegisterFlag(set *pflag.FlagSet, helpCommand string)

RegisterFlag registers this ModuleSetFlag to a given flag set, optionally informing the user about a help command devoted as a manual for this flag.

func (*ModuleSetFlag) Set added in v1.2.0

func (msf *ModuleSetFlag) Set(str string) (err error)

Set resets the registered set of identifiers and tries to append each byte of the given string as a unique module identifier.

func (*ModuleSetFlag) String added in v1.2.0

func (msf *ModuleSetFlag) String() string

String returns all module identifiers, either the default ones, or the one set by the user

func (*ModuleSetFlag) Type added in v1.2.0

func (msf *ModuleSetFlag) Type() string

Type returns the flag type in string format of this flag.

func (ModuleSetFlag) WriteDescription added in v1.2.0

func (msf ModuleSetFlag) WriteDescription(w io.Writer) error

WriteDescription writes a stringified description of this flag, including a description for each available module.

type NetworkConfig

type NetworkConfig struct {
	// Blockchain Constants for this network
	Constants types.ChainConstants
	// BootstrapPeers for this network
	BootstrapPeers []modules.NetAddress
}

NetworkConfig are variables for a particular chain. Currently, these are genesis constants and bootstrap peers

func DefaultNetworkConfig added in v1.2.0

func DefaultNetworkConfig(networkName string) (NetworkConfig, error)

DefaultNetworkConfig returns the default network config based on a given network name.

type Version added in v1.2.0

type Version struct {
	ChainVersion    build.ProtocolVersion `json:"version"`
	ProtocolVersion build.ProtocolVersion `json:"protocolVersion"`
}

Version defines the version of a daemon.

Jump to

Keyboard shortcuts

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