Documentation ¶
Overview ¶
Package node contains the main executable for go-spacemesh node
Index ¶
- Constants
- Variables
- func ActivateGrpcServer(smApp *SpacemeshApp)
- func GracefulShutdown(apps []*SpacemeshApp)
- func LoadConfigFromFile() (*cfg.Config, error)
- func StartMultiNode(numOfinstances, layerAvgSize int, runTillLayer uint32, dbPath string)
- 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 Service
- type SpacemeshApp
- func (app *SpacemeshApp) Cleanup(*cobra.Command, []string)
- func (app *SpacemeshApp) HareFactory(mdb *mesh.DB, swarm service.Service, sgn hare.Signer, nodeID types.NodeID, ...) HareService
- func (app *SpacemeshApp) Initialize(cmd *cobra.Command, args []string) (err error)
- func (app *SpacemeshApp) LoadOrCreateEdSigner() (*signing.EdSigner, error)
- func (app *SpacemeshApp) ParseConfig() error
- func (app *SpacemeshApp) SetLogLevel(name, loglevel string) error
- func (app *SpacemeshApp) Start(cmd *cobra.Command, args []string)
- type TickProvider
Constants ¶
const ( AppLogger = "app" P2PLogger = "p2p" PostLogger = "post" StateDbLogger = "stateDbStore" StateLogger = "state" AtxDbStoreLogger = "atxDbStore" 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" NipstBuilderLogger = "nipstBuilder" AtxBuilderLogger = "atxBuilder" GossipListener = "gossipListener" )
Logger names
Variables ¶
var Cmd = &cobra.Command{ Use: "node", Short: "start node", Run: func(cmd *cobra.Command, args []string) { app := NewSpacemeshApp() defer app.Cleanup(cmd, args) err := app.Initialize(cmd, args) if err != nil { log.With().Error("Failed to initialize node.", log.Err(err)) return } app.Start(cmd, args) }, }
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 *SpacemeshApp)
ActivateGrpcServer starts a grpc server on the provided node
func GracefulShutdown ¶
func GracefulShutdown(apps []*SpacemeshApp)
GracefulShutdown stops the current services running in apps
func LoadConfigFromFile ¶
LoadConfigFromFile tries to load configuration file if the config parameter was specified
func StartMultiNode ¶
StartMultiNode Starts the run of a number of nodes, running in process consensus between them. this also runs a single transaction between the nodes.
Types ¶
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 Service ¶
type Service interface { Start() error Close() }
Service is a general service interface that specifies the basic start/stop functionality
type SpacemeshApp ¶
type SpacemeshApp struct { *cobra.Command P2P p2p.Service Config *cfg.Config // contains filtered or unexported fields }
SpacemeshApp is the cli app singleton
func InitSingleInstance ¶
func InitSingleInstance(cfg config.Config, i int, genesisTime string, rng *amcl.RAND, storePath string, rolacle *eligibility.FixedRolacle, poetClient *activation.HTTPPoetClient, clock TickProvider, net network) (*SpacemeshApp, error)
InitSingleInstance initializes a node instance with given configuration and parameters, it does not stop the instance.
func NewSpacemeshApp ¶
func NewSpacemeshApp() *SpacemeshApp
NewSpacemeshApp creates an instance of the spacemesh app
func (*SpacemeshApp) Cleanup ¶
func (app *SpacemeshApp) Cleanup(*cobra.Command, []string)
Cleanup stops all app services
func (*SpacemeshApp) HareFactory ¶
func (app *SpacemeshApp) HareFactory(mdb *mesh.DB, swarm service.Service, sgn hare.Signer, nodeID types.NodeID, syncer *sync.Syncer, msh *mesh.Mesh, hOracle hare.Rolacle, idStore *activation.IdentityStore, clock TickProvider, lg log.Log) HareService
HareFactory returns a hare consensus algorithm according to the parameters is app.Config.Hare.SuperHare
func (*SpacemeshApp) Initialize ¶
func (app *SpacemeshApp) Initialize(cmd *cobra.Command, args []string) (err error)
Initialize does pre processing of flags and configuration files, it also initializes data dirs if they dont exist
func (*SpacemeshApp) LoadOrCreateEdSigner ¶
func (app *SpacemeshApp) LoadOrCreateEdSigner() (*signing.EdSigner, error)
LoadOrCreateEdSigner either loads a previously created ed identity for the node or creates a new one if not exists
func (*SpacemeshApp) ParseConfig ¶
func (app *SpacemeshApp) ParseConfig() error
ParseConfig unmarshal config file into struct
func (*SpacemeshApp) SetLogLevel ¶
func (app *SpacemeshApp) SetLogLevel(name, loglevel string) error
SetLogLevel updates the log level of an existing logger
type TickProvider ¶
type TickProvider interface { Subscribe() timesync.LayerTimer Unsubscribe(timer timesync.LayerTimer) GetCurrentLayer() types.LayerID StartNotifying() GetGenesisTime() time.Time LayerToTime(id types.LayerID) time.Time Close() AwaitLayer(layerID types.LayerID) chan struct{} }
TickProvider is an interface to a glopbal system clock that releases ticks on each layer