Skip to content

Commit 0b88f3a

Browse files
committed
chore: release 1.1.0
1 parent 043f89c commit 0b88f3a

7 files changed

Lines changed: 126 additions & 253 deletions

File tree

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM node:alpine
2+
3+
WORKDIR /usr/src/app
4+
5+
COPY package*.json .
6+
COPY dist dist
7+
8+
RUN npm install --ignore-scripts
9+
10+
EXPOSE 9000
11+
12+
ENV PORT=""
13+
ENV TARGET=""
14+
ENV EXPIRY=""
15+
16+
CMD sh -c "node dist/index.js --port $PORT --target $TARGET --expiry $EXPIRY"

README.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,44 @@
11
# Etherproxy
22

3-
## Usage
3+
Etherproxy is a JSON-RPC reverse proxy tool designed for caching requests.
44

5-
To launch a JSON-RPC reverse proxy on port 9000 and forward all requests to GetBlock using your token and mainnet, run:
5+
## Usage
66

77
```
8-
npx etherproxy 9000 https://gno.getblock.io/YOUR_TOKEN/mainnet/
8+
npx etherproxy --port 9000 --target https://gno.getblock.io/YOUR_TOKEN/mainnet/ --expiry 2000
99
```
1010

11+
The command above starts the JSON-RPC reverse proxy...
12+
13+
- on port 9000 (`--port`)
14+
- forwarding all requests to GetBlock using your token and mainnet (`--target`)
15+
- grouping requests together within 2 seconds (`--expiry`)
16+
1117
Make sure to replace `YOUR_TOKEN` with your actual token.
1218

19+
## Verify the tool is running
20+
21+
Execute the `curl` command shown below repeatedly and inspect the logs of Etherproxy.
22+
23+
```sh
24+
curl http://localhost:9000 -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
25+
```
26+
27+
When the text `Cache hit` appears, it indicates that a request was saved and immediately returned:
28+
29+
```txt
30+
[~] Key: {"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}
31+
[~] Cache hit: {"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}
32+
[~] Cache hit: {"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}
33+
[~] Cache hit: {"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}
34+
```
35+
1336
## Benefits
1437

15-
The JSON-RPC reverse proxy provides several benefits, particularly in multi-node scenarios. For instance, requests such as `eth_blockNumber` and `eth_getLogs` are frequently called, and in such scenarios, it's easy to quickly exhaust your request quota.
38+
Etherproxy provides several benefits in multi-node scenarios. For instance, requests such as `eth_blockNumber` and `eth_getLogs` are frequently called, sometimes generating many unnecessary requests. By using a reverse proxy, the same requests made within a small time period are grouped together and sent to your JSON-RPC endpoint only once.
39+
40+
As a result, all local nodes receive identical correct responses, and the number of actual requests sent is significantly reduced, which helps to **preserve your request quota** in case of a paid third-party, or **reduce the load** when you run your own Ethereum node.
41+
42+
## Error handling
1643

17-
However, by using the reverse proxy, the same requests made within 2 seconds are grouped together and sent to your third-party service only once. As a result, all local nodes receive the same response, which can significantly reduce the number of requests made and help preserve your quota.
44+
Whenever an error is thrown, Etherproxy responds with a `503 Service Unavailable` status.

package-lock.json

Lines changed: 11 additions & 191 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "etherproxy",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "",
55
"main": "dist/index.js",
66
"bin": {
@@ -9,19 +9,18 @@
99
"scripts": {
1010
"start": "ts-node src/index.ts",
1111
"prepare": "npm run build",
12-
"build": "rimraf dist && tsc"
12+
"build": "tsc"
1313
},
1414
"keywords": [],
1515
"author": "",
1616
"license": "MIT",
1717
"dependencies": {
18-
"cafe-utility": "^9.0.1",
18+
"cafe-utility": "^10.8.1",
1919
"node-fetch": "^2.6.9"
2020
},
2121
"devDependencies": {
2222
"@types/node": "^18.15.11",
2323
"@types/node-fetch": "^2.6.3",
24-
"rimraf": "^4.4.1",
2524
"typescript": "^5.0.3"
2625
}
2726
}

0 commit comments

Comments
 (0)