From cd2461be0b0f7d72ec70cb4936cf8f9887ffc0b1 Mon Sep 17 00:00:00 2001 From: Fedor Partanskiy Date: Tue, 17 Sep 2024 08:10:43 +0300 Subject: [PATCH] add change state batch Signed-off-by: Fedor Partanskiy --- peer/chaincode.proto | 6 ++++++ peer/chaincode_shim.proto | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/peer/chaincode.proto b/peer/chaincode.proto index 4e4cd62..2413fc7 100644 --- a/peer/chaincode.proto +++ b/peer/chaincode.proto @@ -126,3 +126,9 @@ message ChaincodeData { // InstantiationPolicy for the chaincode common.SignaturePolicyEnvelope instantiation_policy = 8; } + +// ChaincodeAdditionalParams - parameters passed to chaincode to notify about peer capabilities +message ChaincodeAdditionalParams { + bool use_write_batch = 1; // an indication that the peer can handle state write batches + uint32 max_size_write_batch = 2; // maximum size of batches with write state +} diff --git a/peer/chaincode_shim.proto b/peer/chaincode_shim.proto index a12750b..4b9b424 100644 --- a/peer/chaincode_shim.proto +++ b/peer/chaincode_shim.proto @@ -38,6 +38,7 @@ message ChaincodeMessage { PUT_STATE_METADATA = 21; GET_PRIVATE_DATA_HASH = 22; PURGE_PRIVATE_DATA = 23; + WRITE_BATCH_STATE = 24; } Type type = 1; @@ -88,6 +89,29 @@ message PutStateMetadata { StateMetadata metadata = 4; } +// WriteBatchState - set of records for state changes sent by the batch +message WriteBatchState { + repeated WriteRecord rec = 1; +} + +// WriteRecord - single record with changes in the state of different types. +// Filled in depending on the type. +message WriteRecord { + enum Type { + UNDEFINED = 0; + PUT_STATE = 9; + DEL_STATE = 10; + PUT_STATE_METADATA = 21; + PURGE_PRIVATE_DATA = 23; + } + + string key = 1; + bytes value = 2; + string collection = 3; + StateMetadata metadata = 4; + Type type = 5; +} + // DelState is the payload of a ChaincodeMessage. It contains a key which // needs to be recorded in the transaction's write set as a delete operation. // If the collection is specified, the key needs to be recorded in the