Skip to content

Commit

Permalink
Fix the accounting for batch size (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianoaix authored Nov 29, 2023
1 parent 2d6fa93 commit 1b5e808
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 := int64(0)
for _, blob := range blobs {
batchSize += blob.BlobHeader.EncodedSizeAllQuorums()
batchSize += blob.Bundles.Size()

Check failure on line 239 in node/node.go

View workflow job for this annotation

GitHub Actions / Linter

invalid operation: batchSize += blob.Bundles.Size() (mismatched types int64 and int) (typecheck)

Check failure on line 239 in node/node.go

View workflow job for this annotation

GitHub Actions / Linter

invalid operation: batchSize += blob.Bundles.Size() (mismatched types int64 and int)) (typecheck)

Check failure on line 239 in node/node.go

View workflow job for this annotation

GitHub Actions / Linter

invalid operation: batchSize += blob.Bundles.Size() (mismatched types int64 and int)) (typecheck)

Check failure on line 239 in node/node.go

View workflow job for this annotation

GitHub Actions / Linter

invalid operation: batchSize += blob.Bundles.Size() (mismatched types int64 and int)) (typecheck)
}
n.Metrics.AcceptBatches("received", batchSize)

Expand Down

0 comments on commit 1b5e808

Please sign in to comment.