@@ -6,23 +6,37 @@ export interface Options {
66 /**
77 * Specify the chain and hardfork by passing a Common instance.
88 *
9- * If not provided this defaults to chain `mainnet` and hardfork `chainstart`
9+ * Default: chain `mainnet` and hardfork `chainstart`
1010 */
1111 common ?: Common
1212 /**
1313 * The logger instance with the log level set (winston)
14+ *
15+ * Default: Logger with loglevel 'debug'
1416 */
1517 logger ?: Logger
1618 /**
1719 * Synchronization mode ('fast' or 'light')
20+ *
21+ * Default: 'fast'
1822 */
1923 syncmode ?: string
24+ /**
25+ * Serve light peer requests
26+ *
27+ * Default: false
28+ */
29+ lightserv ?: boolean
2030 /**
2131 * Number of peers needed before syncing
32+ *
33+ * Default: 2
2234 */
2335 minPeers ?: number
2436 /**
2537 * Maximum peers allowed
38+ *
39+ * Default: 25
2640 */
2741 maxPeers ?: number
2842}
@@ -31,21 +45,29 @@ export class Config {
3145 public common : Common
3246 public logger : Logger
3347 public syncmode : string
48+ public lightserv : boolean
3449 public minPeers : number
3550 public maxPeers : number
3651
52+ public static readonly COMMON_DEFAULT = new Common ( { chain : 'mainnet' , hardfork : 'chainstart' } )
53+ public static readonly LOGGER_DEFAULT = defaultLogger
54+ public static readonly SYNCMODE_DEFAULT = 'fast'
55+ public static readonly LIGHTSERV_DEFAULT = false
56+ public static readonly MINPEERS_DEFAULT = 2
57+ public static readonly MAXPEERS_DEFAULT = 25
58+
59+
3760 constructor ( options : Options = { } ) {
3861 // Initialize Common with an explicit 'chainstart' HF set until
3962 // hardfork awareness is implemented within the library
4063 // Also a fix for https://github.com/ethereumjs/ethereumjs-vm/issues/757
4164
4265 // TODO: map chainParams (and lib/util.parseParams) to new Common format
43- this . common = options . common
44- ? options . common
45- : new Common ( { chain : 'mainnet' , hardfork : 'chainstart' } )
46- this . logger = options . logger ? options . logger : defaultLogger
47- this . syncmode = options . syncmode ? options . syncmode : 'fast'
48- this . minPeers = options . minPeers ? options . minPeers : 3
49- this . maxPeers = options . maxPeers ? options . maxPeers : 25
66+ this . common = options . common ? options . common : Config . COMMON_DEFAULT
67+ this . logger = options . logger ? options . logger : Config . LOGGER_DEFAULT
68+ this . syncmode = options . syncmode ? options . syncmode : Config . SYNCMODE_DEFAULT
69+ this . lightserv = options . lightserv ? options . lightserv : Config . LIGHTSERV_DEFAULT
70+ this . minPeers = options . minPeers ? options . minPeers : Config . MINPEERS_DEFAULT
71+ this . maxPeers = options . maxPeers ? options . maxPeers : Config . MAXPEERS_DEFAULT
5072 }
5173}
0 commit comments