1
1
import * as events from 'events'
2
2
import { FastEthereumService , LightEthereumService } from './service'
3
3
import { defaultLogger } from './logging'
4
+ import { Config } from './config'
4
5
5
6
const defaultOptions = {
6
7
minPeers : 3 ,
@@ -15,8 +16,9 @@ const defaultOptions = {
15
16
* @memberof module:node
16
17
*/
17
18
export default class Node extends events . EventEmitter {
19
+ public config : Config
20
+
18
21
public logger : any
19
- public common : any
20
22
public servers : any
21
23
public syncmode : any
22
24
public services : any
@@ -27,8 +29,8 @@ export default class Node extends events.EventEmitter {
27
29
/**
28
30
* Create new node
29
31
* @param {Object } options constructor parameters
32
+ * @param {Config } [options.config] Client configuration
30
33
* @param {Logger } [options.logger] Logger instance
31
- * @param {Common } [options.common] common parameters
32
34
* @param {LevelDB } [options.db=null] blockchain database
33
35
* @param {string } [options.syncmode=light] synchronization mode ('fast' or 'light')
34
36
* @param {boolean } [options.lightserv=false] serve LES requests
@@ -42,9 +44,8 @@ export default class Node extends events.EventEmitter {
42
44
constructor ( options : any ) {
43
45
super ( )
44
46
options = { ...defaultOptions , ...options }
45
-
47
+ this . config = options . config || new Config ( )
46
48
this . logger = options . logger
47
- this . common = options . common
48
49
this . servers = options . servers
49
50
this . syncmode = options . syncmode
50
51
this . services = [
@@ -53,15 +54,15 @@ export default class Node extends events.EventEmitter {
53
54
servers : this . servers ,
54
55
logger : this . logger ,
55
56
lightserv : options . lightserv ,
56
- common : options . common ,
57
+ config : this . config ,
57
58
minPeers : options . minPeers ,
58
59
maxPeers : options . maxPeers ,
59
60
db : options . db ,
60
61
} )
61
62
: new LightEthereumService ( {
62
63
servers : this . servers ,
63
64
logger : this . logger ,
64
- common : options . common ,
65
+ config : this . config ,
65
66
minPeers : options . minPeers ,
66
67
maxPeers : options . maxPeers ,
67
68
db : options . db ,
0 commit comments