8000 Added RPC feature to modify page size(getBlockByNumber). by Junze888 · Pull Request #264 · XDagger/xdagj · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ xdagj Public

Added RPC feature to modify page size(getBlockByNumber). #264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/XDAGJ_RPC.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
| **xdag_getBlockByHash** | BlockHash(String), Page(String), startTime(String), endTime(String) | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getBlockByHash\",\"params\":[\"55Tffne2cwGSDRJU3kouvZfRNjk19ZaE7\",\"1\",\"1690418353515\",\"1690433215999\"],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":{"height":0,"balance":"6912.000000000","blockTime":1689139840000,"timeStamp":1729679196160,"state":"Accepted","hash":null,"address":"55Tffne2cwGSDRJU3kouvZfRNjk19ZaE7","remark":null,"diff":null,"type":"Wallet","flags":null,"totalPage":1,refs":null,"transactions":[{"direction":0,"hashlow":"0000000000000000bf32a3dcbf86f0f581fa813ed00ff86a3e5358d1a1c5c61c","address":"HMbFodFYUz5q+A/QPoH6gfXwhr/cozK/","amount":"640.000000000","time":1690418353515,"remark":"old balance to new address\u0000\u0000\u0000\u0000\u0000\u0000"]}}} | Enter blockhash & page & start timestamp & end timestamp to return the block information |
| **xdag_getBlockByHash** | BlockHash(String), Page(String), startTime(String), endTime(String), PageSize(String) | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getBlockByHash\",\"params\":[\"4mvr3DNkpWY9ikpGy4maaMSQqUmXjR2hp\",\"1\",\"1691675158000\",\"1691675168999\",\"3\"],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":{"height":0,"balance":"37.000000000","blockTime":1689139840000,"timeStamp":1729679196160,"state":"Accepted","hash":null,"address":"4mvr3DNkpWY9ikpGy4maaMSQqUmXjR2hp","remark":null,"diff":null,"type":"Wallet","flags":null,"totalPage":1,"refs":null,&qu 8000 ot;transactions":[{"direction":0,"hashlow":"00000000000000005161900e0c375f9c3600cf1aa894bb5d003127b9f3ca0f56","address":"Vg/K87knMQBdu5SoGs8ANpxfNwwOkGFR","amount":"64.000000000","time":1691675158000,"remark":"old balance to new address\u0000\u0000\u0000\u0000\u0000\u0000"}]}} | Enter blockhash & page & start timestamp & end timestamp & page size to return the block information |
| **xdag_getBlockByHash** | BlockHash(String), 0 <br />"Set Page = 0, thereby avoiding querying MySQL to retrieve tx". | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getBlockByHash\",\"params\":[\"4mvr3DNkpWY9ikpGy4maaMSQqUmXjR2hp\",\"0\"],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":{"height":0,"balance":"1600.000000000","blockTime":1689139840000,"timeStamp":1729679196160,"state":"Accepted","hash":null,"address":"4mvr3DNkpWY9ikpGy4maaMSQqUmXjR2hp","remark":null,"diff":null,"type":"Wallet","flags":null,"totalPage":0,"refs":null,"transactions":null}} | Enter blockhash & set page = 0 to return the block information without querying MySQL to obtain tx |
| **xdag_getBlockByNumber** | BlockHeight(String), Page(String) | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_blockNumber\",\"params\":[\"2652592\",\"1\"],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":{"height":2652592,"balance":"0.000000000","blockTime":1690356415999,"timeStamp":1730924969983,"state":"Main","hash":"e5975ce26b8102350573292b19c38d0ef9dc09a374b9e86a2aedb011fa7c0d8e","address":"jg18+hGw7Spq6Ll0ownc+Q6NwxkrKXMF","remark":"XdagJ","diff":"0xcdf6e05670013e7517c3e4582f8","type":"Main","flags":"3f","totalpage":1,"refs":[{"direction":2,"address":"jg18+hGw7Spq6Ll0ownc+Q6NwxkrKXMF","hashlow":"00000000000000000573292b19c38d0ef9dc09a374b9e86a2aedb011fa7c0d8e","amount":"0.000000000"},{"direction":1,"address":"/JoxRqqgh7T/z2n7TjptTQ84n+QYfrqS","hashlow":"000000000000000092ba7e18e49f380f4d6d3a4efb69cfffb487a0aa46319afc","amount":"0.000000000"},{"direction":1,"address":"7LE5lCuvIAyREE3jF1VWTa85apucqS7Z","hashlow":"0000000000000000d92ea99c9b6a39af4d565517e34d10910c20af2b9439b1ec","amount":"0.000000000"}],"transactions":[{"direction":2,"hashlow":"00000000000000000573292b19c38d0ef9dc09a374b9e86a2aedb011fa7c0d8e","address":"jg18+hGw7Spq6Ll0ownc+Q6NwxkrKXMF","amount":"64.000000000","time":1690356415999,"remark":"XdagJ"}]}} | Enter block height & page to return block information |
| **xdag_getBlockByNumber** | BlockHeight(String), 0 <br />"Set Page = 0, thereby avoiding querying MySQL to retrieve tx". | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_blockNumber\",\"params\":[\"2652628\",\"0\"],\"id\":1}" <br />Resp: {"jsonrpc":"2.0","id":1,"result":{"height":2652628,"balance":"64.000000000","blockTime":1690781887999,"timeStamp":1731360653311,"state":"Main","hash":"efb5d86f28f16dc1ff51e4468edcaa508e97fe3a704b6db7a40c393b84d59683","address":"g5bVhDs5DKS3bUtwOv6XjlCq3I5G5FH/","remark":"XdagJ","diff":"0xcdf6e05670013e752373b6389d4","type":"Main","flags":"3f","totalPage":0,"refs":[{"direction":2,"address":"g5bVhDs5DKS3bUtwOv6XjlCq3I5G5FH/","hashlow":"0000000000000000ff51e4468edcaa508e97fe3a704b6db7a40c393b84d59683","amount":"0.000000000"},{"direction":1,"address":"uA+JMeO1R+XMraLPywQDbS+J44FqqOqt","hashlow":"0000000000000000adeaa86a81e3892f6d0304cbcfa2adcce547b5e331890fb8","amount":"0.000000000"},{"direction":1,"address":"Zt3jpA2OXs38d3scK5BxPVfT6+pUSFf/","hashlow":"0000000000000000ff574854eaebd3573d71902b1c7b77fccd5e8e0da4e3dd66","amount":"0.000000000"}],"transactions":null}} | Enter block height & set page = 0 to return block information without querying MySQL to obtain tx |
| **xdag_getBlockByNumber** | BlockHeight(String), Page(String) | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getBlockByNumber\",\"params\":[\"2652592\",\"1\"],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":{"height":2652592,"balance":"0.000000000","blockTime":1690356415999,"timeStamp":1730924969983,"state":"Main","hash":"e5975ce26b8102350573292b19c38d0ef9dc09a374b9e86a2aedb011fa7c0d8e","address":"jg18+hGw7Spq6Ll0ownc+Q6NwxkrKXMF","remark":"XdagJ","diff":"0xcdf6e05670013e7517c3e4582f8","type":"Main","flags":"3f","totalpage":1,"refs":[{"direction":2,"address":"jg18+hGw7Spq6Ll0ownc+Q6NwxkrKXMF","hashlow":"00000000000000000573292b19c38d0ef9dc09a374b9e86a2aedb011fa7c0d8e","amount":"0.000000000"},{"direction":1,"address":"/JoxRqqgh7T/z2n7TjptTQ84n+QYfrqS","hashlow":"000000000000000092ba7e18e49f380f4d6d3a4efb69cfffb487a0aa46319afc","amount":"0.000000000"},{"direction":1,"address":"7LE5lCuvIAyREE3jF1VWTa85apucqS7Z","hashlow":"0000000000000000d92ea99c9b6a39af4d565517e34d10910c20af2b9439b1ec","amount":"0.000000000"}],"transactions":[{"direction":2,"hashlow":"00000000000000000573292b19c38d0ef9dc09a374b9e86a2aedb011fa7c0d8e","address":"jg18+hGw7Spq6Ll0ownc+Q6NwxkrKXMF","amount":"64.000000000","time":1690356415999,"remark":"XdagJ"}]}} | Enter block height & page to return block information |
| **xdag_getBlockByNumber** | BlockHeight(String), 0 <br />"Set Page = 0, thereby avoiding querying MySQL to retrieve tx". | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getBlockByNumber\",\"params\":[\"2652628\",\"0\"],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":{"height":2652628,"balance":"64.000000000","blockTime":1690781887999,"timeStamp":1731360653311,"state":"Main","hash":"efb5d86f28f16dc1ff51e4468edcaa508e97fe3a704b6db7a40c393b84d59683","address":"g5bVhDs5DKS3bUtwOv6XjlCq3I5G5FH/","remark":"XdagJ","diff":"0xcdf6e05670013e752373b6389d4","type":"Main","flags":"3f","totalPage":0,"refs":[{"direction":2,"address":"g5bVhDs5DKS3bUtwOv6XjlCq3I5G5FH/","hashlow":"0000000000000000ff51e4468edcaa508e97fe3a704b6db7a40c393b84d59683","amount":"0.000000000"},{"direction":1,"address":"uA+JMeO1R+XMraLPywQDbS+J44FqqOqt","hashlow":"0000000000000000adeaa86a81e3892f6d0304cbcfa2adcce547b5e331890fb8","amount":"0.000000000"},{"direction":1,"address":"Zt3jpA2OXs38d3scK5BxPVfT6+pUSFf/","hashlow":"0000000000000000ff574854eaebd3573d71902b1c7b77fccd5e8e0da4e3dd66","amount":"0.000000000"}],"transactions":null}} | Enter block height & set page = 0 to return block information without querying MySQL to obtain tx |
| **xdag_getBlockByNumber** | BlockHeight(String), Page(String), PageSize(String) | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getBlockByNumber\",\"params\":[\"2650572\",\"1\",\"2\"],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":{"height":0,"balance":"0.000000000","blockTime":1689139840000,"timeStamp":1729679196160,"state":null,"hash":"2f9f2c437ccf2bb5a51bb1f8c2dc7484d2c64e9ba48e3eb31073c52a7b63e7ff","address":"/+djeyrFcxCzPo6km07G0oR03ML4sRul","remark":null,"diff":null,"type":"Snapshot","flags":null,"totalPage":2,"refs":null,"transactions":[{"direction":1,"hashlow":"0000000000000000042b5b9cb5241190af069321f194f14e39b59c9616371d83","address":"gx03FpactTlO8ZTxIZMGr5ARJLWcWysE","amount":"64.000000000","time":1691827406885,"remark":"old balance to new address\u0000\u0000\u0000\u0000\u0000\u0000"},{"direction":1,"hashlow":"0000000000000000042b5b9cb5241190af069321f194f14e39b59c9616371d83","address":"gx03FpactTlO8ZTxIZMGr5ARJLWcWysE","amount":"64.000000000","time":1691827406885,"remark":"old balance to new address\u0000\u0000\u0000\u0000\u0000\u0000"}]}} | Enter block height & page & page size to return block information |
| **xdag_blockNumber** | Null | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_blockNumber\",\"params\":[],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":"5"} | Used to return the current main block height |
| **xdag_coinbase** | Null | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_coinbase\",\"params\":[],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":"K5q0ews/ma110QLUzePetOdU+EwYKrud"} | Used to return the current pool miner |
| **xdag_getBalance** | Address(String) | Req: <br />curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getBalance\",\"params\":[\"K5q0ews/ma110QLUzePetOdU+EwYKrud\"],\"id\":1}" <br />Resp: <br />{"jsonrpc":"2.0","id":1,"result":"1024.000000000"} | Enter an address to return the balance of the address |
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/io/xdag/rpc/Web3Impl.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public BlockResultDTO xdag_getBlockByNumber(String bnOrId, int page) {
return web3XdagModule.xdag_getBlockByNumber(bnOrId, page);
}

