Skip to content

Commit

Permalink
Fix the accounting for batch size
Browse files Browse the repository at this point in the history
  • Loading branch information
jianoaix committed Nov 29, 2023
1 parent cefcf3e commit 4c80cba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions core/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,14 @@ func (cb Bundles) Serialize() ([][][]byte, error) {
}
return data, nil
}

// Returns the size of the bundles in bytes.
func (cb Bundles) Size() int {
size := 0
for _, bundle := range cb {
for _, chunk := range bundle {
size += chunk.Size()
}
}
return size
}
2 changes: 1 addition & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (n *Node) ProcessBatch(ctx context.Context, header *core.BatchHeader, blobs
// Measure num batches received and its size in bytes
batchSize := 0
for _, blob := range blobs {
batchSize += blob.BlobHeader.EncodedSizeAllQuorums()
batchSize += blob.Bundles.Size()
}
n.Metrics.AcceptBatches("received", batchSize)

Expand Down

0 comments on commit 4c80cba

Please sign in to comment.