Skip to content

Commit

Permalink
Merge pull request #1156 from ethereumjs/small-bn-fixes
Browse files Browse the repository at this point in the history
Client: small BN fixes
  • Loading branch information
holgerd77 committed Mar 18, 2021
2 parents f97d9eb + a404276 commit b2d171c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/client/lib/net/protocol/ethprotocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class EthProtocol extends Protocol {
encodeStatus(): any {
// TODO: add latestBlock for more precise ETH/64 forkhash switch
return {
networkId: this.chain.networkId.toNumber(),
networkId: this.chain.networkId.toArrayLike(Buffer),
td: this.chain.blocks.td.toArrayLike(Buffer),
bestHash: this.chain.blocks.latest!.hash(),
genesisHash: this.chain.genesis.hash,
Expand Down
4 changes: 2 additions & 2 deletions packages/client/lib/net/protocol/lesprotocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ export class LesProtocol extends Protocol {
}

return {
networkId: this.chain.networkId.toNumber(),
networkId: this.chain.networkId.toArrayLike(Buffer),
headTd: this.chain.headers.td.toArrayLike(Buffer),
headHash: this.chain.headers.latest?.hash(),
headNum: this.chain.headers.latest?.number,
headNum: this.chain.headers.latest?.number.toArrayLike(Buffer),
genesisHash: this.chain.genesis.hash,
...serveOptions,
}
Expand Down
4 changes: 2 additions & 2 deletions packages/client/lib/rpc/modules/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export class Admin {
// TODO version not present in reference..
// const ethVersion = Math.max.apply(Math, this._ethProtocol.versions)
const latestHeader = await this._chain.getLatestHeader()
const difficulty = latestHeader.difficulty
const difficulty = latestHeader.difficulty.toString()
const genesis = bufferToHex(this._chain.genesis.hash)
const head = bufferToHex(latestHeader.mixHash)
const network = this._chain.networkId.toNumber()
const network = this._chain.networkId.toString()

const nodeInfo = {
name: clientName,
Expand Down
2 changes: 1 addition & 1 deletion packages/client/test/net/protocol/ethprotocol.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ tape('[EthProtocol]', (t) => {
t.deepEquals(
p.encodeStatus(),
{
networkId: 1,
networkId: Buffer.from('01', 'hex'),
td: Buffer.from('64', 'hex'),
bestHash: '0xaa',
genesisHash: '0xbb',
Expand Down
4 changes: 2 additions & 2 deletions packages/client/test/net/protocol/lesprotocol.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ tape('[LesProtocol]', (t) => {
})
let status = p.encodeStatus()
t.ok(
status.networkId === 1 &&
status.networkId.toString('hex') === '01' &&
status.headTd.toString('hex') === '64' &&
status.headHash === '0xaa' &&
status.headNum.toNumber() === 100 &&
status.headNum.toString('hex') === '64' &&
status.genesisHash === '0xbb' &&
status.serveHeaders === 1 &&
status.serveChainSince === 0 &&
Expand Down

0 comments on commit b2d171c

Please sign in to comment.