官术网_书友最值得收藏!

The Invoke function

The Invoke function is called when the client invokes a specific function to process the transaction proposal. The ChaincodeStubInterface interface has the GetFunctionAndParameters method. This method extracts the function name and arguments and dispatches code to different functions based on the first argument. In our assetmgr, we need to call the Order, Ship, and Distribute functions, and then update the status for each step and the orgAsset information in the ledger. We can also define the query and query history functions, to get orgAsset information from the ledger.

You will notice that the Order method passes parameters from the command-line input. We use stub.GetState(assetId) to query the asset data from the blockchain, then we verify to make sure the current asset status is correct. We update the orgAsset info and then convert the asset data to byte data by calling json.Marshal(orgAsset). Finally, we save the data into the blockchain via stub.PutState. If there are no errors, the function will return a successful response to the client.

主站蜘蛛池模板: 博爱县| 安多县| 盈江县| 长岛县| 翼城县| 高邑县| 中江县| 当雄县| 洪洞县| 玉林市| 台中市| 台山市| 丰城市| 射阳县| 吴忠市| 彭州市| 徐州市| 兴义市| 台中县| 长白| 灌南县| 乌兰县| 七台河市| 象州县| 越西县| 武定县| 万源市| 吉林省| 桂东县| 穆棱市| 阜阳市| 班戈县| 麦盖提县| 安平县| 文登市| 安多县| 陕西省| 武汉市| 明溪县| 隆安县| 浦东新区|