Skip to content

Commit

Permalink
Add methods for block details
Browse files Browse the repository at this point in the history
  • Loading branch information
pustovalov committed Apr 25, 2024
1 parent 7750000 commit 8390aad
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions near.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,40 @@ func (c *Connection) Block() (map[string]interface{}, error) {
return r, nil
}

// Block with given blockHash queries network and returns block with given hash.
//
// For details see https://docs.near.org/api/rpc/block-chunk#block-details
func (c *Connection) GetBlockByHash(blockHash string) (map[string]interface{}, error) {
res, err := c.call("block", map[string]string{
"block_id": blockHash,
})
if err != nil {
return nil, err
}
r, ok := res.(map[string]interface{})
if !ok {
return nil, ErrNotObject
}
return r, nil
}

// Block with given blockId queries network and returns block with given ID.
//
// For details see https://docs.near.org/api/rpc/block-chunk#block-details
func (c *Connection) GetBlockByID(blockID uint64) (map[string]interface{}, error) {
res, err := c.call("block", map[string]interface{}{
"block_id": blockID,
})
if err != nil {
return nil, err
}
r, ok := res.(map[string]interface{})
if !ok {
return nil, ErrNotObject
}
return r, nil
}

// GetNodeStatus returns general status of a given node.
//
// For details see
Expand Down

0 comments on commit 8390aad

Please sign in to comment.