Implement getSlice API #206

Merged
prathamesh0 merged 21 commits from pm-get-slice into v4 2022-12-19 08:42:23 +00:00
Showing only changes of commit 8e4d67fcd1 - Show all commits

View File

@ -17,6 +17,7 @@
package eth package eth
import ( import (
"bytes"
"context" "context"
"database/sql" "database/sql"
"errors" "errors"
@ -932,6 +933,11 @@ func (b *Backend) getSliceStem(headPath []byte, t state.Trie, response *GetSlice
it, timeTaken := getIteratorAtPath(t, startPath) it, timeTaken := getIteratorAtPath(t, startPath)
metaData.trieLoadingTime += timeTaken metaData.trieLoadingTime += timeTaken
// Skip if iterator not at required path (might happen if node not present at given path)
if !bytes.Equal(it.Path(), startPath) {
continue
}
sliceNodeMetrics, err := fillSliceNodeData(b.EthDB, b.StateDatabase.TrieDB(), response.TrieNodes.Stem, response.Leaves, it, storage) sliceNodeMetrics, err := fillSliceNodeData(b.EthDB, b.StateDatabase.TrieDB(), response.TrieNodes.Stem, response.Leaves, it, storage)
if err != nil { if err != nil {
return err return err
@ -956,6 +962,11 @@ func (b *Backend) getSliceHead(headPath []byte, t state.Trie, response *GetSlice
it, timeTaken := getIteratorAtPath(t, headPath) it, timeTaken := getIteratorAtPath(t, headPath)
metaData.trieLoadingTime += timeTaken metaData.trieLoadingTime += timeTaken
// Skip if iterator not at required path (might happen if node not present at given path)
if !bytes.Equal(it.Path(), headPath) {
return nil
}
sliceNodeMetrics, err := fillSliceNodeData(b.EthDB, b.StateDatabase.TrieDB(), response.TrieNodes.Head, response.Leaves, it, storage) sliceNodeMetrics, err := fillSliceNodeData(b.EthDB, b.StateDatabase.TrieDB(), response.TrieNodes.Head, response.Leaves, it, storage)
if err != nil { if err != nil {
return err return err