Skip to content

Commit

Permalink
gidlid cleanup & lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbundalo committed Mar 22, 2024
1 parent 4e6cd79 commit c2dd121
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions blockchain/storage/leveldb/leveldb_perf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func prepareBatch(t *testing.T, s storage.Storage, b *types.FullBlock) *storage.

batchWriter := storage.NewBatchWriter(s)

// GidLid 'sorted'
// Lookup 'sorted'
batchWriter.PutHeadHash(b.Block.Header.Hash)
batchWriter.PutHeadNumber(b.Block.Number())

Expand Down Expand Up @@ -205,7 +205,7 @@ func TestWriteBlockPerf(t *testing.T) {
}

d := time.Since(tn)
watchTime = watchTime + d.Milliseconds()
watchTime += d.Milliseconds()
}

time.Sleep(time.Second)
Expand Down Expand Up @@ -234,7 +234,7 @@ func TestReadBlockPerf(t *testing.T) {
_, err4 := s.ReadReceipts(h)
d := time.Since(tn)

watchTime = watchTime + d.Milliseconds()
watchTime += d.Milliseconds()

if !ok || err2 != nil || err3 != nil || err4 != nil {
t.Logf("\terror")
Expand Down
14 changes: 7 additions & 7 deletions blockchain/storagev2/leveldb/leveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var tableMapper = map[uint8][]byte{
storagev2.RECEIPTS: []byte("r"), // DB key = block number + block hash + mapper, value = block receipts
storagev2.CANONICAL: {}, // DB key = block number + mapper, value = block hash

// GidLid DB
// Lookup DB
storagev2.FORK: {}, // DB key = FORK_KEY + mapper, value = fork hashes
storagev2.HEAD_HASH: {}, // DB key = HEAD_HASH_KEY + mapper, value = head hash
storagev2.HEAD_NUMBER: {}, // DB key = HEAD_NUMBER_KEY + mapper, value = head number
Expand All @@ -39,26 +39,26 @@ func NewLevelDBStorage(path string, logger hclog.Logger) (*storagev2.Storage, er
WriteBuffer: 128 * opt.MiB, // Two of these are used internally
}

db, err := openLevelDBStorage(path, options)
maindb, err := openLevelDBStorage(path, options)
if err != nil {
return nil, err
}

// Open GidLid
// Open Lookup
// Set default options
options = &opt.Options{
BlockCacheCapacity: 64 * opt.MiB,
WriteBuffer: opt.DefaultWriteBuffer,
}
path = path + "/gidlid"
path += "/lookup"

gidlid, err := openLevelDBStorage(path, options)
lookup, err := openLevelDBStorage(path, options)
if err != nil {
return nil, err
}

ldbs[0] = &levelDB{db}
ldbs[1] = &levelDB{gidlid}
ldbs[0] = &levelDB{maindb}
ldbs[1] = &levelDB{lookup}

return storagev2.Open(logger.Named("leveldb"), ldbs)
}
Expand Down
4 changes: 2 additions & 2 deletions blockchain/storagev2/leveldb/leveldb_perf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestWriteBlockPerf(t *testing.T) {
require.NoError(t, batchWriter.WriteBatch())

d := time.Since(tn)
watchTime = watchTime + d.Milliseconds()
watchTime += d.Milliseconds()
}

time.Sleep(time.Second)
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestReadBlockPerf(t *testing.T) {
b, err5 := s.ReadBlockLookup(h)
d := time.Since(tn)

watchTime = watchTime + d.Milliseconds()
watchTime += d.Milliseconds()

if !ok || err1 != nil || err3 != nil || err4 != nil || err5 != nil {
t.Logf("\terror")
Expand Down
4 changes: 2 additions & 2 deletions blockchain/storagev2/mdbx/mdbx_perf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestWriteBlockPerf(t *testing.T) {
require.NoError(t, batchWriter.WriteBatch())

d := time.Since(tn)
watchTime = watchTime + d.Milliseconds()
watchTime += d.Milliseconds()
}

time.Sleep(time.Second)
Expand Down Expand Up @@ -81,7 +81,7 @@ func TestReadBlockPerf(t *testing.T) {
b, err5 := s.ReadBlockLookup(h)
d := time.Since(tn)

watchTime = watchTime + d.Milliseconds()
watchTime += d.Milliseconds()

if !ok || err1 != nil || err3 != nil || err4 != nil || err5 != nil {
t.Logf("\terror")
Expand Down
2 changes: 1 addition & 1 deletion blockchain/storagev2/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const (
RECEIPTS = uint8(8)
)

// GidLid tables
// Lookup tables
const (
FORK = uint8(0) | LOOKUP_INDEX
HEAD_HASH = uint8(2) | LOOKUP_INDEX
Expand Down
2 changes: 1 addition & 1 deletion blockchain/storagev2/testing_perf.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func PrepareBatch(t *testing.T, s *Storage, b *types.FullBlock) *Writer {

batchWriter := s.NewWriter()

// GidLid 'sorted'
// Lookup 'sorted'
batchWriter.PutHeadHash(b.Block.Header.Hash)
batchWriter.PutHeadNumber(b.Block.Number())
batchWriter.PutBlockLookup(b.Block.Hash(), b.Block.Number())
Expand Down

0 comments on commit c2dd121

Please sign in to comment.