Skip to content

Commit

Permalink
feat(core-p2p): use compression on the p2p level (#2886)
Browse files Browse the repository at this point in the history
* Traffic volume is reduced 21 times (!)
* As expected, only small messages appear in clear text (uncompressed)
  now in tcpdump(1) output. Messages smaller than 1024 bytes are not
  compressed
* Compression is used according to the following:
  server perMessageDeflate=true,    client perMessageDeflate=true:    yes
  server perMessageDeflate=true,    client perMessageDeflate not set: yes
  server perMessageDeflate not set, client perMessageDeflate=true:    no
  server perMessageDeflate not set, client perMessageDeflate not set: no
  • Loading branch information
vasild authored and spkjp committed Aug 22, 2019
1 parent 5df769b commit a201d64
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/core-p2p/src/peer-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class PeerConnector implements P2P.IPeerConnector {
port: peer.port,
hostname: peer.ip,
ackTimeout: Math.max(app.resolveOptions("p2p").getBlocksTimeout, app.resolveOptions("p2p").verifyTimeout),
perMessageDeflate: true,
});

this.connections.set(peer.ip, connection);
Expand Down
1 change: 1 addition & 0 deletions packages/core-p2p/src/socket-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const startSocketServer = async (service: P2P.IPeerService, config: Recor
// See https://github.com/SocketCluster/socketcluster/issues/506 about
// details on how pingTimeout works.
pingTimeout: Math.max(app.resolveOptions("p2p").getBlocksTimeout, app.resolveOptions("p2p").verifyTimeout),
perMessageDeflate: true,
},
...config.server,
});
Expand Down

0 comments on commit a201d64

Please sign in to comment.