Created
April 16, 2019 13:37
-
-
Save aschmidt75/fcd2ab098adde44f5411cb7c23343fd3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (r registry) create(stub shim.ChaincodeStubInterface, item interface{}) (string, error) { | |
idStr, err := newID(stub, r.typeStr) | |
if err != nil { | |
return "", errors.New("internal error generating index key") | |
} | |
ck, err := getShipmentKey(stub, idStr) | |
if err != nil { | |
return "", errors.New("internal error generating composite key") | |
} | |
data, err := json.Marshal(&item) | |
if err != nil { | |
return "", errors.New("internal JSON marshal error") | |
} | |
err = stub.PutState(ck, []byte(data)) | |
if err != nil { | |
return "", errors.New("internal error writing world state") | |
} | |
return ck, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment