MCPcopy Create free account
hub / github.com/DNAProject/DNA / GetBlockByHash

Function GetBlockByHash

http/base/rest/interfaces.go:124–141  ·  view source on GitHub ↗

get block by hash

(cmd map[string]interface{})

Source from the content-addressed store, hash-verified

122
123//get block by hash
124func GetBlockByHash(cmd map[string]interface{}) map[string]interface{} {
125 resp := ResponsePack(berr.SUCCESS)
126 str := cmd["Hash"].(string)
127 if len(str) == 0 {
128 return ResponsePack(berr.INVALID_PARAMS)
129 }
130 var getTxBytes = false
131 if raw, ok := cmd["Raw"].(string); ok && raw == "1" {
132 getTxBytes = true
133 }
134 var hash common.Uint256
135 hash, err := common.Uint256FromHexString(str)
136 if err != nil {
137 return ResponsePack(berr.INVALID_PARAMS)
138 }
139 resp["Result"], resp["Error"] = getBlock(hash, getTxBytes)
140 return resp
141}
142
143//get block height by transaction hash
144func GetBlockHeightByTxHash(cmd map[string]interface{}) map[string]interface{} {

Callers

nothing calls this directly

Calls 2

ResponsePackFunction · 0.85
getBlockFunction · 0.85

Tested by

no test coverage detected