[state] add function to get initial data from contract storage
@@ -91,7 +91,7 @@ func (st *ContractState) SetData(key, value []byte) error {
return nil
}
-// GetData returns the value corresponding to the key from the storage.
+// GetData returns the value corresponding to the key from the buffered storage.
func (st *ContractState) GetData(key []byte) ([]byte, error) {
id := types.GetHashID(key)
if entry := st.storage.get(id); entry != nil {
@@ -100,7 +100,11 @@ func (st *ContractState) GetData(key []byte) ([]byte, error) {
}
return nil, nil
}
- dkey, err := st.storage.trie.Get(id[:])
+ return st.getInitialData(id[:])
+}
+
+func (st *ContractState) getInitialData(id []byte) ([]byte, error) {
+ dkey, err := st.storage.trie.Get(id)
if err != nil {
return nil, err
}
@@ -114,6 +118,12 @@ func (st *ContractState) GetData(key []byte) ([]byte, error) {
return value, nil
}
+// GetInitialData returns the value corresponding to the key from the contract storage.
+func (st *ContractState) GetInitialData(key []byte) ([]byte, error) {
+ id := types.GetHashID(key)
+ return st.getInitialData(id[:])
+}
+
// DeleteData remove key and value pair from the storage.
func (st *ContractState) DeleteData(key []byte) error {
st.storage.put(newValueEntryDelete(types.GetHashID(key)))
