Skip to content

Commit

Permalink
add getversion,delete getsystemfee (DNAProject#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
xizho10 authored and laizy committed Jun 21, 2018
1 parent d26e7e4 commit 580dcd5
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 54 deletions.
23 changes: 23 additions & 0 deletions docs/specifications/restful_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Restful Api List
| get_unboundong | GET /api/v1/unboundong/:addr |
| get_mempooltxcount | GET /api/v1/mempool/txcount |
| get_mempooltxstate | GET /api/v1/mempool/txstate/:hash |
| get_version | GET /api/v1/version |
| post_raw_tx | post /api/v1/transaction?preExec=0 |


Expand Down Expand Up @@ -889,6 +890,28 @@ curl -i http://localhost:20334/api/v1/mempool/txcount
}
```

### 21 get_version

Get the version information of the node.

GET
```
/api/v1/version
```
#### Request Example:
```
curl -i http://localhost:20334/api/v1/version
```
#### Response
```
{
"Action": "getversion",
"Desc": "SUCCESS",
"Error": 0,
"Version": "1.0.0",
"Result": "0.9"
}
```

## Error Code

Expand Down
61 changes: 12 additions & 49 deletions docs/specifications/rpc_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ Transaction field description
| getrawtransaction | transactionhash | Returns the corresponding transaction information based on the specified hash value. | |
| sendrawtransaction | hex,preExec | Broadcast transaction. | Serialized signed transactions constructed in the program into hexadecimal strings |
| getstorage | script_hash | Returns the stored value according to the contract script hashes and stored key. | |
| getversion | | Get the version information of the query node | |
| getblocksysfee | | According to the specified index, return the system fee before the block. | |
| getversion | | Get the version information of the node | |
| getcontractstate | script_hash,[verbose] | According to the contract script hash, query the contract information. | |
| getmempooltxcount | | Query the transaction count in the memory pool. | |
| getmempooltxstate | tx_hash | Query the transaction state in the memory pool. | |
Expand Down Expand Up @@ -594,7 +593,7 @@ Response:
#### 10. getversion

Get the version information of the query node.
Get the version information of the node.

#### Example

Expand Down Expand Up @@ -729,44 +728,8 @@ or

> Note: If params is a number, the response result will be the txhash list. If params is txhash, the response result will be smartcode event.
#### 12. getblocksysfee

According to the specified index, return the system fee before the block.

#### Parameter instruction

Index: Block index

#### Example

Request:

```
{
"jsonrpc": "2.0",
"method": "getblocksysfee",
"params": [1005434],
"id": 1
}
```

Response:

```
{
"desc":"SUCCESS",
"error":0,
"jsonrpc": "2.0",
"id": 1,
"result": "195500"
}
```

Response instruction:

Result: The system fee before the block and the unit is OntGas.

#### 13. getcontractstate
#### 12. getcontractstate

According to the contract script hash, query the contract information.

Expand Down Expand Up @@ -809,7 +772,7 @@ Response:
}
```

#### 14. getmempooltxstate
#### 13. getmempooltxstate

Query the transaction state in the memory pool.

Expand Down Expand Up @@ -852,7 +815,7 @@ Response:
}
```

#### 15. getmempooltxcount
#### 14. getmempooltxcount

Query the transaction count in the memory pool.

Expand Down Expand Up @@ -882,7 +845,7 @@ Response:
```


#### 16. getblockheightbytxhash
#### 15. getblockheightbytxhash
get blockheight by txhash
#### Parameter instruction
txhash: transaction hash
Expand Down Expand Up @@ -910,7 +873,7 @@ Response:
}
```

#### 17. getbalance
#### 16. getbalance

return balance of base58 account address.

Expand Down Expand Up @@ -947,7 +910,7 @@ Response:
}
```

#### 18. getmerkleproof
#### 17. getmerkleproof

return merkle proof

Expand Down Expand Up @@ -1001,7 +964,7 @@ Response:
}
```

#### 19. getgasprice
#### 18. getgasprice

return gasprice.

Expand Down Expand Up @@ -1034,7 +997,7 @@ Response:
}
```

