Skip to content

Commit

Permalink
RPC patch with Fast format (#279)
Browse files Browse the repository at this point in the history
* fast format

* parseInt16

* rpc patch entrypoint

* remove fastFormatter.js; pump version

---------

Co-authored-by: Kang <kangjianhu@conflux-chain.org>
  • Loading branch information
Tigo9527 and Kang authored Jan 8, 2025
1 parent 3feba82 commit 458ce03
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "js-conflux-sdk",
"description": "JavaScript Conflux Software Development Kit",
"version": "2.4.11",
"version": "2.4.12",
"license": "LGPL-3.0",
"author": "pan.wang@confluxnetwork.org",
"repository": "https://github.com/Conflux-Chain/js-conflux-sdk.git",
Expand Down
2 changes: 2 additions & 0 deletions src/rpc/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const format = require('../util/format');
const { rpcPatch } = require('./rpcPatch');

class RPCMethodFactory {
constructor(conflux, methods = []) {
Expand All @@ -8,6 +9,7 @@ class RPCMethodFactory {

addMethods(methods) {
for (const methodMeta of methods) {
rpcPatch(methodMeta);
const method = methodMeta.method.split('_')[1];
this[method] = this.createRPCMethod(methodMeta);
// create method alias
Expand Down
19 changes: 19 additions & 0 deletions src/rpc/rpcPatch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Give a chance to change the RPC behavior.
* For example, you may want to use a different responseFormatter for traceBlock.
* @param rpcDef
*/

// eslint-disable-next-line no-unused-vars
function emptyPatchRPCMethod(rpcDef) {
// const { method, requestFormatters, responseFormatter } = rpcDef;
}

let rpcPatch = emptyPatchRPCMethod;

// set it before initializing a new Conflux instance.
function setPRCMethodPatch(fn) {
rpcPatch = fn;
}

module.exports = { rpcPatch, setPRCMethodPatch };

0 comments on commit 458ce03

Please sign in to comment.