-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pvtData APIs are not allowed in chaincode Init()
private data APIs are not allowed in Init() since the private data collection configuration is not yet committed on the channel. This CR provide a better error message indicating that pvtdata APIs are not allowed in chaincode Init(). FAB-13050 #done Change-Id: I6e6a8abdf1f35f56307be90d8b6b2830c8f35755 Signed-off-by: senthil <cendhu@gmail.com>
- Loading branch information
Showing
8 changed files
with
239 additions
and
8 deletions.
There are no files selected for viewing
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
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
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
38 changes: 38 additions & 0 deletions
38
core/chaincode/testdata/chaincode/init_private_data/init_private_data.go
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hyperledger/fabric/core/chaincode/shim" | ||
pb "github.com/hyperledger/fabric/protos/peer" | ||
) | ||
|
||
// SimpleChaincode example simple Chaincode implementation | ||
type SimpleChaincode struct { | ||
} | ||
|
||
// Init initializes a private state | ||
func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response { | ||
if err := stub.PutPrivateData("dummyColl", "dummyKey", []byte("dummyValue")); err != nil { | ||
return shim.Error(fmt.Sprintf("put operation failed. Error storing state: %s", err)) | ||
} | ||
return shim.Success(nil) | ||
} | ||
|
||
// Invoke is a no-op | ||
func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response { | ||
return shim.Success(nil) | ||
} | ||
|
||
func main() { | ||
err := shim.Start(new(SimpleChaincode)) | ||
if err != nil { | ||
fmt.Printf("Error starting chaincode: %s", err) | ||
} | ||
} |
Oops, something went wrong.