Skip to content

Commit

Permalink
fix(p2p): peer header check (#785)
Browse files Browse the repository at this point in the history
* fix peer header check oversight

* Empty commit
  • Loading branch information
oXtxNt9U authored Nov 29, 2024
1 parent 6957ff6 commit 4b929c0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/p2p/source/peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,16 @@ export class Peer implements Contracts.P2P.Peer {
}

public set header(header: Contracts.P2P.HeaderData) {
const isUpdate = this.#header !== undefined;
const previousHeader = this.#header;

this.#header = header;

if (!isUpdate) {
if (previousHeader === undefined) {
return;
}

const changed = header.height !== this.#header.height || header.version !== this.#header.version;
const changed =
previousHeader.height !== this.#header.height || previousHeader.version !== this.#header.version;
if (changed) {
void this.events.dispatch(Events.PeerEvent.Updated, this);
}
Expand Down

0 comments on commit 4b929c0

Please sign in to comment.