-
Notifications
You must be signed in to change notification settings - Fork 9
/
api_ledger.go
71 lines (55 loc) · 1.72 KB
/
api_ledger.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package blockfrost
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
)
var (
resourceGenesis = "genesis"
)
// GenesisBlock contains the information of the genesis block of the network.
type GenesisBlock struct {
// The proportion of slots in which blocks should be issued
ActiveSlotsCoefficient float32 `json:"active_slots_coefficient"`
// Determines the quorum needed for votes on the protocol parameter updates
UpdateQuorum float32 `json:"update_quorum"`
// The total number of lovelace in the system
MaxLovelaceSupply string `json:"max_lovelace_supply"`
// Network identifier
NetworkMagic int `json:"network_magic"`
// Number of slots in an epoch
EpochLength int `json:"epoch_length"`
// Time of slot 0 in UNIX time
SystemStart int `json:"system_start"`
// Number of slots in an KES period
SlotsPerKesPeriod int `json:"slots_per_kes_period"`
// Duration of one slot in seconds
SlotLength int `json:"slot_length"`
// The maximum number of time a KES key can be evolved before
// a pool operator must create a new operational certificate
MaxKesEvolutions int `json:"max_kes_evolutions"`
// Security parameter k
SecurityParam int `json:"security_param"`
}
// Genesis returns the information about blockchain genesis.
func (c *apiClient) Genesis(ctx context.Context) (gen GenesisBlock, err error) {
requestUrl, err := url.Parse(fmt.Sprintf("%s/%s", c.server, resourceGenesis))
if err != nil {
return
}
req, err := http.NewRequestWithContext(ctx, http.MethodGet, requestUrl.String(), nil)
if err != nil {
return
}
res, err := c.handleRequest(req)
if err != nil {
return
}
defer res.Body.Close()
if err = json.NewDecoder(res.Body).Decode(&gen); err != nil {
return
}
return gen, nil
}