Skip to content

Commit

Permalink
Add block size in bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
danil-lashin committed Sep 8, 2018
1 parent 4e7639a commit 26a2f05
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

- [api] Add validators rewards to block api

## 0.3.3
*Sept 8th, 2018*

IMPROVEMENT

- [api] Add block size in bytes

## 0.3.2
*Sept 8th, 2018*

Expand Down
6 changes: 6 additions & 0 deletions api/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type BlockResponse struct {
Transactions []BlockTransactionResponse `json:"transactions"`
Precommits json.RawMessage `json:"precommits"`
BlockReward string `json:"block_reward"`
Size int `json:"size"`
}

type BlockTransactionResponse struct {
Expand Down Expand Up @@ -93,6 +94,10 @@ func Block(w http.ResponseWriter, r *http.Request) {

precommits, _ := cdc.MarshalJSON(block.Block.LastCommit.Precommits)

encodedBlock, _ := cdc.MarshalBinary(block)

size := len(encodedBlock)

response := BlockResponse{
Hash: block.Block.Hash(),
Height: block.Block.Height,
Expand All @@ -102,6 +107,7 @@ func Block(w http.ResponseWriter, r *http.Request) {
Transactions: txs,
Precommits: json.RawMessage(precommits),
BlockReward: rewards.GetRewardForBlock(uint64(height)).String(),
Size: size,
}

err = json.NewEncoder(w).Encode(Response{
Expand Down
4 changes: 2 additions & 2 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ package version
const (
Maj = "0"
Min = "3"
Fix = "2"
Fix = "3"
)

var (
// Must be a string because scripts like dist.sh read this file.
Version = "0.3.2"
Version = "0.3.3"

// GitCommit is the current HEAD set using ldflags.
GitCommit string
Expand Down

0 comments on commit 26a2f05

Please sign in to comment.