Skip to content

Commit b5855db

Browse files
committed
add delete state in chaincode runtime
1 parent c6d18d8 commit b5855db

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

chaincode/lib/runtime/shim_state_map.go

+5
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ func (w *shimStateMap) SetRaw(key string, raw []byte) error {
4545
}
4646
return w.stub.PutState(w.path+key, raw)
4747
}
48+
49+
func (w *shimStateMap) Delete(key string) error {
50+
return w.stub.DelState(w.path + key)
51+
}
52+
4853
func (w *shimStateMap) Get(key string, m StorageObject) error {
4954

5055
raw, err := w.GetRaw(key)

chaincode/lib/runtime/state.go

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type StateMap interface {
4343
SetRaw(string, []byte) error
4444
Get(string, StorageObject) error
4545
Set(string, StorageObject) error
46+
Delete(string) error
4647
}
4748

4849
//default

chaincode/lib/runtime/state_legacy.go

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ func (w *shimStateMapROLegacy) Set(string, p.Message) error {
7979
return nil
8080
}
8181

82+
func (w *shimStateMapLegacy) Delete(key string) error {
83+
return w.stub.DelState(w.path + key)
84+
}
85+
8286
//default
8387
func NewShimMapLegacy(root string, stub shim.ChaincodeStubInterface, readOnly bool) StateMap_Legacy {
8488
if readOnly {

0 commit comments

Comments
 (0)