Skip to content
This repository was archived by the owner on Dec 10, 2020. It is now read-only.

Commit 1f7f83a

Browse files
holgerd77evertonfraga
authored andcommitted
Expand common singleton config accees to lib/service/
1 parent eb977b4 commit 1f7f83a

File tree

5 files changed

+12
-31
lines changed

5 files changed

+12
-31
lines changed

lib/node.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ export default class Node extends events.EventEmitter {
5454
servers: this.servers,
5555
logger: this.logger,
5656
lightserv: options.lightserv,
57-
common: this.config.common,
57+
config: this.config,
5858
minPeers: options.minPeers,
5959
maxPeers: options.maxPeers,
6060
db: options.db,
6161
})
6262
: new LightEthereumService({
6363
servers: this.servers,
6464
logger: this.logger,
65-
common: this.config.common,
65+
config: this.config,
6666
minPeers: options.minPeers,
6767
maxPeers: options.maxPeers,
6868
db: options.db,

lib/service/ethereumservice.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { Service } from './service'
22
import { FlowControl } from '../net/protocol/flowcontrol'
33
import { Chain } from '../blockchain'
4-
import Common from '@ethereumjs/common'
4+
import { Config } from '../config'
55

66
const defaultOptions = {
77
lightserv: false,
8-
common: new Common({ chain: 'mainnet', hardfork: 'chainstart' }),
98
minPeers: 3,
109
timeout: 8000,
1110
interval: 1000,
@@ -16,9 +15,10 @@ const defaultOptions = {
1615
* @memberof module:service
1716
*/
1817
export class EthereumService extends Service {
18+
public config: Config
19+
1920
public flow: FlowControl
2021
public chain: Chain
21-
public common: Common
2222
public minPeers: number
2323
public interval: number
2424
public timeout: number
@@ -27,10 +27,10 @@ export class EthereumService extends Service {
2727
/**
2828
* Create new ETH service
2929
* @param {Object} options constructor parameters
30+
* @param {Config} [options.config] Client configuration
3031
* @param {Server[]} options.servers servers to run service on
3132
* @param {Chain} [options.chain] blockchain
3233
* @param {LevelDB} [options.db=null] blockchain database
33-
* @param {Common} [options.common] ethereum network name
3434
* @param {number} [options.minPeers=3] number of peers needed before syncing
3535
* @param {number} [options.maxPeers=25] maximum peers allowed
3636
* @param {number} [options.timeout] protocol timeout
@@ -41,9 +41,10 @@ export class EthereumService extends Service {
4141
options = { ...defaultOptions, ...options }
4242
super(options)
4343

44+
this.config = options.config || new Config()
45+
4446
this.flow = new FlowControl(options)
4547
this.chain = options.chain || new Chain(options)
46-
this.common = options.common
4748
this.minPeers = options.minPeers
4849
this.interval = options.interval
4950
this.timeout = options.timeout

lib/service/fastethereumservice.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ export class FastEthereumService extends EthereumService {
1818
/**
1919
* Create new ETH service
2020
* @param {Object} options constructor parameters
21+
* @param {Config} [options.config] Client configuration
2122
* @param {Server[]} options.servers servers to run service on
2223
* @param {boolean} [options.lightserv=false] serve LES requests
2324
* @param {Chain} [options.chain] blockchain
24-
* @param {Common} [options.common] ethereum network name
2525
* @param {number} [options.minPeers=3] number of peers needed before syncing
2626
* @param {number} [options.maxPeers=25] maximum peers allowed
2727
* @param {number} [options.interval] sync retry interval
@@ -40,7 +40,7 @@ export class FastEthereumService extends EthereumService {
4040
logger: this.logger,
4141
pool: this.pool,
4242
chain: this.chain,
43-
common: this.common,
43+
common: this.config.common,
4444
minPeers: this.minPeers,
4545
interval: this.interval,
4646
})

lib/service/lightethereumservice.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ export class LightEthereumService extends EthereumService {
1111
/**
1212
* Create new ETH service
1313
* @param {Object} options constructor parameters
14+
* @param {Config} [options.config] Client configuration
1415
* @param {Server[]} options.servers servers to run service on
1516
* @param {Chain} [options.chain] blockchain
16-
* @param {Common} [options.common] ethereum network name
1717
* @param {number} [options.minPeers=3] number of peers needed before syncing
1818
* @param {number} [options.maxPeers=25] maximum peers allowed
1919
* @param {number} [options.interval] sync retry interval
@@ -30,7 +30,7 @@ export class LightEthereumService extends EthereumService {
3030
logger: this.logger,
3131
pool: this.pool,
3232
chain: this.chain,
33-
common: this.common,
33+
common: this.config.common,
3434
minPeers: this.minPeers,
3535
flow: this.flow,
3636
interval: this.interval,

lib/types.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)