Extend the load report tool to include transactions' hashes (backport #9509) (#9514)

* Extend the load report tool to include transactions' hashes (#9509)

* Add transaction hash to raw data

* Add hash in formatted output

* Cosmetic

(cherry picked from commit cdd3479f20)

# Conflicts:
#	test/loadtime/cmd/report/main.go

* Resolve conflict

* Appease linter

Co-authored-by: Sergio Mena <sergio@informal.systems>
This commit is contained in:
mergify[bot]
2022-10-05 21:56:34 +02:00
committed by GitHub
co-authored by Sergio Mena
parent bda1dd4734
commit df5ba80914
2 changed files with 9 additions and 6 deletions
+7 -4
View File
@@ -25,6 +25,7 @@ type BlockStore interface {
type DataPoint struct {
Duration time.Duration
BlockTime time.Time
Hash []byte
}
// Report contains the data calculated from reading the timestamped transactions
@@ -68,7 +69,7 @@ func (rs *Reports) ErrorCount() int {
return rs.errorCount
}
func (rs *Reports) addDataPoint(id uuid.UUID, l time.Duration, bt time.Time, conns, rate, size uint64) {
func (rs *Reports) addDataPoint(id uuid.UUID, l time.Duration, bt time.Time, hash []byte, conns, rate, size uint64) {
r, ok := rs.s[id]
if !ok {
r = Report{
@@ -81,7 +82,7 @@ func (rs *Reports) addDataPoint(id uuid.UUID, l time.Duration, bt time.Time, con
}
rs.s[id] = r
}
r.All = append(r.All, DataPoint{Duration: l, BlockTime: bt})
r.All = append(r.All, DataPoint{Duration: l, BlockTime: bt, Hash: hash})
if l > r.Max {
r.Max = l
}
@@ -123,11 +124,12 @@ func GenerateFromBlockStore(s BlockStore) (*Reports, error) {
id uuid.UUID
l time.Duration
bt time.Time
hash []byte
connections, rate, size uint64
err error
}
type txData struct {
tx []byte
tx types.Tx
bt time.Time
}
reports := &Reports{
@@ -161,6 +163,7 @@ func GenerateFromBlockStore(s BlockStore) (*Reports, error) {
pdc <- payloadData{
l: l,
bt: b.bt,
hash: b.tx.Hash(),
id: uuid.UUID(*idb),
connections: p.Connections,
rate: p.Rate,
@@ -202,7 +205,7 @@ func GenerateFromBlockStore(s BlockStore) (*Reports, error) {
reports.addError()
continue
}
reports.addDataPoint(pd.id, pd.l, pd.bt, pd.connections, pd.rate, pd.size)
reports.addDataPoint(pd.id, pd.l, pd.bt, pd.hash, pd.connections, pd.rate, pd.size)
}
reports.calculateAll()
return reports, nil