Skip to content

Commit 37e7033

Browse files
committed
[FAB-9645] Key-level metadata protobufs
Additional kvrwset protobuf messages to support per-key-level metadata. Like the regular value, the metadata is represented as a byte array. Change-Id: I424e938d9418183e5d2e8adabc1d895181cbd335 Signed-off-by: Matthias Neugschwandtner <eug@zurich.ibm.com> Signed-off-by: Alessandro Sorniotti <ale.linux@sopit.net>
1 parent 97b51a7 commit 37e7033

File tree

2 files changed

+165
-55
lines changed

2 files changed

+165
-55
lines changed

protos/ledger/rwset/kvrwset/kv_rwset.pb.go

+137-54
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/ledger/rwset/kvrwset/kv_rwset.proto

+28-1
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,34 @@ message KVRead {
4242
Version version = 2;
4343
}
4444

45+
// KVMetadataWrite captures changes to metadata of a KVS key.
46+
// If KeepExistingMetadata is true, it is implied that metadata of the
47+
// previous version of this KVS key should be used, otherwise
48+
// they should be updated to the value specified in Metadata.
49+
message KVMetadataWrite {
50+
bytes metadata = 1;
51+
bool keep_existing_metadata = 2;
52+
}
53+
4554
// KVWrite captures a write (update/delete) operation performed during transaction simulation
55+
// Four operations are supported:
56+
// 1) value update: if KeepExistingValue is false, the value is updated to Value.
57+
// 2) metadata update: if Metadata.KeepExistingMetadata is false, the metadata
58+
// is updated to Metadata.Metadata
59+
// 3) medatadata deletion: if Metadata is nil, metadata is deleted
60+
// 4) deletion: if IsDelete is set, this key is removed from the ledger
61+
// Note that 1 and 2 may be combined.
4662
message KVWrite {
4763
string key = 1;
4864
bool is_delete = 2;
4965
bytes value = 3;
66+
// The two values below have been added in v1.2. Note that their zero value
67+
// describes a behaviour which is consistent with that of of pre-1.2 code:
68+
// - if KeepExistingValue is false, the value is updated to Value (unless
69+
// IsDelete is true).
70+
// - if Metadata is nil, metadata is deleted for this KVS key.
71+
bool keep_existing_value = 4;
72+
KVMetadataWrite metadata = 5;
5073
}
5174

5275
// KVReadHash is similar to the KVRead in spirit. However, it captures the hash of the key instead of the key itself
@@ -57,11 +80,15 @@ message KVReadHash {
5780
Version version = 2;
5881
}
5982

60-
// KVWriteHash is similar to the KVWrite in spiritcaptures a write (update/delete) operation performed during transaction simulation
83+
// KVWriteHash is similar to the KVWrite. It captures a write (update/delete) operation performed during transaction simulation
84+
// for a hashed key and to a hashed value. Note that metadata are stored in cleartext (no hash).
85+
// Similar considerations to KVWrite apply here.
6186
message KVWriteHash {
6287
bytes key_hash = 1;
6388
bool is_delete = 2;
6489
bytes value_hash = 3;
90+
bool keep_existing_value = 4;
91+
KVMetadataWrite metadata = 5;
6592
}
6693

6794
// Version encapsulates the version of a Key

0 commit comments

Comments
 (0)