github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/tm2/pkg/store/immut/store.go (about)

     1  package immut
     2  
     3  import (
     4  	"github.com/gnolang/gno/tm2/pkg/store/cache"
     5  	"github.com/gnolang/gno/tm2/pkg/store/types"
     6  )
     7  
     8  var _ types.Store = immutStore{}
     9  
    10  type immutStore struct {
    11  	parent types.Store
    12  }
    13  
    14  func New(parent types.Store) immutStore {
    15  	return immutStore{
    16  		parent: parent,
    17  	}
    18  }
    19  
    20  // Implements Store
    21  func (is immutStore) Get(key []byte) []byte {
    22  	return is.parent.Get(key)
    23  }
    24  
    25  // Implements Store
    26  func (is immutStore) Has(key []byte) bool {
    27  	return is.parent.Has(key)
    28  }
    29  
    30  // Implements Store
    31  func (is immutStore) Set(key, value []byte) {
    32  	panic("unexpected .Set() on immutStore")
    33  }
    34  
    35  // Implements Store
    36  func (is immutStore) Delete(key []byte) {
    37  	panic("unexpected .Delete() on immutStore")
    38  }
    39  
    40  // Implements Store
    41  func (is immutStore) Iterator(start, end []byte) types.Iterator {
    42  	return is.parent.Iterator(start, end)
    43  }
    44  
    45  // Implements Store
    46  func (is immutStore) ReverseIterator(start, end []byte) types.Iterator {
    47  	return is.parent.ReverseIterator(start, end)
    48  }
    49  
    50  // Implements Store
    51  func (is immutStore) CacheWrap() types.Store {
    52  	return cache.New(is)
    53  }
    54  
    55  // Implements Store
    56  func (is immutStore) Write() {
    57  	panic("unexpected .Write() on immutStore")
    58  }