Documentation ¶
Overview ¶
Package node contains the main executable for go-spacemesh node
Index ¶
- Constants
- Variables
- func ActivateGrpcServer(smApp *App)
- func GracefulShutdown(apps []*App)
- func LoadConfigFromFile() (*config.Config, error)
- func StartMultiNode(logger log.Log, numOfInstances, layerAvgSize int, runTillLayer uint32, ...)
- type App
- func (app *App) Cleanup()
- func (app *App) HareFactory(ctx context.Context, mdb *mesh.DB, sgn hare.Signer, nodeID types.NodeID, ...) HareService
- func (app *App) Initialize() (err error)
- func (app *App) LoadOrCreateEdSigner() (*signing.EdSigner, error)
- func (app *App) SetLogLevel(name, loglevel string) error
- func (app *App) Start() error
- type HareService
- type ManualClock
- func (clk *ManualClock) AwaitLayer(layerID types.LayerID) chan struct{}
- func (clk *ManualClock) Close()
- func (clk *ManualClock) GetCurrentLayer() types.LayerID
- func (clk *ManualClock) GetGenesisTime() time.Time
- func (clk *ManualClock) LayerToTime(types.LayerID) time.Time
- func (clk *ManualClock) StartNotifying()
- func (clk *ManualClock) Subscribe() timesync.LayerTimer
- func (clk *ManualClock) Tick()
- func (clk *ManualClock) Unsubscribe(ch timesync.LayerTimer)
- type Option
- type Service
- type TickProvider
Constants ¶
const ( AppLogger = "app" P2PLogger = "p2p" PostLogger = "post" StateDbLogger = "stateDbStore" StateLogger = "state" AtxDbStoreLogger = "atxDbStore" TBeaconDbStoreLogger = "tbDbStore" TBeaconLogger = "tBeacon" WeakCoinLogger = "weakCoin" PoetDbStoreLogger = "poetDbStore" StoreLogger = "store" PoetDbLogger = "poetDb" MeshDBLogger = "meshDb" TrtlLogger = "trtl" AtxDbLogger = "atxDb" BlkEligibilityLogger = "blkElgValidator" MeshLogger = "mesh" SyncLogger = "sync" BlockOracle = "blockOracle" HareBeaconLogger = "hareBeacon" HareOracleLogger = "hareOracle" HareLogger = "hare" BlockBuilderLogger = "blockBuilder" BlockListenerLogger = "blockListener" PoetListenerLogger = "poetListener" NipostBuilderLogger = "nipostBuilder" AtxBuilderLogger = "atxBuilder" GossipListener = "gossipListener" Fetcher = "fetcher" LayerFetcher = "layerFetcher" TimeSyncLogger = "timesync" SVMLogger = "SVM" )
Logger names.
Variables ¶
var Cmd = &cobra.Command{ Use: "node", Short: "start node", Run: func(cmd *cobra.Command, args []string) { conf, err := LoadConfigFromFile() if err != nil { log.With().Error("can't load config file", log.Err(err)) return } if err := cmdp.EnsureCLIFlags(cmd, conf); err != nil { log.With().Error("can't ensure that cli flags match config value types", log.Err(err)) return } if conf.TestMode { log.JSONLog(true) } app := New( WithConfig(conf), WithLog(log.RegisterHooks( log.NewWithLevel("", zap.NewAtomicLevelAt(zapcore.DebugLevel)), events.EventHook())), ) starter := func() error { if err := app.Initialize(); err != nil { log.With().Error("Failed to initialize node.", log.Err(err)) return fmt.Errorf("init node: %w", err) } if err := app.Start(); err != nil { log.With().Error("Failed to start the node. See logs for details.", log.Err(err)) return fmt.Errorf("start node: %w", err) } return nil } err = starter() app.Cleanup() if err != nil { os.Exit(1) } }, }
Cmd is the cobra wrapper for the node, that allows adding parameters to it.
var VersionCmd = &cobra.Command{ Use: "version", Short: "Show version info", Run: func(cmd *cobra.Command, args []string) { fmt.Print(cmdp.Version) if cmdp.Commit != "" { fmt.Printf("+%s", cmdp.Commit) } fmt.Println() }, }
VersionCmd returns the current version of spacemesh.
Functions ¶
func ActivateGrpcServer ¶
func ActivateGrpcServer(smApp *App)
ActivateGrpcServer starts a grpc server on the provided node.
func GracefulShutdown ¶
func GracefulShutdown(apps []*App)
GracefulShutdown stops the current services running in apps.
func LoadConfigFromFile ¶
LoadConfigFromFile tries to load configuration file if the config parameter was specified.
Types ¶
type App ¶
App is the cli app singleton.
func InitSingleInstance ¶
func InitSingleInstance(lg log.Log, cfg config.Config, i int, genesisTime string, storePath string, rolacle *eligibility.FixedRolacle, poetClient *activation.HTTPPoetClient, clock TickProvider, host *p2p.Host, edSgn *signing.EdSigner) (*App, error)
InitSingleInstance initializes a node instance with given configuration and parameters, it does not stop the instance.
func (*App) HareFactory ¶
func (app *App) HareFactory( ctx context.Context, mdb *mesh.DB, sgn hare.Signer, nodeID types.NodeID, patrol *layerpatrol.LayerPatrol, syncer *syncer.Syncer, msh *mesh.Mesh, beacons blocks.BeaconGetter, hOracle hare.Rolacle, idStore *activation.IdentityStore, clock TickProvider, lg log.Log, ) HareService
HareFactory returns a hare consensus algorithm according to the parameters in app.Config.Hare.SuperHare.
func (*App) Initialize ¶
Initialize sets up an exit signal, logging and checks the clock, returns error if clock is not in sync.
func (*App) LoadOrCreateEdSigner ¶
LoadOrCreateEdSigner either loads a previously created ed identity for the node or creates a new one if not exists.
func (*App) SetLogLevel ¶
SetLogLevel updates the log level of an existing logger.
type HareService ¶
HareService is basic definition of hare algorithm service, providing consensus results for a layer.
type ManualClock ¶
type ManualClock struct {
// contains filtered or unexported fields
}
ManualClock is a clock that releases ticks on demand and not according to a real world clock.
func NewManualClock ¶
func NewManualClock(genesisTime time.Time) *ManualClock
NewManualClock creates a new manual clock struct.
func (*ManualClock) AwaitLayer ¶
func (clk *ManualClock) AwaitLayer(layerID types.LayerID) chan struct{}
AwaitLayer implement the ability to notify a subscriber when a layer has ticked.
func (*ManualClock) Close ¶
func (clk *ManualClock) Close()
Close does nothing because this clock is manual.
func (*ManualClock) GetCurrentLayer ¶
func (clk *ManualClock) GetCurrentLayer() types.LayerID
GetCurrentLayer gets the last ticked layer.
func (*ManualClock) GetGenesisTime ¶
func (clk *ManualClock) GetGenesisTime() time.Time
GetGenesisTime returns the set genesis time for this clock.
func (*ManualClock) LayerToTime ¶ added in v0.1.6
func (clk *ManualClock) LayerToTime(types.LayerID) time.Time
LayerToTime returns the time of the provided layer.
func (*ManualClock) StartNotifying ¶
func (clk *ManualClock) StartNotifying()
StartNotifying is empty because this clock is manual.
func (*ManualClock) Subscribe ¶
func (clk *ManualClock) Subscribe() timesync.LayerTimer
Subscribe allow subscribes to be notified when a layer ticks.
func (*ManualClock) Tick ¶
func (clk *ManualClock) Tick()
Tick notifies all subscribers to this clock.
func (*ManualClock) Unsubscribe ¶
func (clk *ManualClock) Unsubscribe(ch timesync.LayerTimer)
Unsubscribe removes this channel ch from channels notified on tick.
type Option ¶
type Option func(app *App)
Option to modify an App instance.
func WithConfig ¶
WithConfig overvwrites default App config.
type Service ¶
Service is a general service interface that specifies the basic start/stop functionality.
type TickProvider ¶
type TickProvider interface { Subscribe() timesync.LayerTimer Unsubscribe(timesync.LayerTimer) GetCurrentLayer() types.LayerID StartNotifying() GetGenesisTime() time.Time LayerToTime(types.LayerID) time.Time Close() AwaitLayer(types.LayerID) chan struct{} }
TickProvider is an interface to a glopbal system clock that releases ticks on each layer.