Skip to content

Commit

Permalink
Merge branch 'debug-setHead-rpc-implementation' of github.com:ethereu…
Browse files Browse the repository at this point in the history
…mjs/ethereumjs-monorepo into ethjs-repl
  • Loading branch information
scorbajio committed Dec 5, 2024
2 parents 5a93f91 + cf4cff9 commit 2e4733a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/client/src/rpc/modules/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ export class Debug {
1,
[[validators.hex]],
)
this.setHead = middleware(callWithStackTrace(this.setHead.bind(this), this._rpcDebug), 1, [
[validators.blockOption],
])
this.verbosity = middleware(callWithStackTrace(this.verbosity.bind(this), this._rpcDebug), 1, [
[validators.unsignedInteger],
])
Expand Down Expand Up @@ -457,4 +460,25 @@ export class Debug {
this.client.config.logger.configure({ level: logLevels[level] })
return `level: ${this.client.config.logger.level}`
}

/**
* Returns an RLP-encoded block
* @param blockOpt Block number or tag
*/
async setHead(params: [string]) {
const [blockOpt] = params
if (blockOpt === 'pending') {
throw {
code: INVALID_PARAMS,
message: `"pending" is not yet supported`,
}
}
const block = await getBlockByOption(blockOpt, this.chain)
let res
try {
res = await this.service.skeleton?.setHead(block)
} catch (e) {
console.log(e)
}
}
}

0 comments on commit 2e4733a

Please sign in to comment.