Skip to content

Commit

Permalink
add change state batch
Browse files Browse the repository at this point in the history
Signed-off-by: Fedor Partanskiy <[email protected]>
  • Loading branch information
pfi79 committed Dec 4, 2024
1 parent d5db3dc commit cd2461b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions peer/chaincode.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
24 changes: 24 additions & 0 deletions peer/chaincode_shim.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cd2461b

Please sign in to comment.