Skip to content

Commit e19eb04

Browse files
Feature: node RPC metadata endpoint
1 parent a9e619f commit e19eb04

File tree

2 files changed

+63
-2
lines changed

2 files changed

+63
-2
lines changed

node/data.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,58 @@ type Endorsement struct {
176176
type EndorsementOperation struct {
177177
Level uint64 `json:"level"`
178178
}
179+
180+
// HeadMetadata -
181+
type HeadMetadata struct {
182+
Protocol string `json:"protocol"`
183+
NextProtocol string `json:"next_protocol"`
184+
TestChainStatus struct {
185+
Status string `json:"status"`
186+
} `json:"test_chain_status"`
187+
MaxOperationsTTL uint64 `json:"max_operations_ttl"`
188+
MaxOperationDataLength uint64 `json:"max_operation_data_length"`
189+
MaxBlockHeaderLength uint64 `json:"max_block_header_length"`
190+
MaxOperationListLength []struct {
191+
MaxSize uint64 `json:"max_size"`
192+
MaxOp uint64 `json:"max_op,omitempty"`
193+
} `json:"max_operation_list_length"`
194+
Baker string `json:"baker"`
195+
Level struct {
196+
Level uint64 `json:"level"`
197+
LevelPosition uint64 `json:"level_position"`
198+
Cycle uint64 `json:"cycle"`
199+
CyclePosition uint64 `json:"cycle_position"`
200+
VotingPeriod uint64 `json:"voting_period"`
201+
VotingPeriodPosition uint64 `json:"voting_period_position"`
202+
ExpectedCommitment bool `json:"expected_commitment"`
203+
} `json:"level"`
204+
LevelInfo struct {
205+
Level uint64 `json:"level"`
206+
LevelPosition uint64 `json:"level_position"`
207+
Cycle uint64 `json:"cycle"`
208+
CyclePosition uint64 `json:"cycle_position"`
209+
ExpectedCommitment bool `json:"expected_commitment"`
210+
} `json:"level_info"`
211+
VotingPeriodKind string `json:"voting_period_kind"`
212+
VotingPeriodInfo struct {
213+
VotingPeriod struct {
214+
Index uint64 `json:"index"`
215+
Kind string `json:"kind"`
216+
StartPosition uint64 `json:"start_position"`
217+
} `json:"voting_period"`
218+
Position int `json:"position"`
219+
Remaining int `json:"remaining"`
220+
} `json:"voting_period_info"`
221+
NonceHash interface{} `json:"nonce_hash"`
222+
ConsumedGas string `json:"consumed_gas"`
223+
Deactivated []interface{} `json:"deactivated"`
224+
BalanceUpdates []struct {
225+
Kind string `json:"kind"`
226+
Contract string `json:"contract,omitempty"`
227+
Change string `json:"change"`
228+
Origin string `json:"origin"`
229+
Category string `json:"category,omitempty"`
230+
Delegate string `json:"delegate,omitempty"`
231+
Cycle uint64 `json:"cycle,omitempty"`
232+
} `json:"balance_updates"`
233+
}

node/node.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,14 @@ func (rpc *NodeRPC) Constants() (constants Constants, err error) {
7979
return
8080
}
8181

82-
// Head -
83-
func (rpc *NodeRPC) Head() (head Header, err error) {
82+
// Header -
83+
func (rpc *NodeRPC) Header() (head Header, err error) {
8484
err = rpc.get("chains/main/blocks/head/header", &head)
8585
return
8686
}
87+
88+
// HeadMetadata -
89+
func (rpc *NodeRPC) HeadMetadata() (head HeadMetadata, err error) {
90+
err = rpc.get("chains/main/blocks/head/metadata", &head)
91+
return
92+
}

0 commit comments

Comments
 (0)