Skip to content

Commit

Permalink
devp2p -> snappy: more user friendly RLPx protocol version checks
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerd77 committed Aug 17, 2021
1 parent 61b0511 commit 892c71c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/devp2p/src/eth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export class ETH extends EventEmitter {
let payload = rlp.encode(this._status as any)

// Use snappy compression if peer supports DevP2P >=v5
if ((this._peer._hello?.protocolVersion ?? 0) >= 5) {
if (this._peer._hello?.protocolVersion && this._peer._hello?.protocolVersion >= 5) {
payload = snappy.compress(payload)
}

Expand Down Expand Up @@ -284,7 +284,7 @@ export class ETH extends EventEmitter {
payload = rlp.encode(payload)

// Use snappy compression if peer supports DevP2P >=v5
if ((this._peer._hello?.protocolVersion ?? 0) >= 5) {
if (this._peer._hello?.protocolVersion && this._peer._hello?.protocolVersion >= 5) {
payload = snappy.compress(payload)
}

Expand Down
4 changes: 2 additions & 2 deletions packages/devp2p/src/les/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class LES extends EventEmitter {
let payload = rlp.encode(statusList)

// Use snappy compression if peer supports DevP2P >=v5
if ((this._peer._hello?.protocolVersion ?? 0) >= 5) {
if (this._peer._hello?.protocolVersion && this._peer._hello?.protocolVersion >= 5) {
payload = snappy.compress(payload)
}

Expand Down Expand Up @@ -231,7 +231,7 @@ export class LES extends EventEmitter {
payload = rlp.encode(payload)

// Use snappy compression if peer supports DevP2P >=v5
if ((this._peer._hello?.protocolVersion ?? 0) >= 5) {
if (this._peer._hello?.protocolVersion && this._peer._hello?.protocolVersion >= 5) {
payload = snappy.compress(payload)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/devp2p/src/rlpx/peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ export class Peer extends EventEmitter {
let payload = body.slice(1)

// Use snappy uncompression if peer supports DevP2P >=v5
if ((this._hello?.protocolVersion ?? 0) >= 5) {
if (this._hello?.protocolVersion && this._hello?.protocolVersion >= 5) {
payload = snappy.uncompress(payload)
}

Expand Down

0 comments on commit 892c71c

Please sign in to comment.