Skip to content

Commit c688a54

Browse files
committed
nits
Signed-off-by: Sam Batschelet <[email protected]>
1 parent 1d7c146 commit c688a54

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

chain/processor.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type fetchData struct {
2020

2121
type txData struct {
2222
tx *Transaction
23-
storage map[[tstate.MapKeyLength]byte][]byte
23+
storage map[tstate.Key][]byte
2424
}
2525

2626
type Processor struct {
@@ -49,9 +49,9 @@ func (p *Processor) Prefetch(ctx context.Context, db Database) {
4949
defer span.End()
5050

5151
// Store required keys for each set
52-
alreadyFetched := make(map[[tstate.MapKeyLength]byte]*fetchData, len(p.blk.GetTxs()))
52+
alreadyFetched := make(map[tstate.Key]*fetchData, len(p.blk.GetTxs()))
5353
for _, tx := range p.blk.GetTxs() {
54-
storage := map[[65]byte][]byte{}
54+
storage := map[tstate.Key][]byte{}
5555
for _, k := range tx.StateKeys(sm) {
5656
sk := tstate.ToStateKeyArray(k)
5757
if v, ok := alreadyFetched[sk]; ok {

tstate/tstate.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import (
88
"context"
99
"errors"
1010

11-
"github.com/ava-labs/avalanchego/database"
12-
"github.com/ava-labs/avalanchego/trace"
1311
"go.opentelemetry.io/otel/attribute"
1412
oteltrace "go.opentelemetry.io/otel/trace"
13+
14+
"github.com/ava-labs/avalanchego/database"
15+
"github.com/ava-labs/avalanchego/trace"
1516
)
1617

1718
type op struct {

tstate/tstate_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func TestFetchAndSetScope(t *testing.T) {
122122
}
123123
err := ts.FetchAndSetScope(ctx, keys, db)
124124
require.NoError(err, "Error thrown.")
125-
require.Equal(0, ts.OpIndex(), "Opertions not updated correctly.")
125+
require.Equal(0, ts.OpIndex(), "Operations not updated correctly.")
126126
require.Equal(keys, ts.scope, "Scope not updated correctly.")
127127
// Check values
128128
for i, key := range keys {
@@ -146,7 +146,7 @@ func TestFetchAndSetScopeMissingKey(t *testing.T) {
146146
}
147147
err := ts.FetchAndSetScope(ctx, keys, db)
148148
require.NoError(err, "Error thrown.")
149-
require.Equal(0, ts.OpIndex(), "Opertions not updated correctly.")
149+
require.Equal(0, ts.OpIndex(), "Operations not updated correctly.")
150150
require.Equal(keys, ts.scope, "Scope not updated correctly.")
151151
// Check values
152152
for i, key := range keys[:len(keys)-1] {
@@ -178,20 +178,20 @@ func TestRemoveInsertRollback(t *testing.T) {
178178
v, err := ts.GetValue(ctx, TestKey)
179179
require.NoError(err)
180180
require.Equal(TestVal, v)
181-
require.Equal(1, ts.OpIndex(), "Opertions not updated correctly.")
181+
require.Equal(1, ts.OpIndex(), "Operations not updated correctly.")
182182
// Remove
183183
err = ts.Remove(ctx, TestKey)
184184
require.NoError(err, "Error from remove.")
185185
_, err = ts.GetValue(ctx, TestKey)
186186
require.ErrorIs(err, database.ErrNotFound, "Key not deleted from storage.")
187-
require.Equal(2, ts.OpIndex(), "Opertions not updated correctly.")
187+
require.Equal(2, ts.OpIndex(), "Operations not updated correctly.")
188188
// Insert
189189
err = ts.Insert(ctx, TestKey, TestVal)
190190
require.NoError(err, "Error from insert.")
191191
v, err = ts.GetValue(ctx, TestKey)
192192
require.NoError(err)
193193
require.Equal(TestVal, v)
194-
require.Equal(3, ts.OpIndex(), "Opertions not updated correctly.")
194+
require.Equal(3, ts.OpIndex(), "Operations not updated correctly.")
195195
require.Equal(1, ts.PendingChanges())
196196
// Rollback
197197
ts.Rollback(ctx, 2)
@@ -327,7 +327,7 @@ func TestWriteChanges(t *testing.T) {
327327
}
328328

329329
func BenchmarkFetchAndSetScope(b *testing.B) {
330-
for _, size := range []int{10, 100, 1000} {
330+
for _, size := range []int{4, 8, 16, 32, 64, 128} {
331331
b.Run(fmt.Sprintf("fetch_and_set_scope_%d_keys", size), func(b *testing.B) {
332332
benchmarkFetchAndSetScope(b, size)
333333
})

0 commit comments

Comments
 (0)