Skip to content
This repository was archived by the owner on Jun 25, 2025. It is now read-only.

[tstate] inline byte to string conversions #174

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[processor] inline all byte to string conversions
Signed-off-by: Sam Batschelet <[email protected]>
  • Loading branch information
hexfusion committed May 19, 2023
commit 0c7bef58b146c10d8831e34b9bc85e188ee208a9
11 changes: 5 additions & 6 deletions chain/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,21 @@ func (p *Processor) Prefetch(ctx context.Context, db Database) {
for _, tx := range p.blk.GetTxs() {
storage := map[string][]byte{}
for _, k := range tx.StateKeys(sm) {
sk := string(k)
if v, ok := alreadyFetched[sk]; ok {
if v, ok := alreadyFetched[string(k)]; ok {
if v.exists {
storage[sk] = v.v
storage[string(k)] = v.v
}
continue
}
v, err := db.GetValue(ctx, k)
if errors.Is(err, database.ErrNotFound) {
alreadyFetched[sk] = &fetchData{nil, false}
alreadyFetched[string(k)] = &fetchData{nil, false}
continue
} else if err != nil {
panic(err)
}
alreadyFetched[sk] = &fetchData{v, true}
storage[sk] = v
alreadyFetched[string(k)] = &fetchData{v, true}
storage[string(k)] = v
}
p.readyTxs <- &txData{tx, storage}
}
Expand Down