-
Notifications
You must be signed in to change notification settings - Fork 34
/
getblock.go
37 lines (33 loc) · 1.09 KB
/
getblock.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package daemonManager
import (
"encoding/json"
"fmt"
)
type GetBlock struct {
Hash string `json:"hash"`
Confirmations int `json:"confirmations"`
Strippedsize int `json:"strippedsize"`
Size int `json:"size"`
Weight int `json:"weight"`
Height int `json:"height"`
Version int `json:"version"`
VersionHex string `json:"versionHex"`
Merkleroot string `json:"merkleroot"`
Tx []string `json:"tx"`
Time int `json:"time"`
Mediantime int `json:"mediantime"`
Nonce int `json:"nonce"`
Bits string `json:"bits"`
Difficulty float64 `json:"difficulty"`
Chainwork string `json:"chainwork"`
NTx int `json:"nTx"`
Previousblockhash string `json:"previousblockhash"`
}
func BytesToGetBlock(b []byte) *GetBlock {
var getBlock GetBlock
err := json.Unmarshal(b, &getBlock)
if err != nil {
log.Fatal(fmt.Sprint("getblock call failed with error ", err))
}
return &getBlock
}