(hashOrHeight interface{})
| 525 | } |
| 526 | |
| 527 | func GetBlockData(hashOrHeight interface{}) ([]byte, error) { |
| 528 | data, ontErr := sendRpcRequest("getblock", []interface{}{hashOrHeight}) |
| 529 | if ontErr != nil { |
| 530 | switch ontErr.ErrorCode { |
| 531 | case ERROR_INVALID_PARAMS: |
| 532 | return nil, fmt.Errorf("invalid block hash or block height:%v", hashOrHeight) |
| 533 | } |
| 534 | return nil, ontErr.Error |
| 535 | } |
| 536 | hexStr := "" |
| 537 | err := json.Unmarshal(data, &hexStr) |
| 538 | if err != nil { |
| 539 | return nil, fmt.Errorf("json.Unmarshal error:%s", err) |
| 540 | } |
| 541 | blockData, err := hex.DecodeString(hexStr) |
| 542 | if err != nil { |
| 543 | return nil, fmt.Errorf("hex.DecodeString error:%s", err) |
| 544 | } |
| 545 | return blockData, nil |
| 546 | } |
| 547 | |
| 548 | func GetBlockCount() (uint32, error) { |
| 549 | data, ontErr := sendRpcRequest("getblockcount", []interface{}{}) |
no test coverage detected