Skip to content

Commit

Permalink
Fix update bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bandreghetti committed Sep 8, 2020
1 parent 033edf0 commit 8f08ec7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions assets/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,9 @@ import (
"github.com/hyperledger/fabric/core/chaincode/shim"
)

// Put inserts asset in blockchain
func (a *Asset) Put(stub shim.ChaincodeStubInterface) (map[string]interface{}, errors.ICCError) {
// Check if org has write permission
err := a.CheckWriters(stub)
if err != nil {
return nil, errors.WrapError(err, "failed write permission check")
}

func (a *Asset) put(stub shim.ChaincodeStubInterface) (map[string]interface{}, errors.ICCError) {
// Write index of references this asset points to
err = a.putRefs(stub)
err := a.putRefs(stub)
if err != nil {
return nil, errors.WrapError(err, "failed writing reference index")
}
Expand Down Expand Up @@ -57,6 +50,17 @@ func (a *Asset) Put(stub shim.ChaincodeStubInterface) (map[string]interface{}, e
return *a, nil
}

// Put inserts asset in blockchain
func (a *Asset) Put(stub shim.ChaincodeStubInterface) (map[string]interface{}, errors.ICCError) {
// Check if org has write permission
err := a.CheckWriters(stub)
if err != nil {
return nil, errors.WrapError(err, "failed write permission check")
}

return a.put(stub)
}

// PutNew inserts asset in blockchain and returns error if asset exists
func (a *Asset) PutNew(stub shim.ChaincodeStubInterface) (map[string]interface{}, errors.ICCError) {
// Check if asset already exists
Expand Down
2 changes: 1 addition & 1 deletion assets/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (a *Asset) Update(stub shim.ChaincodeStubInterface, update map[string]inter
return nil, errors.WrapError(err, "failed injecting asset metadata")
}

ret, err := a.Put(stub)
ret, err := a.put(stub)
if err != nil {
return nil, errors.WrapError(err, "failed putting asset in ledger")
}
Expand Down

0 comments on commit 8f08ec7

Please sign in to comment.