public BlockResultDTO xdag_getBlockByNumber(String bnOrId, int page, int pageSize) {
return web3XdagModule.xdag_getBlockByNumber(bnOrId, page, pageSize);
}

@Override
public String xdag_getRewardByNumber(String bnOrId) {
return web3XdagModule.xdag_getRewardByNumber(bnOrId);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/io/xdag/rpc/modules/xdag/Web3XdagModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ default BlockResultDTO xdag_getBlockByNumber(String bnOrId, int page) {
return getXdagModule().getBlockByNumber(bnOrId, page);
}

default BlockResultDTO xdag_getBlockByNumber(String bnOrId, int page, int pageSize) {
return getXdagModule().getBlockByNumber(bnOrId, page, pageSize);
}

default String xdag_getRewardByNumber(String bnOrId) {
return getXdagModule().getRewardByNumber(bnOrId);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/xdag/rpc/modules/xdag/XdagModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public BlockResultDTO getBlockByHash(String hash, int page,Object... parameters
}

@Override
public BlockResultDTO getBlockByNumber(String bnOrId, int page) {
return xdagModuleChain.getBlockByNumber(bnOrId, page);
public BlockResultDTO getBlockByNumber(String bnOrId, int page, Object... parameters) {
return xdagModuleChain.getBlockByNumber(bnOrId, page, parameters);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public interface XdagModuleChain {

BlockResultDTO getBlockByHash(String hash, int page, Object... parameters);

BlockResultDTO getBlockByNumber(String bnOrId, int page);
BlockResultDTO getBlockByNumber(String bnOrId, int page, Object... parameters );

String getRewardByNumber(String bnOrId);

Expand Down
Loading
0