@@ -111,6 +111,7 @@ public class Client {
111111 "GetBalance" ,
112112 "GetBlock" ,
113113 "GetBlockById" ,
114+ "GetBlockByIdOrNum" ,
114115 "GetBlockByLatestNum" ,
115116 "GetBlockByLimitNext" ,
116117 "GetBrokerage" ,
@@ -240,6 +241,7 @@ public class Client {
240241 "GetBalance" ,
241242 "GetBlock" ,
242243 "GetBlockById" ,
244+ "GetBlockByIdOrNum" ,
243245 "GetBlockByLatestNum" ,
244246 "GetBlockByLimitNext" ,
245247 "GetBrokerage" ,
@@ -4357,6 +4359,10 @@ private void run() {
43574359 getMarketOrderById (parameters );
43584360 break ;
43594361 }
4362+ case "getblockbyidornum" : {
4363+ getBlockByIdOrNum (parameters );
4364+ break ;
4365+ }
43604366 case "exit" :
43614367 case "quit" : {
43624368 System .out .println ("Exit !!!" );
@@ -4403,6 +4409,47 @@ private void getChainParameters() {
44034409 }
44044410 }
44054411
4412+ private void getBlockByIdOrNum (String [] parameters ) {
4413+ String idOrNum = null ;
4414+ boolean detail = false ;
4415+ if (parameters == null || parameters .length == 0 ) {
4416+ // query current header
4417+ System .out .println ("Get current header !!!" );
4418+ } else {
4419+ if (parameters .length == 1 ) {
4420+ String param = parameters [0 ];
4421+ if ("help" .equalsIgnoreCase (param )) {
4422+ // print help
4423+ System .out .println ("1.get current header using the following command:" );
4424+ System .out .println ("getBlockByIdOrNum" );
4425+ System .out .println ("2. get current block command:" );
4426+ System .out .println ("getBlockByIdOrNum true" );
4427+ System .out .println ("3. get header by id or number with the following syntax:" );
4428+ System .out .println ("getBlockByIdOrNum idOrNum" );
4429+ System .out .println ("4. get block by id or number with the following syntax:" );
4430+ System .out .println ("getBlockByIdOrNum idOrNum true" );
4431+ return ;
4432+ }
4433+ if ("true" .equalsIgnoreCase (param )) {
4434+ // query current block
4435+ detail = true ;
4436+ } else {
4437+ // query header by id or num
4438+ idOrNum = parameters [0 ];
4439+ }
4440+ } else {
4441+ idOrNum = parameters [0 ];
4442+ detail = Boolean .parseBoolean (parameters [1 ]);
4443+ }
4444+ }
4445+ BlockExtention blockExtention = walletApiWrapper .getBlock (idOrNum , detail );
4446+ if (blockExtention == null ) {
4447+ System .out .println ("No header for idOrNum : " + idOrNum );
4448+ return ;
4449+ }
4450+ System .out .println (Utils .printBlockExtention (blockExtention ));
4451+ }
4452+
44064453 public static void main (String [] args ) {
44074454 Client cli = new Client ();
44084455 JCommander .newBuilder ()
0 commit comments