@ -32,8 +32,8 @@ import (
// the protocol stack, that is passed to all constructors to be optionally used;
// the protocol stack, that is passed to all constructors to be optionally used;
// as well as utility methods to operate on the service environment.
// as well as utility methods to operate on the service environment.
type ServiceContext struct {
type ServiceContext struct {
config * Config
services map [ reflect . Type ] Service // Index of the already constructed services
services map [ reflect . Type ] Service // Index of the already constructed services
Config Config
EventMux * event . TypeMux // Event multiplexer used for decoupled notifications
EventMux * event . TypeMux // Event multiplexer used for decoupled notifications
AccountManager * accounts . Manager // Account manager created by the node.
AccountManager * accounts . Manager // Account manager created by the node.
}
}
@ -42,10 +42,10 @@ type ServiceContext struct {
// if no previous can be found) from within the node's data directory. If the
// if no previous can be found) from within the node's data directory. If the
// node is an ephemeral one, a memory database is returned.
// node is an ephemeral one, a memory database is returned.
func ( ctx * ServiceContext ) OpenDatabase ( name string , cache int , handles int , namespace string ) ( ethdb . Database , error ) {
func ( ctx * ServiceContext ) OpenDatabase ( name string , cache int , handles int , namespace string ) ( ethdb . Database , error ) {
if ctx . c onfig. DataDir == "" {
if ctx . C onfig. DataDir == "" {
return rawdb . NewMemoryDatabase ( ) , nil
return rawdb . NewMemoryDatabase ( ) , nil
}
}
return rawdb . NewLevelDBDatabase ( ctx . c onfig. ResolvePath ( name ) , cache , handles , namespace )
return rawdb . NewLevelDBDatabase ( ctx . C onfig. ResolvePath ( name ) , cache , handles , namespace )
}
}
// OpenDatabaseWithFreezer opens an existing database with the given name (or
// OpenDatabaseWithFreezer opens an existing database with the given name (or
@ -54,16 +54,16 @@ func (ctx *ServiceContext) OpenDatabase(name string, cache int, handles int, nam
// database to immutable append-only files. If the node is an ephemeral one, a
// database to immutable append-only files. If the node is an ephemeral one, a
// memory database is returned.
// memory database is returned.
func ( ctx * ServiceContext ) OpenDatabaseWithFreezer ( name string , cache int , handles int , freezer string , namespace string ) ( ethdb . Database , error ) {
func ( ctx * ServiceContext ) OpenDatabaseWithFreezer ( name string , cache int , handles int , freezer string , namespace string ) ( ethdb . Database , error ) {
if ctx . c onfig. DataDir == "" {
if ctx . C onfig. DataDir == "" {
return rawdb . NewMemoryDatabase ( ) , nil
return rawdb . NewMemoryDatabase ( ) , nil
}
}
root := ctx . c onfig. ResolvePath ( name )
root := ctx . C onfig. ResolvePath ( name )
switch {
switch {
case freezer == "" :
case freezer == "" :
freezer = filepath . Join ( root , "ancient" )
freezer = filepath . Join ( root , "ancient" )
case ! filepath . IsAbs ( freezer ) :
case ! filepath . IsAbs ( freezer ) :
freezer = ctx . c onfig. ResolvePath ( freezer )
freezer = ctx . C onfig. ResolvePath ( freezer )
}
}
return rawdb . NewLevelDBDatabaseWithFreezer ( root , cache , handles , freezer , namespace )
return rawdb . NewLevelDBDatabaseWithFreezer ( root , cache , handles , freezer , namespace )
}
}
@ -72,7 +72,7 @@ func (ctx *ServiceContext) OpenDatabaseWithFreezer(name string, cache int, handl
// and if the user actually uses persistent storage. It will return an empty string
// and if the user actually uses persistent storage. It will return an empty string
// for emphemeral storage and the user's own input for absolute paths.
// for emphemeral storage and the user's own input for absolute paths.
func ( ctx * ServiceContext ) ResolvePath ( path string ) string {
func ( ctx * ServiceContext ) ResolvePath ( path string ) string {
return ctx . c onfig. ResolvePath ( path )
return ctx . C onfig. ResolvePath ( path )
}
}
// Service retrieves a currently running service registered of a specific type.
// Service retrieves a currently running service registered of a specific type.
@ -88,7 +88,7 @@ func (ctx *ServiceContext) Service(service interface{}) error {
// ExtRPCEnabled returns the indicator whether node enables the external
// ExtRPCEnabled returns the indicator whether node enables the external
// RPC(http, ws or graphql).
// RPC(http, ws or graphql).
func ( ctx * ServiceContext ) ExtRPCEnabled ( ) bool {
func ( ctx * ServiceContext ) ExtRPCEnabled ( ) bool {
return ctx . c onfig. ExtRPCEnabled ( )
return ctx . C onfig. ExtRPCEnabled ( )
}
}
// ServiceConstructor is the function signature of the constructors needed to be
// ServiceConstructor is the function signature of the constructors needed to be