Add init function to avoid init function not found error

Signed-off-by: SamYuan1990 <yy19902439@126.com>
This commit is contained in:
SamYuan1990 2020-06-12 20:00:51 +08:00
parent 7b2dcbf2ed
commit 90c0496d23

View file

@ -119,6 +119,9 @@ type SmartContract struct {
contractapi.Contract contractapi.Contract
} }
func (s *SmartContract) Init(ctx contractapi.TransactionContextInterface) error {
return nil
}
// ============================================================ // ============================================================
// initMarble - create a new marble, store into chaincode state // initMarble - create a new marble, store into chaincode state
@ -369,7 +372,6 @@ func (s *SmartContract) TransferMarble(ctx contractapi.TransactionContextInterfa
return fmt.Errorf("failed to unmarshal JSON: %s", err.Error()) return fmt.Errorf("failed to unmarshal JSON: %s", err.Error())
} }
if len(marbleTransferInput.Name) == 0 { if len(marbleTransferInput.Name) == 0 {
return fmt.Errorf("name field must be a non-empty string") return fmt.Errorf("name field must be a non-empty string")
} }
@ -443,7 +445,6 @@ func (s *SmartContract) GetMarblesByRange(ctx contractapi.TransactionContextInte
} }
// =======Rich queries ========================================================================= // =======Rich queries =========================================================================
// Two examples of rich queries are provided below (parameterized query and ad hoc query). // Two examples of rich queries are provided below (parameterized query and ad hoc query).
// Rich queries pass a query string to the state database. // Rich queries pass a query string to the state database.
@ -528,7 +529,7 @@ func (s *SmartContract) getQueryResultForQueryString(ctx contractapi.Transaction
// getMarbleHash - use the public data hash to verify a private marble // getMarbleHash - use the public data hash to verify a private marble
// Result is the hash on the public ledger of a marble stored a private data collection // Result is the hash on the public ledger of a marble stored a private data collection
// =============================================== // ===============================================
func (s *SmartContract) GetMarbleHash(ctx contractapi.TransactionContextInterface, collection string, marbleID string,) (string, error) { func (s *SmartContract) GetMarbleHash(ctx contractapi.TransactionContextInterface, collection string, marbleID string) (string, error) {
// GetPrivateDataHash can use any collection deployed with the chaincode as input // GetPrivateDataHash can use any collection deployed with the chaincode as input
hashAsbytes, err := ctx.GetStub().GetPrivateDataHash(collection, marbleID) hashAsbytes, err := ctx.GetStub().GetPrivateDataHash(collection, marbleID)