Skip to content

Commit

Permalink
feat(core-p2p): allow to configure peer discovery (#1325)
Browse files Browse the repository at this point in the history
  • Loading branch information
faustbrian committed Nov 8, 2018
1 parent e9bf187 commit 0b3f514
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 25 deletions.
1 change: 1 addition & 0 deletions packages/core-config/__tests__/__stubs__/peers.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"discover": true,
"blackList": [],
"list": [{
"ip": "127.0.0.1",
Expand Down
24 changes: 0 additions & 24 deletions packages/core-error-tracker-sentry/jsdoc.json

This file was deleted.

1 change: 1 addition & 0 deletions packages/core-p2p/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Reject forgers as peers
- Recovery after a fork
- Enabled rate-limiting
- Enable/Disable peer discovery

### Changed
- Network state calculation (new internal/networkState) taking PBFT into account
Expand Down
7 changes: 6 additions & 1 deletion packages/core-p2p/lib/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Monitor {
async updateNetworkStatus () {
try {
// TODO: for tests that involve peers we need to sync them
if (process.env.ARK_ENV !== 'test') {
if (process.env.ARK_ENV !== 'test' && config.peers.discover) {
await this.discoverPeers()
await this.cleanPeers()
}
Expand All @@ -84,6 +84,11 @@ class Monitor {
* @throws {Error} If invalid peer
*/
async acceptNewPeer (peer) {
if (!config.peers.discover) {
logger.warn(`Rejected ${peer.ip} because the relay is in non-discovery mode.`)
return
}

if (this.guard.isSuspended(peer) || this.guard.isMyself(peer) || process.env.ARK_ENV === 'test') {
return
}
Expand Down
1 change: 1 addition & 0 deletions packages/core-test-utils/config/testnet/peers.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"discover": true,
"minimumVersion": ">=1.3.3",
"minimumNetworkReach": 5,
"globalTimeout": 5000,
Expand Down
1 change: 1 addition & 0 deletions packages/core/lib/config/devnet/peers.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"discover": true,
"minimumVersion": ">=1.3.3",
"minimumNetworkReach": 5,
"globalTimeout": 5000,
Expand Down
1 change: 1 addition & 0 deletions packages/core/lib/config/mainnet/peers.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"discover": true,
"minimumVersion": ">=1.3.3",
"minimumNetworkReach": 20,
"globalTimeout": 5000,
Expand Down
1 change: 1 addition & 0 deletions packages/core/lib/config/testnet.1/peers.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"discover": true,
"minimumVersion": ">=1.3.3",
"minimumNetworkReach": 20,
"globalTimeout": 5000,
Expand Down
1 change: 1 addition & 0 deletions packages/core/lib/config/testnet.2/peers.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"discover": true,
"minimumVersion": ">=1.3.3",
"minimumNetworkReach": 20,
"globalTimeout": 5000,
Expand Down
1 change: 1 addition & 0 deletions packages/core/lib/config/testnet.live/peers.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"discover": true,
"minimumVersion": ">=1.3.3",
"minimumNetworkReach": 10,
"blackList": [],
Expand Down
1 change: 1 addition & 0 deletions packages/core/lib/config/testnet/peers.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"discover": true,
"minimumVersion": ">=1.3.3",
"minimumNetworkReach": 5,
"globalTimeout": 5000,
Expand Down

0 comments on commit 0b3f514

Please sign in to comment.