Skip to content

Commit

Permalink
extending the state reader - bad idea?
Browse files Browse the repository at this point in the history
  • Loading branch information
pnowosie committed Oct 10, 2024
1 parent 9b63bfd commit 03a531d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
21 changes: 21 additions & 0 deletions blockchain/pending.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package blockchain

import (
"errors"
"github.com/NethermindEth/juno/core"
"github.com/NethermindEth/juno/core/felt"
"github.com/NethermindEth/juno/core/trie"
)

type Pending struct {
Expand Down Expand Up @@ -65,3 +67,22 @@ func (p *PendingState) Class(classHash *felt.Felt) (*core.DeclaredClass, error)

return p.head.Class(classHash)
}

// Note[pnowosie]: Maybe extending StateReader with the following methods was not a good idea?
func (s *PendingState) ClassTrie() (*trie.Trie, func() error, error) {
return nil, nopCloser, featureNotImplemented
}
func (s *PendingState) StorageTrie() (*trie.Trie, func() error, error) {
return nil, nopCloser, featureNotImplemented
}
func (s *PendingState) StorageTrieForAddr(*felt.Felt) (*trie.Trie, error) {
return nil, featureNotImplemented
}
func (s *PendingState) StateAndClassRoot() (*felt.Felt, *felt.Felt, error) {
return nil, nil, featureNotImplemented
}

var (
featureNotImplemented = errors.New("feature not implemented for a historical state")
nopCloser = func() error { return nil }
)
20 changes: 20 additions & 0 deletions core/state_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package core

import (
"errors"
"github.com/NethermindEth/juno/core/trie"

"github.com/NethermindEth/juno/core/felt"
"github.com/NethermindEth/juno/db"
Expand Down Expand Up @@ -87,3 +88,22 @@ func (s *stateSnapshot) Class(classHash *felt.Felt) (*DeclaredClass, error) {
}
return declaredClass, nil
}

// Note[pnowosie]: Maybe extending StateReader with the following methods was not a good idea?
func (s *stateSnapshot) ClassTrie() (*trie.Trie, func() error, error) {
return nil, nopCloser, featureNotImplemented
}
func (s *stateSnapshot) StorageTrie() (*trie.Trie, func() error, error) {
return nil, nopCloser, featureNotImplemented
}
func (s *stateSnapshot) StorageTrieForAddr(*felt.Felt) (*trie.Trie, error) {
return nil, featureNotImplemented
}
func (s *stateSnapshot) StateAndClassRoot() (*felt.Felt, *felt.Felt, error) {
return nil, nil, featureNotImplemented
}

var (
featureNotImplemented = errors.New("feature not implemented for a historical state")
nopCloser = func() error { return nil }
)

0 comments on commit 03a531d

Please sign in to comment.