Skip to content

Commit 5cb88fc

Browse files
committed
is_bootstrapped rpc call
1 parent 2dbee9f commit 5cb88fc

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

client/generate.go

+8
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ var types = []*typeDef{
130130
Func: "Heads",
131131
ResponseType: "Head",
132132
},
133+
{
134+
RequestType: "ChainID",
135+
Method: "GET",
136+
Path: "/chains/{{.}}/is_bootstrapped",
137+
Func: "IsBootstrapped",
138+
ResponseType: "BootstrappedResponse",
139+
AllocMode: ModeAllocate,
140+
},
133141
}
134142

135143
const tplSrc = `package client

client/request_gen.go

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/types.go

+28
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package client
33
//go:generate go run generate.go
44

55
import (
6+
"strconv"
7+
68
tz "github.com/ecadlabs/gotez/v2"
79
"github.com/ecadlabs/gotez/v2/protocol"
810
"github.com/ecadlabs/gotez/v2/protocol/core"
@@ -98,6 +100,32 @@ type Head struct {
98100

99101
type Flag bool
100102

103+
type BootstrappedResponse struct {
104+
Bootstrapped bool
105+
SyncState SyncState
106+
}
107+
108+
type SyncState uint8
109+
110+
const (
111+
SyncStateSynced SyncState = iota
112+
SyncStateUnsynced
113+
SyncStateStuck
114+
)
115+
116+
func (state SyncState) String() string {
117+
switch state {
118+
case SyncStateSynced:
119+
return "synced"
120+
case SyncStateUnsynced:
121+
return "unsynced"
122+
case SyncStateStuck:
123+
return "stuck"
124+
default:
125+
return strconv.FormatUint(uint64(state), 10)
126+
}
127+
}
128+
101129
func newConstants(p *tz.ProtocolHash) (Constants, error) { return protocol.NewConstants(p) }
102130
func newBlockInfo(p *tz.ProtocolHash) (BlockInfo, error) { return protocol.NewBlockInfo(p) }
103131
func newBlockHeaderInfo(p *tz.ProtocolHash) (BlockHeaderInfo, error) {

0 commit comments

Comments
 (0)