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

Commit

Permalink
Merge pull request #75 from ethereumjs/logger-improvements
Browse files Browse the repository at this point in the history
More logger improvements
  • Loading branch information
holgerd77 authored Jun 3, 2020
2 parents c8cdb44 + 58b8211 commit d77a3f9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/dpt/ban-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export class BanList {

add(obj: any, maxAge?: number) {
for (const key of KBucket.getKeys(obj)) {
debug(`add ${formatLogId(key, verbose)}, size: ${this.lru.length}`)
this.lru.set(key, true, maxAge)
debug(`Added peer ${formatLogId(key, verbose)}, size: ${this.lru.length}`)
}
}

Expand Down
17 changes: 12 additions & 5 deletions src/rlpx/peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ export class Peer extends EventEmitter {
try {
if (this._state === 'Auth') {
if (!this._eciesSession._gotEIP8Auth) {
try {
if (parseData.slice(0, 1) === Buffer.from('04', 'hex')) {
this._eciesSession.parseAuthPlain(parseData)
} catch (err) {
} else {
this._eciesSession._gotEIP8Auth = true
this._nextPacketSize = util.buffer2int(data.slice(0, 2)) + 2
continue
Expand All @@ -154,12 +154,12 @@ export class Peer extends EventEmitter {
process.nextTick(() => this._sendAck())
} else if (this._state === 'Ack') {
if (!this._eciesSession._gotEIP8Ack) {
try {
if (parseData.slice(0, 1) === Buffer.from('04', 'hex')) {
this._eciesSession.parseAckPlain(parseData)
debug(
`Received ack (old format) from ${this._socket.remoteAddress}:${this._socket.remotePort}`,
)
} catch (err) {
} else {
this._eciesSession._gotEIP8Ack = true
this._nextPacketSize = util.buffer2int(data.slice(0, 2)) + 2
continue
Expand Down Expand Up @@ -194,7 +194,9 @@ export class Peer extends EventEmitter {
this._protocols = []

// send AUTH if outgoing connection
if (this._remoteId !== null) this._sendAuth()
if (this._remoteId !== null) {
this._sendAuth()
}
}

_parseSocketData(data: Buffer) {}
Expand Down Expand Up @@ -334,6 +336,11 @@ export class Peer extends EventEmitter {
case PREFIXES.DISCONNECT:
this._closed = true
this._disconnectReason = payload[0].length === 0 ? 0 : payload[0][0]
debug(
`DISCONNECT reason: ${DISCONNECT_REASONS[this._disconnectReason as number]} ${
this._socket.remoteAddress
}:${this._socket.remotePort}`,
)
this._disconnectWe = false
this._socket.end()
break
Expand Down
4 changes: 2 additions & 2 deletions src/rlpx/rlpx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ export class RLPx extends EventEmitter {
_refillConnections() {
if (!this._isAlive()) return
debug(
`refill connections.. queue size: ${
this._peersQueue.length
`refill connections.. queue size: ${this._peersQueue.length}, peers: ${
this._peers.size
}, open slots: ${this._getOpenSlots()}`,
)

Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function assertEq(expected: any, actual: any, msg: string, debug: any): v
if (Buffer.isBuffer(expected) && Buffer.isBuffer(actual)) {
if (expected.equals(actual)) return
message = `${msg}: ${expected.toString('hex')} / ${actual.toString('hex')}`
debug(`[ERROR] ${message}`)
debug(`[ERROR] ${message}`)
throw new assert.AssertionError({
message: message,
})
Expand Down

0 comments on commit d77a3f9

Please sign in to comment.