#### 20. getallowance
#### 19. getallowance

return allowance.

Expand Down Expand Up @@ -1064,7 +1027,7 @@ Response:
}
```

#### 21. getunboundong
#### 20. getunboundong

return unboundong.

Expand Down Expand Up @@ -1094,7 +1057,7 @@ Response:
}
```

#### 22 getblocktxsbyheight
#### 21 getblocktxsbyheight

Get transactions by block height
return all transaction hash contained in the block corresponding to this height
Expand Down
22 changes: 22 additions & 0 deletions docs/specifications/websocket_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,28 @@ Query the transaction count in the memory pool.
```


### 25. Get version
Get the version information of the node.

#### Request Example:
```
{
"Action": "getversion",
"Version": "1.0.0"
}
```
#### Response
```
{
"Action": "getversion",
"Desc": "SUCCESS",
"Error": 0,
"Version": "1.0.0",
"Result": "0.9"
}
```


## Error Code

| Field | Type | Description |
Expand Down
6 changes: 6 additions & 0 deletions http/base/rest/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ type ApiServer interface {
Stop()
}

func GetNodeVersion(cmd map[string]interface{}) map[string]interface{} {
resp := ResponsePack(berr.SUCCESS)
resp["Result"] = config.Version
return resp
}

//Node
func GetGenerateBlockTime(cmd map[string]interface{}) map[string]interface{} {
resp := ResponsePack(berr.SUCCESS)
Expand Down
4 changes: 0 additions & 4 deletions http/base/rpc/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,6 @@ func GetNodeVersion(params []interface{}) map[string]interface{} {
return responseSuccess(config.Version)
}

func GetSystemFee(params []interface{}) map[string]interface{} {
return responseSuccess(config.DefConfig.Common.SystemFee)
}

func GetContractState(params []interface{}) map[string]interface{} {
if len(params) < 1 {
return responsePack(berr.INVALID_PARAMS, nil)
Expand Down
1 change: 0 additions & 1 deletion http/jsonrpc/rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func StartRPCServer() error {
rpc.HandleFunc("getstorage", rpc.GetStorage)
rpc.HandleFunc("getversion", rpc.GetNodeVersion)

rpc.HandleFunc("getblocksysfee", rpc.GetSystemFee)
rpc.HandleFunc("getcontractstate", rpc.GetContractState)
rpc.HandleFunc("getmempooltxcount", rpc.GetMemPoolTxCount)
rpc.HandleFunc("getmempooltxstate", rpc.GetMemPoolTxState)
Expand Down
2 changes: 2 additions & 0 deletions http/restful/restful/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const (
GET_UNBOUNDONG = "/api/v1/unboundong/:addr"
GET_MEMPOOL_TXCOUNT = "/api/v1/mempool/txcount"
GET_MEMPOOL_TXSTATE = "/api/v1/mempool/txstate/:hash"
GET_VERSION = "/api/v1/version"

POST_RAW_TX = "/api/v1/transaction"
)
Expand Down Expand Up @@ -141,6 +142,7 @@ func (this *restServer) registryMethod() {
GET_UNBOUNDONG: {name: "getunboundong", handler: rest.GetUnboundOng},
GET_MEMPOOL_TXCOUNT: {name: "getmempooltxcount", handler: rest.GetMemPoolTxCount},
GET_MEMPOOL_TXSTATE: {name: "getmempooltxstate", handler: rest.GetMemPoolTxState},
GET_VERSION: {name: "getversion", handler: rest.GetNodeVersion},
}

postMethodMap := map[string]Action{
Expand Down
1 change: 1 addition & 0 deletions http/websocket/websocket/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ func (self *WsServer) registryMethod() {
"getunboundong": {handler: rest.GetUnboundOng},
"getmempooltxcount": {handler: rest.GetMemPoolTxCount},
"getmempooltxstate": {handler: rest.GetMemPoolTxState},
"getversion": {handler: rest.GetNodeVersion},

"getsessioncount": {handler: getsessioncount},
}
Expand Down

0 comments on commit 580dcd5

Please sign in to comment.