fabric-sdk 0.4.3

Interact and program chaincode for the Hyperledger Fabric blockchain network
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
// This file is @generated by prost-build.
/// ChaincodeEvent is used for events and registrations that are specific to chaincode
/// string type - "chaincode"
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ChaincodeEvent {
    #[prost(string, tag = "1")]
    pub chaincode_id: ::prost::alloc::string::String,
    #[prost(string, tag = "2")]
    pub tx_id: ::prost::alloc::string::String,
    #[prost(string, tag = "3")]
    pub event_name: ::prost::alloc::string::String,
    #[prost(bytes = "vec", tag = "4")]
    pub payload: ::prost::alloc::vec::Vec<u8>,
}
/// ChaincodeID contains the path as specified by the deploy transaction
/// that created it as well as the hashCode that is generated by the
/// system for the path. From the user level (ie, CLI, REST API and so on)
/// deploy transaction is expected to provide the path and other requests
/// are expected to provide the hashCode. The other value will be ignored.
/// Internally, the structure could contain both values. For instance, the
/// hashCode will be set when first generated using the path
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ChaincodeId {
    /// deploy transaction will use the path
    #[prost(string, tag = "1")]
    pub path: ::prost::alloc::string::String,
    /// all other requests will use the name (really a hashcode) generated by
    /// the deploy transaction
    #[prost(string, tag = "2")]
    pub name: ::prost::alloc::string::String,
    /// user friendly version name for the chaincode
    #[prost(string, tag = "3")]
    pub version: ::prost::alloc::string::String,
}
/// Carries the chaincode function and its arguments.
/// UnmarshalJSON in transaction.go converts the string-based REST/JSON input to
/// the \[\]byte-based current ChaincodeInput structure.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChaincodeInput {
    #[prost(bytes = "vec", repeated, tag = "1")]
    pub args: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
    #[prost(map = "string, bytes", tag = "2")]
    pub decorations: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        ::prost::alloc::vec::Vec<u8>,
    >,
    /// is_init is used for the application to signal that an invocation is to be routed
    /// to the legacy 'Init' function for compatibility with chaincodes which handled
    /// Init in the old way.  New applications should manage their initialized state
    /// themselves.
    #[prost(bool, tag = "3")]
    pub is_init: bool,
}
/// Carries the chaincode specification. This is the actual metadata required for
/// defining a chaincode.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChaincodeSpec {
    #[prost(enumeration = "chaincode_spec::Type", tag = "1")]
    pub r#type: i32,
    #[prost(message, optional, tag = "2")]
    pub chaincode_id: ::core::option::Option<ChaincodeId>,
    #[prost(message, optional, tag = "3")]
    pub input: ::core::option::Option<ChaincodeInput>,
    #[prost(int32, tag = "4")]
    pub timeout: i32,
}
/// Nested message and enum types in `ChaincodeSpec`.
pub mod chaincode_spec {
    #[derive(serde::Serialize, serde::Deserialize)]
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum Type {
        Undefined = 0,
        Golang = 1,
        Node = 2,
        Car = 3,
        Java = 4,
    }
    impl Type {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::Undefined => "UNDEFINED",
                Self::Golang => "GOLANG",
                Self::Node => "NODE",
                Self::Car => "CAR",
                Self::Java => "JAVA",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "UNDEFINED" => Some(Self::Undefined),
                "GOLANG" => Some(Self::Golang),
                "NODE" => Some(Self::Node),
                "CAR" => Some(Self::Car),
                "JAVA" => Some(Self::Java),
                _ => None,
            }
        }
    }
}
/// Specify the deployment of a chaincode.
/// TODO: Define `codePackage`.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChaincodeDeploymentSpec {
    #[prost(message, optional, tag = "1")]
    pub chaincode_spec: ::core::option::Option<ChaincodeSpec>,
    #[prost(bytes = "vec", tag = "3")]
    pub code_package: ::prost::alloc::vec::Vec<u8>,
}
/// Carries the chaincode function and its arguments.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChaincodeInvocationSpec {
    #[prost(message, optional, tag = "1")]
    pub chaincode_spec: ::core::option::Option<ChaincodeSpec>,
}
/// LifecycleEvent is used as the payload of the chaincode event emitted by LSCC
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct LifecycleEvent {
    #[prost(string, tag = "1")]
    pub chaincode_name: ::prost::alloc::string::String,
}
/// CDSData is data stored in the LSCC on instantiation of a CC
/// for CDSPackage.  This needs to be serialized for ChaincodeData
/// hence the protobuf format
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CdsData {
    /// hash of ChaincodeDeploymentSpec.code_package
    #[prost(bytes = "vec", tag = "1")]
    pub hash: ::prost::alloc::vec::Vec<u8>,
    /// hash of ChaincodeID.name + ChaincodeID.version
    #[prost(bytes = "vec", tag = "2")]
    pub metadatahash: ::prost::alloc::vec::Vec<u8>,
}
/// ChaincodeData defines the datastructure for chaincodes to be serialized by proto
/// Type provides an additional check by directing to use a specific package after instantiation
/// Data is Type specific (see CDSPackage and SignedCDSPackage)
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChaincodeData {
    /// Name of the chaincode
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
    /// Version of the chaincode
    #[prost(string, tag = "2")]
    pub version: ::prost::alloc::string::String,
    /// Escc for the chaincode instance
    #[prost(string, tag = "3")]
    pub escc: ::prost::alloc::string::String,
    /// Vscc for the chaincode instance
    #[prost(string, tag = "4")]
    pub vscc: ::prost::alloc::string::String,
    /// Policy endorsement policy for the chaincode instance
    #[prost(message, optional, tag = "5")]
    pub policy: ::core::option::Option<super::common::SignaturePolicyEnvelope>,
    /// Data data specific to the package
    #[prost(bytes = "vec", tag = "6")]
    pub data: ::prost::alloc::vec::Vec<u8>,
    /// Id of the chaincode that's the unique fingerprint for the CC This is not
    /// currently used anywhere but serves as a good eyecatcher
    #[prost(bytes = "vec", tag = "7")]
    pub id: ::prost::alloc::vec::Vec<u8>,
    /// InstantiationPolicy for the chaincode
    #[prost(message, optional, tag = "8")]
    pub instantiation_policy: ::core::option::Option<
        super::common::SignaturePolicyEnvelope,
    >,
}
/// ChaincodeAdditionalParams - parameters passed to chaincode to notify about peer capabilities
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ChaincodeAdditionalParams {
    /// an indication that the peer can handle state write batches
    #[prost(bool, tag = "1")]
    pub use_write_batch: bool,
    /// maximum size of batches with write state
    #[prost(uint32, tag = "2")]
    pub max_size_write_batch: u32,
    /// an indication that the peer can handle get multiple keys
    #[prost(bool, tag = "3")]
    pub use_get_multiple_keys: bool,
    /// maximum size of batches with get multiple keys
    #[prost(uint32, tag = "4")]
    pub max_size_get_multiple_keys: u32,
}
/// A ProposalResponse is returned from an endorser to the proposal submitter.
/// The idea is that this message contains the endorser's response to the
/// request of a client to perform an action over a chaincode (or more
/// generically on the ledger); the response might be success/error (conveyed in
/// the Response field) together with a description of the action and a
/// signature over it by that endorser.  If a sufficient number of distinct
/// endorsers agree on the same action and produce signature to that effect, a
/// transaction can be generated and sent for ordering.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ProposalResponse {
    /// Version indicates message protocol version
    #[prost(int32, tag = "1")]
    pub version: i32,
    /// Timestamp is the time that the message
    /// was created as  defined by the sender
    #[prost(message, optional, tag = "2")]
    pub timestamp: ::core::option::Option<crate::fabric::google_protobuf::Timestamp>,
    /// A response message indicating whether the
    /// endorsement of the action was successful
    #[prost(message, optional, tag = "4")]
    pub response: ::core::option::Option<Response>,
    /// The payload of response. It is the bytes of ProposalResponsePayload
    #[prost(bytes = "vec", tag = "5")]
    pub payload: ::prost::alloc::vec::Vec<u8>,
    /// The endorsement of the proposal, basically
    /// the endorser's signature over the payload
    #[prost(message, optional, tag = "6")]
    pub endorsement: ::core::option::Option<Endorsement>,
    /// The chaincode interest derived from simulating the proposal.
    #[prost(message, optional, tag = "7")]
    pub interest: ::core::option::Option<ChaincodeInterest>,
}
/// A response with a representation similar to an HTTP response that can
/// be used within another message.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Response {
    /// A status code that should follow the HTTP status codes.
    #[prost(int32, tag = "1")]
    pub status: i32,
    /// A message associated with the response code.
    #[prost(string, tag = "2")]
    pub message: ::prost::alloc::string::String,
    /// A payload that can be used to include metadata with this response.
    #[prost(bytes = "vec", tag = "3")]
    pub payload: ::prost::alloc::vec::Vec<u8>,
}
/// ProposalResponsePayload is the payload of a proposal response.  This message
/// is the "bridge" between the client's request and the endorser's action in
/// response to that request. Concretely, for chaincodes, it contains a hashed
/// representation of the proposal (proposalHash) and a representation of the
/// chaincode state changes and events inside the extension field.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ProposalResponsePayload {
    /// Hash of the proposal that triggered this response. The hash is used to
    /// link a response with its proposal, both for bookeeping purposes on an
    /// asynchronous system and for security reasons (accountability,
    /// non-repudiation). The hash usually covers the entire Proposal message
    /// (byte-by-byte).
    #[prost(bytes = "vec", tag = "1")]
    pub proposal_hash: ::prost::alloc::vec::Vec<u8>,
    /// Extension should be unmarshaled to a type-specific message. The type of
    /// the extension in any proposal response depends on the type of the proposal
    /// that the client selected when the proposal was initially sent out.  In
    /// particular, this information is stored in the type field of a Header.  For
    /// chaincode, it's a ChaincodeAction message
    #[prost(bytes = "vec", tag = "2")]
    pub extension: ::prost::alloc::vec::Vec<u8>,
}
/// An endorsement is a signature of an endorser over a proposal response.  By
/// producing an endorsement message, an endorser implicitly "approves" that
/// proposal response and the actions contained therein. When enough
/// endorsements have been collected, a transaction can be generated out of a
/// set of proposal responses.  Note that this message only contains an identity
/// and a signature but no signed payload. This is intentional because
/// endorsements are supposed to be collected in a transaction, and they are all
/// expected to endorse a single proposal response/action (many endorsements
/// over a single proposal response)
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Endorsement {
    /// Identity of the endorser (e.g. its certificate)
    #[prost(bytes = "vec", tag = "1")]
    pub endorser: ::prost::alloc::vec::Vec<u8>,
    /// Signature of the payload included in ProposalResponse concatenated with
    /// the endorser's certificate; ie, sign(ProposalResponse.payload + endorser)
    #[prost(bytes = "vec", tag = "2")]
    pub signature: ::prost::alloc::vec::Vec<u8>,
}
/// ChaincodeInterest defines an interest about an endorsement
/// for a specific single chaincode invocation.
/// Multiple chaincodes indicate chaincode to chaincode invocations.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChaincodeInterest {
    #[prost(message, repeated, tag = "1")]
    pub chaincodes: ::prost::alloc::vec::Vec<ChaincodeCall>,
}
/// ChaincodeCall defines a call to a chaincode.
/// It may have collections that are related to the chaincode
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChaincodeCall {
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
    #[prost(string, repeated, tag = "2")]
    pub collection_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// Indicates we do not need to read from private data
    #[prost(bool, tag = "3")]
    pub no_private_reads: bool,
    /// Indicates we do not need to write to the chaincode namespace
    #[prost(bool, tag = "4")]
    pub no_public_writes: bool,
    /// The set of signature policies associated with states in the write-set
    /// that have state-based endorsement policies.
    #[prost(message, repeated, tag = "5")]
    pub key_policies: ::prost::alloc::vec::Vec<super::common::SignaturePolicyEnvelope>,
    /// Indicates we wish to ignore the namespace endorsement policy
    #[prost(bool, tag = "6")]
    pub disregard_namespace_policy: bool,
}
/// This structure is necessary to sign the proposal which contains the header
/// and the payload. Without this structure, we would have to concatenate the
/// header and the payload to verify the signature, which could be expensive
/// with large payload
///
/// When an endorser receives a SignedProposal message, it should verify the
/// signature over the proposal bytes. This verification requires the following
/// steps:
/// 1. Verification of the validity of the certificate that was used to produce
///     the signature.  The certificate will be available once proposalBytes has
///     been unmarshalled to a Proposal message, and Proposal.header has been
///     unmarshalled to a Header message. While this unmarshalling-before-verifying
///     might not be ideal, it is unavoidable because i) the signature needs to also
///     protect the signing certificate; ii) it is desirable that Header is created
///     once by the client and never changed (for the sake of accountability and
///     non-repudiation). Note also that it is actually impossible to conclusively
///     verify the validity of the certificate included in a Proposal, because the
///     proposal needs to first be endorsed and ordered with respect to certificate
///     expiration transactions. Still, it is useful to pre-filter expired
///     certificates at this stage.
/// 2. Verification that the certificate is trusted (signed by a trusted CA) and
///     that it is allowed to transact with us (with respect to some ACLs);
/// 3. Verification that the signature on proposalBytes is valid;
/// 4. Detect replay attacks;
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SignedProposal {
    /// The bytes of Proposal
    #[prost(bytes = "vec", tag = "1")]
    pub proposal_bytes: ::prost::alloc::vec::Vec<u8>,
    /// Signaure over proposalBytes; this signature is to be verified against
    /// the creator identity contained in the header of the Proposal message
    /// marshaled as proposalBytes
    #[prost(bytes = "vec", tag = "2")]
    pub signature: ::prost::alloc::vec::Vec<u8>,
}
/// A Proposal is sent to an endorser for endorsement.  The proposal contains:
/// 1. A header which should be unmarshaled to a Header message.  Note that
///     Header is both the header of a Proposal and of a Transaction, in that i)
///     both headers should be unmarshaled to this message; and ii) it is used to
///     compute cryptographic hashes and signatures.  The header has fields common
///     to all proposals/transactions.  In addition it has a type field for
///     additional customization. An example of this is the ChaincodeHeaderExtension
///     message used to extend the Header for type CHAINCODE.
/// 2. A payload whose type depends on the header's type field.
/// 3. An extension whose type depends on the header's type field.
///
/// Let us see an example. For type CHAINCODE (see the Header message),
/// we have the following:
/// 1. The header is a Header message whose extensions field is a
///     ChaincodeHeaderExtension message.
/// 2. The payload is a ChaincodeProposalPayload message.
/// 3. The extension is a ChaincodeAction that might be used to ask the
///     endorsers to endorse a specific ChaincodeAction, thus emulating the
///     submitting peer model.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Proposal {
    /// The header of the proposal. It is the bytes of the Header
    #[prost(bytes = "vec", tag = "1")]
    pub header: ::prost::alloc::vec::Vec<u8>,
    /// The payload of the proposal as defined by the type in the proposal
    /// header.
    #[prost(bytes = "vec", tag = "2")]
    pub payload: ::prost::alloc::vec::Vec<u8>,
    /// Optional extensions to the proposal. Its content depends on the Header's
    /// type field.  For the type CHAINCODE, it might be the bytes of a
    /// ChaincodeAction message.
    #[prost(bytes = "vec", tag = "3")]
    pub extension: ::prost::alloc::vec::Vec<u8>,
}
/// ChaincodeHeaderExtension is the Header's extentions message to be used when
/// the Header's type is CHAINCODE.  This extensions is used to specify which
/// chaincode to invoke and what should appear on the ledger.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ChaincodeHeaderExtension {
    /// The ID of the chaincode to target.
    #[prost(message, optional, tag = "2")]
    pub chaincode_id: ::core::option::Option<ChaincodeId>,
}
/// ChaincodeProposalPayload is the Proposal's payload message to be used when
/// the Header's type is CHAINCODE.  It contains the arguments for this
/// invocation.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChaincodeProposalPayload {
    /// Input contains the arguments for this invocation. If this invocation
    /// deploys a new chaincode, ESCC/VSCC are part of this field.
    /// This is usually a marshaled ChaincodeInvocationSpec
    #[prost(bytes = "vec", tag = "1")]
    pub input: ::prost::alloc::vec::Vec<u8>,
    /// TransientMap contains data (e.g. cryptographic material) that might be used
    /// to implement some form of application-level confidentiality. The contents
    /// of this field are supposed to always be omitted from the transaction and
    /// excluded from the ledger.
    #[prost(map = "string, bytes", tag = "2")]
    pub transient_map: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        ::prost::alloc::vec::Vec<u8>,
    >,
}
/// ChaincodeAction contains the executed chaincode results, response, and event.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ChaincodeAction {
    /// This field contains the read set and the write set produced by the
    /// chaincode executing this invocation.
    #[prost(bytes = "vec", tag = "1")]
    pub results: ::prost::alloc::vec::Vec<u8>,
    /// This field contains the event generated by the chaincode.
    /// Only a single marshaled ChaincodeEvent is included.
    #[prost(bytes = "vec", tag = "2")]
    pub events: ::prost::alloc::vec::Vec<u8>,
    /// This field contains the result of executing this invocation.
    #[prost(message, optional, tag = "3")]
    pub response: ::core::option::Option<Response>,
    /// This field contains the ChaincodeID of executing this invocation. Endorser
    /// will set it with the ChaincodeID called by endorser while simulating proposal.
    /// Committer will validate the version matching with latest chaincode version.
    /// Adding ChaincodeID to keep version opens up the possibility of multiple
    /// ChaincodeAction per transaction.
    #[prost(message, optional, tag = "4")]
    pub chaincode_id: ::core::option::Option<ChaincodeId>,
}
/// ProcessedTransaction wraps an Envelope that includes a transaction along with an indication
/// of whether the transaction was validated or invalidated by committing peer.
/// The use case is that GetTransactionByID API needs to retrieve the transaction Envelope
/// from block storage, and return it to a client, and indicate whether the transaction
/// was validated or invalidated by committing peer. So that the originally submitted
/// transaction Envelope is not modified, the ProcessedTransaction wrapper is returned.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ProcessedTransaction {
    /// An Envelope which includes a processed transaction
    #[prost(message, optional, tag = "1")]
    pub transaction_envelope: ::core::option::Option<super::common::Envelope>,
    /// An indication of whether the transaction was validated or invalidated by committing peer
    #[prost(int32, tag = "2")]
    pub validation_code: i32,
}
/// The transaction to be sent to the ordering service. A transaction contains
/// one or more TransactionAction. Each TransactionAction binds a proposal to
/// potentially multiple actions. The transaction is atomic meaning that either
/// all actions in the transaction will be committed or none will.  Note that
/// while a Transaction might include more than one Header, the Header.creator
/// field must be the same in each.
/// A single client is free to issue a number of independent Proposal, each with
/// their header (Header) and request payload (ChaincodeProposalPayload).  Each
/// proposal is independently endorsed generating an action
/// (ProposalResponsePayload) with one signature per Endorser. Any number of
/// independent proposals (and their action) might be included in a transaction
/// to ensure that they are treated atomically.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Transaction {
    /// The payload is an array of TransactionAction. An array is necessary to
    /// accommodate multiple actions per transaction
    #[prost(message, repeated, tag = "1")]
    pub actions: ::prost::alloc::vec::Vec<TransactionAction>,
}
/// TransactionAction binds a proposal to its action.  The type field in the
/// header dictates the type of action to be applied to the ledger.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct TransactionAction {
    /// The header of the proposal action, which is the proposal header
    #[prost(bytes = "vec", tag = "1")]
    pub header: ::prost::alloc::vec::Vec<u8>,
    /// The payload of the action as defined by the type in the header For
    /// chaincode, it's the bytes of ChaincodeActionPayload
    #[prost(bytes = "vec", tag = "2")]
    pub payload: ::prost::alloc::vec::Vec<u8>,
}
/// ChaincodeActionPayload is the message to be used for the TransactionAction's
/// payload when the Header's type is set to CHAINCODE.  It carries the
/// chaincodeProposalPayload and an endorsed action to apply to the ledger.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChaincodeActionPayload {
    /// This field contains the bytes of the ChaincodeProposalPayload message from
    /// the original invocation (essentially the arguments) after the application
    /// of the visibility function. The main visibility modes are "full" (the
    /// entire ChaincodeProposalPayload message is included here), "hash" (only
    /// the hash of the ChaincodeProposalPayload message is included) or
    /// "nothing".  This field will be used to check the consistency of
    /// ProposalResponsePayload.proposalHash.  For the CHAINCODE type,
    /// ProposalResponsePayload.proposalHash is supposed to be H(ProposalHeader ||
    /// f(ChaincodeProposalPayload)) where f is the visibility function.
    #[prost(bytes = "vec", tag = "1")]
    pub chaincode_proposal_payload: ::prost::alloc::vec::Vec<u8>,
    /// The list of actions to apply to the ledger
    #[prost(message, optional, tag = "2")]
    pub action: ::core::option::Option<ChaincodeEndorsedAction>,
}
/// ChaincodeEndorsedAction carries information about the endorsement of a
/// specific proposal
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChaincodeEndorsedAction {
    /// This is the bytes of the ProposalResponsePayload message signed by the
    /// endorsers.  Recall that for the CHAINCODE type, the
    /// ProposalResponsePayload's extenstion field carries a ChaincodeAction
    #[prost(bytes = "vec", tag = "1")]
    pub proposal_response_payload: ::prost::alloc::vec::Vec<u8>,
    /// The endorsement of the proposal, basically the endorser's signature over
    /// proposalResponsePayload
    #[prost(message, repeated, tag = "2")]
    pub endorsements: ::prost::alloc::vec::Vec<Endorsement>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum TxValidationCode {
    Valid = 0,
    NilEnvelope = 1,
    BadPayload = 2,
    BadCommonHeader = 3,
    BadCreatorSignature = 4,
    InvalidEndorserTransaction = 5,
    InvalidConfigTransaction = 6,
    UnsupportedTxPayload = 7,
    BadProposalTxid = 8,
    DuplicateTxid = 9,
    EndorsementPolicyFailure = 10,
    MvccReadConflict = 11,
    PhantomReadConflict = 12,
    UnknownTxType = 13,
    TargetChainNotFound = 14,
    MarshalTxError = 15,
    NilTxaction = 16,
    ExpiredChaincode = 17,
    ChaincodeVersionConflict = 18,
    BadHeaderExtension = 19,
    BadChannelHeader = 20,
    BadResponsePayload = 21,
    BadRwset = 22,
    IllegalWriteset = 23,
    InvalidWriteset = 24,
    InvalidChaincode = 25,
    NotValidated = 254,
    InvalidOtherReason = 255,
}
impl TxValidationCode {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Valid => "VALID",
            Self::NilEnvelope => "NIL_ENVELOPE",
            Self::BadPayload => "BAD_PAYLOAD",
            Self::BadCommonHeader => "BAD_COMMON_HEADER",
            Self::BadCreatorSignature => "BAD_CREATOR_SIGNATURE",
            Self::InvalidEndorserTransaction => "INVALID_ENDORSER_TRANSACTION",
            Self::InvalidConfigTransaction => "INVALID_CONFIG_TRANSACTION",
            Self::UnsupportedTxPayload => "UNSUPPORTED_TX_PAYLOAD",
            Self::BadProposalTxid => "BAD_PROPOSAL_TXID",
            Self::DuplicateTxid => "DUPLICATE_TXID",
            Self::EndorsementPolicyFailure => "ENDORSEMENT_POLICY_FAILURE",
            Self::MvccReadConflict => "MVCC_READ_CONFLICT",
            Self::PhantomReadConflict => "PHANTOM_READ_CONFLICT",
            Self::UnknownTxType => "UNKNOWN_TX_TYPE",
            Self::TargetChainNotFound => "TARGET_CHAIN_NOT_FOUND",
            Self::MarshalTxError => "MARSHAL_TX_ERROR",
            Self::NilTxaction => "NIL_TXACTION",
            Self::ExpiredChaincode => "EXPIRED_CHAINCODE",
            Self::ChaincodeVersionConflict => "CHAINCODE_VERSION_CONFLICT",
            Self::BadHeaderExtension => "BAD_HEADER_EXTENSION",
            Self::BadChannelHeader => "BAD_CHANNEL_HEADER",
            Self::BadResponsePayload => "BAD_RESPONSE_PAYLOAD",
            Self::BadRwset => "BAD_RWSET",
            Self::IllegalWriteset => "ILLEGAL_WRITESET",
            Self::InvalidWriteset => "INVALID_WRITESET",
            Self::InvalidChaincode => "INVALID_CHAINCODE",
            Self::NotValidated => "NOT_VALIDATED",
            Self::InvalidOtherReason => "INVALID_OTHER_REASON",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "VALID" => Some(Self::Valid),
            "NIL_ENVELOPE" => Some(Self::NilEnvelope),
            "BAD_PAYLOAD" => Some(Self::BadPayload),
            "BAD_COMMON_HEADER" => Some(Self::BadCommonHeader),
            "BAD_CREATOR_SIGNATURE" => Some(Self::BadCreatorSignature),
            "INVALID_ENDORSER_TRANSACTION" => Some(Self::InvalidEndorserTransaction),
            "INVALID_CONFIG_TRANSACTION" => Some(Self::InvalidConfigTransaction),
            "UNSUPPORTED_TX_PAYLOAD" => Some(Self::UnsupportedTxPayload),
            "BAD_PROPOSAL_TXID" => Some(Self::BadProposalTxid),
            "DUPLICATE_TXID" => Some(Self::DuplicateTxid),
            "ENDORSEMENT_POLICY_FAILURE" => Some(Self::EndorsementPolicyFailure),
            "MVCC_READ_CONFLICT" => Some(Self::MvccReadConflict),
            "PHANTOM_READ_CONFLICT" => Some(Self::PhantomReadConflict),
            "UNKNOWN_TX_TYPE" => Some(Self::UnknownTxType),
            "TARGET_CHAIN_NOT_FOUND" => Some(Self::TargetChainNotFound),
            "MARSHAL_TX_ERROR" => Some(Self::MarshalTxError),
            "NIL_TXACTION" => Some(Self::NilTxaction),
            "EXPIRED_CHAINCODE" => Some(Self::ExpiredChaincode),
            "CHAINCODE_VERSION_CONFLICT" => Some(Self::ChaincodeVersionConflict),
            "BAD_HEADER_EXTENSION" => Some(Self::BadHeaderExtension),
            "BAD_CHANNEL_HEADER" => Some(Self::BadChannelHeader),
            "BAD_RESPONSE_PAYLOAD" => Some(Self::BadResponsePayload),
            "BAD_RWSET" => Some(Self::BadRwset),
            "ILLEGAL_WRITESET" => Some(Self::IllegalWriteset),
            "INVALID_WRITESET" => Some(Self::InvalidWriteset),
            "INVALID_CHAINCODE" => Some(Self::InvalidChaincode),
            "NOT_VALIDATED" => Some(Self::NotValidated),
            "INVALID_OTHER_REASON" => Some(Self::InvalidOtherReason),
            _ => None,
        }
    }
}
/// Reserved entries in the key-level metadata map
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum MetaDataKeys {
    ValidationParameter = 0,
    ValidationParameterV2 = 1,
}
impl MetaDataKeys {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::ValidationParameter => "VALIDATION_PARAMETER",
            Self::ValidationParameterV2 => "VALIDATION_PARAMETER_V2",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "VALIDATION_PARAMETER" => Some(Self::ValidationParameter),
            "VALIDATION_PARAMETER_V2" => Some(Self::ValidationParameterV2),
            _ => None,
        }
    }
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ChaincodeMessage {
    #[prost(enumeration = "chaincode_message::Type", tag = "1")]
    pub r#type: i32,
    #[prost(message, optional, tag = "2")]
    pub timestamp: ::core::option::Option<crate::fabric::google_protobuf::Timestamp>,
    #[prost(bytes = "vec", tag = "3")]
    pub payload: ::prost::alloc::vec::Vec<u8>,
    #[prost(string, tag = "4")]
    pub txid: ::prost::alloc::string::String,
    #[prost(message, optional, tag = "5")]
    pub proposal: ::core::option::Option<SignedProposal>,
    /// event emitted by chaincode. Used only with Init or Invoke.
    /// This event is then stored (currently)
    /// with Block.NonHashData.TransactionResult
    #[prost(message, optional, tag = "6")]
    pub chaincode_event: ::core::option::Option<ChaincodeEvent>,
    /// channel id
    #[prost(string, tag = "7")]
    pub channel_id: ::prost::alloc::string::String,
}
/// Nested message and enum types in `ChaincodeMessage`.
pub mod chaincode_message {
    #[derive(serde::Serialize, serde::Deserialize)]
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum Type {
        Undefined = 0,
        Register = 1,
        Registered = 2,
        Init = 3,
        Ready = 4,
        Transaction = 5,
        Completed = 6,
        Error = 7,
        GetState = 8,
        PutState = 9,
        DelState = 10,
        InvokeChaincode = 11,
        Response = 13,
        GetStateByRange = 14,
        GetQueryResult = 15,
        QueryStateNext = 16,
        QueryStateClose = 17,
        Keepalive = 18,
        GetHistoryForKey = 19,
        GetStateMetadata = 20,
        PutStateMetadata = 21,
        GetPrivateDataHash = 22,
        PurgePrivateData = 23,
        WriteBatchState = 24,
        GetStateMultiple = 25,
    }
    impl Type {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::Undefined => "UNDEFINED",
                Self::Register => "REGISTER",
                Self::Registered => "REGISTERED",
                Self::Init => "INIT",
                Self::Ready => "READY",
                Self::Transaction => "TRANSACTION",
                Self::Completed => "COMPLETED",
                Self::Error => "ERROR",
                Self::GetState => "GET_STATE",
                Self::PutState => "PUT_STATE",
                Self::DelState => "DEL_STATE",
                Self::InvokeChaincode => "INVOKE_CHAINCODE",
                Self::Response => "RESPONSE",
                Self::GetStateByRange => "GET_STATE_BY_RANGE",
                Self::GetQueryResult => "GET_QUERY_RESULT",
                Self::QueryStateNext => "QUERY_STATE_NEXT",
                Self::QueryStateClose => "QUERY_STATE_CLOSE",
                Self::Keepalive => "KEEPALIVE",
                Self::GetHistoryForKey => "GET_HISTORY_FOR_KEY",
                Self::GetStateMetadata => "GET_STATE_METADATA",
                Self::PutStateMetadata => "PUT_STATE_METADATA",
                Self::GetPrivateDataHash => "GET_PRIVATE_DATA_HASH",
                Self::PurgePrivateData => "PURGE_PRIVATE_DATA",
                Self::WriteBatchState => "WRITE_BATCH_STATE",
                Self::GetStateMultiple => "GET_STATE_MULTIPLE",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "UNDEFINED" => Some(Self::Undefined),
                "REGISTER" => Some(Self::Register),
                "REGISTERED" => Some(Self::Registered),
                "INIT" => Some(Self::Init),
                "READY" => Some(Self::Ready),
                "TRANSACTION" => Some(Self::Transaction),
                "COMPLETED" => Some(Self::Completed),
                "ERROR" => Some(Self::Error),
                "GET_STATE" => Some(Self::GetState),
                "PUT_STATE" => Some(Self::PutState),
                "DEL_STATE" => Some(Self::DelState),
                "INVOKE_CHAINCODE" => Some(Self::InvokeChaincode),
                "RESPONSE" => Some(Self::Response),
                "GET_STATE_BY_RANGE" => Some(Self::GetStateByRange),
                "GET_QUERY_RESULT" => Some(Self::GetQueryResult),
                "QUERY_STATE_NEXT" => Some(Self::QueryStateNext),
                "QUERY_STATE_CLOSE" => Some(Self::QueryStateClose),
                "KEEPALIVE" => Some(Self::Keepalive),
                "GET_HISTORY_FOR_KEY" => Some(Self::GetHistoryForKey),
                "GET_STATE_METADATA" => Some(Self::GetStateMetadata),
                "PUT_STATE_METADATA" => Some(Self::PutStateMetadata),
                "GET_PRIVATE_DATA_HASH" => Some(Self::GetPrivateDataHash),
                "PURGE_PRIVATE_DATA" => Some(Self::PurgePrivateData),
                "WRITE_BATCH_STATE" => Some(Self::WriteBatchState),
                "GET_STATE_MULTIPLE" => Some(Self::GetStateMultiple),
                _ => None,
            }
        }
    }
}
/// GetState is the payload of a ChaincodeMessage. It contains a key which
/// is to be fetched from the ledger. If the collection is specified, the key
/// would be fetched from the collection (i.e., private state)
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetState {
    #[prost(string, tag = "1")]
    pub key: ::prost::alloc::string::String,
    #[prost(string, tag = "2")]
    pub collection: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetStateMetadata {
    #[prost(string, tag = "1")]
    pub key: ::prost::alloc::string::String,
    #[prost(string, tag = "2")]
    pub collection: ::prost::alloc::string::String,
}
/// GetStateMultiple is the payload of the ChaincodeMessage.
/// It contains the keys to be retrieved from the ledger.
/// If a collection is specified, the keys will be retrieved
/// from the collection (i.e., the private state).
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetStateMultiple {
    #[prost(string, repeated, tag = "1")]
    pub keys: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    #[prost(string, tag = "2")]
    pub collection: ::prost::alloc::string::String,
}
/// GetStateMultipleResult is result of executing the GetStateMiltiple request
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetStateMultipleResult {
    #[prost(bytes = "vec", repeated, tag = "1")]
    pub values: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
}
/// PutState is the payload of a ChaincodeMessage. It contains a key and value
/// which needs to be written to the transaction's write set. If the collection is
/// specified, the key and value would be written to the transaction's private
/// write set.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct PutState {
    #[prost(string, tag = "1")]
    pub key: ::prost::alloc::string::String,
    #[prost(bytes = "vec", tag = "2")]
    pub value: ::prost::alloc::vec::Vec<u8>,
    #[prost(string, tag = "3")]
    pub collection: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct PutStateMetadata {
    #[prost(string, tag = "1")]
    pub key: ::prost::alloc::string::String,
    #[prost(string, tag = "3")]
    pub collection: ::prost::alloc::string::String,
    #[prost(message, optional, tag = "4")]
    pub metadata: ::core::option::Option<StateMetadata>,
}
/// WriteBatchState - set of records for state changes sent by the batch
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WriteBatchState {
    #[prost(message, repeated, tag = "1")]
    pub rec: ::prost::alloc::vec::Vec<WriteRecord>,
}
/// WriteRecord - single record with changes in the state of different types.
/// Filled in depending on the type.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct WriteRecord {
    #[prost(string, tag = "1")]
    pub key: ::prost::alloc::string::String,
    #[prost(bytes = "vec", tag = "2")]
    pub value: ::prost::alloc::vec::Vec<u8>,
    #[prost(string, tag = "3")]
    pub collection: ::prost::alloc::string::String,
    #[prost(message, optional, tag = "4")]
    pub metadata: ::core::option::Option<StateMetadata>,
    #[prost(enumeration = "write_record::Type", tag = "5")]
    pub r#type: i32,
}
/// Nested message and enum types in `WriteRecord`.
pub mod write_record {
    #[derive(serde::Serialize, serde::Deserialize)]
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum Type {
        Undefined = 0,
        PutState = 9,
        DelState = 10,
        PutStateMetadata = 21,
        PurgePrivateData = 23,
    }
    impl Type {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::Undefined => "UNDEFINED",
                Self::PutState => "PUT_STATE",
                Self::DelState => "DEL_STATE",
                Self::PutStateMetadata => "PUT_STATE_METADATA",
                Self::PurgePrivateData => "PURGE_PRIVATE_DATA",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "UNDEFINED" => Some(Self::Undefined),
                "PUT_STATE" => Some(Self::PutState),
                "DEL_STATE" => Some(Self::DelState),
                "PUT_STATE_METADATA" => Some(Self::PutStateMetadata),
                "PURGE_PRIVATE_DATA" => Some(Self::PurgePrivateData),
                _ => None,
            }
        }
    }
}
/// 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
/// transaction's private write set as a delete operation.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct DelState {
    #[prost(string, tag = "1")]
    pub key: ::prost::alloc::string::String,
    #[prost(string, tag = "2")]
    pub collection: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct PurgePrivateState {
    #[prost(string, tag = "1")]
    pub key: ::prost::alloc::string::String,
    #[prost(string, tag = "2")]
    pub collection: ::prost::alloc::string::String,
}
/// GetStateByRange is the payload of a ChaincodeMessage. It contains a start key and
/// a end key required to execute range query. If the collection is specified,
/// the range query needs to be executed on the private data. The metadata hold
/// the byte representation of QueryMetadata.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetStateByRange {
    #[prost(string, tag = "1")]
    pub start_key: ::prost::alloc::string::String,
    #[prost(string, tag = "2")]
    pub end_key: ::prost::alloc::string::String,
    #[prost(string, tag = "3")]
    pub collection: ::prost::alloc::string::String,
    #[prost(bytes = "vec", tag = "4")]
    pub metadata: ::prost::alloc::vec::Vec<u8>,
}
/// GetQueryResult is the payload of a ChaincodeMessage. It contains a query
/// string in the form that is supported by the underlying state database.
/// If the collection is specified, the query needs to be executed on the
/// private data.  The metadata hold the byte representation of QueryMetadata.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetQueryResult {
    #[prost(string, tag = "1")]
    pub query: ::prost::alloc::string::String,
    #[prost(string, tag = "2")]
    pub collection: ::prost::alloc::string::String,
    #[prost(bytes = "vec", tag = "3")]
    pub metadata: ::prost::alloc::vec::Vec<u8>,
}
/// QueryMetadata is the metadata of a GetStateByRange and GetQueryResult.
/// It contains a pageSize which denotes the number of records to be fetched
/// and a bookmark.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct QueryMetadata {
    #[prost(int32, tag = "1")]
    pub page_size: i32,
    #[prost(string, tag = "2")]
    pub bookmark: ::prost::alloc::string::String,
}
/// GetHistoryForKey is the payload of a ChaincodeMessage. It contains a key
/// for which the historical values need to be retrieved.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetHistoryForKey {
    #[prost(string, tag = "1")]
    pub key: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct QueryStateNext {
    #[prost(string, tag = "1")]
    pub id: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct QueryStateClose {
    #[prost(string, tag = "1")]
    pub id: ::prost::alloc::string::String,
}
/// QueryResultBytes hold the byte representation of a record returned by the peer.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct QueryResultBytes {
    #[prost(bytes = "vec", tag = "1")]
    pub result_bytes: ::prost::alloc::vec::Vec<u8>,
}
/// QueryResponse is returned by the peer as a result of a GetStateByRange,
/// GetQueryResult, and GetHistoryForKey. It holds a bunch of records in
/// results field, a flag to denote whether more results need to be fetched from
/// the peer in has_more field, transaction id in id field, and a QueryResponseMetadata
/// in metadata field.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryResponse {
    #[prost(message, repeated, tag = "1")]
    pub results: ::prost::alloc::vec::Vec<QueryResultBytes>,
    #[prost(bool, tag = "2")]
    pub has_more: bool,
    #[prost(string, tag = "3")]
    pub id: ::prost::alloc::string::String,
    #[prost(bytes = "vec", tag = "4")]
    pub metadata: ::prost::alloc::vec::Vec<u8>,
}
/// QueryResponseMetadata is the metadata of a QueryResponse. It contains a count
/// which denotes the number of records fetched from the ledger and a bookmark.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct QueryResponseMetadata {
    #[prost(int32, tag = "1")]
    pub fetched_records_count: i32,
    #[prost(string, tag = "2")]
    pub bookmark: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct StateMetadata {
    #[prost(string, tag = "1")]
    pub metakey: ::prost::alloc::string::String,
    #[prost(bytes = "vec", tag = "2")]
    pub value: ::prost::alloc::vec::Vec<u8>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StateMetadataResult {
    #[prost(message, repeated, tag = "1")]
    pub entries: ::prost::alloc::vec::Vec<StateMetadata>,
}
/// Generated client implementations.
pub mod chaincode_support_client {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    /// Interface that provides support to chaincode execution. ChaincodeContext
    /// provides the context necessary for the server to respond appropriately.
    #[derive(Debug, Clone)]
    pub struct ChaincodeSupportClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl<T> ChaincodeSupportClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::Body>,
        T::Error: Into<StdError>,
        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
    {
        pub fn new(inner: T) -> Self {
            let inner = tonic::client::Grpc::new(inner);
            Self { inner }
        }
        pub fn with_origin(inner: T, origin: Uri) -> Self {
            let inner = tonic::client::Grpc::with_origin(inner, origin);
            Self { inner }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> ChaincodeSupportClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                http::Request<tonic::body::Body>,
                Response = http::Response<
                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
                >,
            >,
            <T as tonic::codegen::Service<
                http::Request<tonic::body::Body>,
            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
        {
            ChaincodeSupportClient::new(InterceptedService::new(inner, interceptor))
        }
        /// Compress requests with the given encoding.
        ///
        /// This requires the server to support it otherwise it might respond with an
        /// error.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.send_compressed(encoding);
            self
        }
        /// Enable decompressing responses.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.accept_compressed(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_decoding_message_size(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_encoding_message_size(limit);
            self
        }
        pub async fn register(
            &mut self,
            request: impl tonic::IntoStreamingRequest<Message = super::ChaincodeMessage>,
        ) -> std::result::Result<
            tonic::Response<tonic::codec::Streaming<super::ChaincodeMessage>>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/protos.ChaincodeSupport/Register",
            );
            let mut req = request.into_streaming_request();
            req.extensions_mut()
                .insert(GrpcMethod::new("protos.ChaincodeSupport", "Register"));
            self.inner.streaming(req, path, codec).await
        }
    }
}
/// Generated server implementations.
pub mod chaincode_support_server {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    /// Generated trait containing gRPC methods that should be implemented for use with ChaincodeSupportServer.
    #[async_trait]
    pub trait ChaincodeSupport: std::marker::Send + std::marker::Sync + 'static {
        /// Server streaming response type for the Register method.
        type RegisterStream: tonic::codegen::tokio_stream::Stream<
                Item = std::result::Result<super::ChaincodeMessage, tonic::Status>,
            >
            + std::marker::Send
            + 'static;
        async fn register(
            &self,
            request: tonic::Request<tonic::Streaming<super::ChaincodeMessage>>,
        ) -> std::result::Result<tonic::Response<Self::RegisterStream>, tonic::Status>;
    }
    /// Interface that provides support to chaincode execution. ChaincodeContext
    /// provides the context necessary for the server to respond appropriately.
    #[derive(Debug)]
    pub struct ChaincodeSupportServer<T> {
        inner: Arc<T>,
        accept_compression_encodings: EnabledCompressionEncodings,
        send_compression_encodings: EnabledCompressionEncodings,
        max_decoding_message_size: Option<usize>,
        max_encoding_message_size: Option<usize>,
    }
    impl<T> ChaincodeSupportServer<T> {
        pub fn new(inner: T) -> Self {
            Self::from_arc(Arc::new(inner))
        }
        pub fn from_arc(inner: Arc<T>) -> Self {
            Self {
                inner,
                accept_compression_encodings: Default::default(),
                send_compression_encodings: Default::default(),
                max_decoding_message_size: None,
                max_encoding_message_size: None,
            }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> InterceptedService<Self, F>
        where
            F: tonic::service::Interceptor,
        {
            InterceptedService::new(Self::new(inner), interceptor)
        }
        /// Enable decompressing requests with the given encoding.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.accept_compression_encodings.enable(encoding);
            self
        }
        /// Compress responses with the given encoding, if the client supports it.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.send_compression_encodings.enable(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.max_decoding_message_size = Some(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.max_encoding_message_size = Some(limit);
            self
        }
    }
    impl<T, B> tonic::codegen::Service<http::Request<B>> for ChaincodeSupportServer<T>
    where
        T: ChaincodeSupport,
        B: Body + std::marker::Send + 'static,
        B::Error: Into<StdError> + std::marker::Send + 'static,
    {
        type Response = http::Response<tonic::body::Body>;
        type Error = std::convert::Infallible;
        type Future = BoxFuture<Self::Response, Self::Error>;
        fn poll_ready(
            &mut self,
            _cx: &mut Context<'_>,
        ) -> Poll<std::result::Result<(), Self::Error>> {
            Poll::Ready(Ok(()))
        }
        fn call(&mut self, req: http::Request<B>) -> Self::Future {
            match req.uri().path() {
                "/protos.ChaincodeSupport/Register" => {
                    #[allow(non_camel_case_types)]
                    struct RegisterSvc<T: ChaincodeSupport>(pub Arc<T>);
                    impl<
                        T: ChaincodeSupport,
                    > tonic::server::StreamingService<super::ChaincodeMessage>
                    for RegisterSvc<T> {
                        type Response = super::ChaincodeMessage;
                        type ResponseStream = T::RegisterStream;
                        type Future = BoxFuture<
                            tonic::Response<Self::ResponseStream>,
                            tonic::Status,
                        >;
                        fn call(
                            &mut self,
                            request: tonic::Request<
                                tonic::Streaming<super::ChaincodeMessage>,
                            >,
                        ) -> Self::Future {
                            let inner = Arc::clone(&self.0);
                            let fut = async move {
                                <T as ChaincodeSupport>::register(&inner, request).await
                            };
                            Box::pin(fut)
                        }
                    }
                    let accept_compression_encodings = self.accept_compression_encodings;
                    let send_compression_encodings = self.send_compression_encodings;
                    let max_decoding_message_size = self.max_decoding_message_size;
                    let max_encoding_message_size = self.max_encoding_message_size;
                    let inner = self.inner.clone();
                    let fut = async move {
                        let method = RegisterSvc(inner);
                        let codec = tonic_prost::ProstCodec::default();
                        let mut grpc = tonic::server::Grpc::new(codec)
                            .apply_compression_config(
                                accept_compression_encodings,
                                send_compression_encodings,
                            )
                            .apply_max_message_size_config(
                                max_decoding_message_size,
                                max_encoding_message_size,
                            );
                        let res = grpc.streaming(method, req).await;
                        Ok(res)
                    };
                    Box::pin(fut)
                }
                _ => {
                    Box::pin(async move {
                        let mut response = http::Response::new(
                            tonic::body::Body::default(),
                        );
                        let headers = response.headers_mut();
                        headers
                            .insert(
                                tonic::Status::GRPC_STATUS,
                                (tonic::Code::Unimplemented as i32).into(),
                            );
                        headers
                            .insert(
                                http::header::CONTENT_TYPE,
                                tonic::metadata::GRPC_CONTENT_TYPE,
                            );
                        Ok(response)
                    })
                }
            }
        }
    }
    impl<T> Clone for ChaincodeSupportServer<T> {
        fn clone(&self) -> Self {
            let inner = self.inner.clone();
            Self {
                inner,
                accept_compression_encodings: self.accept_compression_encodings,
                send_compression_encodings: self.send_compression_encodings,
                max_decoding_message_size: self.max_decoding_message_size,
                max_encoding_message_size: self.max_encoding_message_size,
            }
        }
    }
    /// Generated gRPC service name
    pub const SERVICE_NAME: &str = "protos.ChaincodeSupport";
    impl<T> tonic::server::NamedService for ChaincodeSupportServer<T> {
        const NAME: &'static str = SERVICE_NAME;
    }
}
/// Generated client implementations.
pub mod chaincode_client {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    /// Chaincode as a server - peer establishes a connection to the chaincode as a client
    /// Currently only supports a stream connection.
    #[derive(Debug, Clone)]
    pub struct ChaincodeClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl<T> ChaincodeClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::Body>,
        T::Error: Into<StdError>,
        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
    {
        pub fn new(inner: T) -> Self {
            let inner = tonic::client::Grpc::new(inner);
            Self { inner }
        }
        pub fn with_origin(inner: T, origin: Uri) -> Self {
            let inner = tonic::client::Grpc::with_origin(inner, origin);
            Self { inner }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> ChaincodeClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                http::Request<tonic::body::Body>,
                Response = http::Response<
                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
                >,
            >,
            <T as tonic::codegen::Service<
                http::Request<tonic::body::Body>,
            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
        {
            ChaincodeClient::new(InterceptedService::new(inner, interceptor))
        }
        /// Compress requests with the given encoding.
        ///
        /// This requires the server to support it otherwise it might respond with an
        /// error.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.send_compressed(encoding);
            self
        }
        /// Enable decompressing responses.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.accept_compressed(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_decoding_message_size(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_encoding_message_size(limit);
            self
        }
        pub async fn connect(
            &mut self,
            request: impl tonic::IntoStreamingRequest<Message = super::ChaincodeMessage>,
        ) -> std::result::Result<
            tonic::Response<tonic::codec::Streaming<super::ChaincodeMessage>>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static("/protos.Chaincode/Connect");
            let mut req = request.into_streaming_request();
            req.extensions_mut().insert(GrpcMethod::new("protos.Chaincode", "Connect"));
            self.inner.streaming(req, path, codec).await
        }
    }
}
/// Generated server implementations.
pub mod chaincode_server {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    /// Generated trait containing gRPC methods that should be implemented for use with ChaincodeServer.
    #[async_trait]
    pub trait Chaincode: std::marker::Send + std::marker::Sync + 'static {
        /// Server streaming response type for the Connect method.
        type ConnectStream: tonic::codegen::tokio_stream::Stream<
                Item = std::result::Result<super::ChaincodeMessage, tonic::Status>,
            >
            + std::marker::Send
            + 'static;
        async fn connect(
            &self,
            request: tonic::Request<tonic::Streaming<super::ChaincodeMessage>>,
        ) -> std::result::Result<tonic::Response<Self::ConnectStream>, tonic::Status>;
    }
    /// Chaincode as a server - peer establishes a connection to the chaincode as a client
    /// Currently only supports a stream connection.
    #[derive(Debug)]
    pub struct ChaincodeServer<T> {
        inner: Arc<T>,
        accept_compression_encodings: EnabledCompressionEncodings,
        send_compression_encodings: EnabledCompressionEncodings,
        max_decoding_message_size: Option<usize>,
        max_encoding_message_size: Option<usize>,
    }
    impl<T> ChaincodeServer<T> {
        pub fn new(inner: T) -> Self {
            Self::from_arc(Arc::new(inner))
        }
        pub fn from_arc(inner: Arc<T>) -> Self {
            Self {
                inner,
                accept_compression_encodings: Default::default(),
                send_compression_encodings: Default::default(),
                max_decoding_message_size: None,
                max_encoding_message_size: None,
            }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> InterceptedService<Self, F>
        where
            F: tonic::service::Interceptor,
        {
            InterceptedService::new(Self::new(inner), interceptor)
        }
        /// Enable decompressing requests with the given encoding.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.accept_compression_encodings.enable(encoding);
            self
        }
        /// Compress responses with the given encoding, if the client supports it.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.send_compression_encodings.enable(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.max_decoding_message_size = Some(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.max_encoding_message_size = Some(limit);
            self
        }
    }
    impl<T, B> tonic::codegen::Service<http::Request<B>> for ChaincodeServer<T>
    where
        T: Chaincode,
        B: Body + std::marker::Send + 'static,
        B::Error: Into<StdError> + std::marker::Send + 'static,
    {
        type Response = http::Response<tonic::body::Body>;
        type Error = std::convert::Infallible;
        type Future = BoxFuture<Self::Response, Self::Error>;
        fn poll_ready(
            &mut self,
            _cx: &mut Context<'_>,
        ) -> Poll<std::result::Result<(), Self::Error>> {
            Poll::Ready(Ok(()))
        }
        fn call(&mut self, req: http::Request<B>) -> Self::Future {
            match req.uri().path() {
                "/protos.Chaincode/Connect" => {
                    #[allow(non_camel_case_types)]
                    struct ConnectSvc<T: Chaincode>(pub Arc<T>);
                    impl<
                        T: Chaincode,
                    > tonic::server::StreamingService<super::ChaincodeMessage>
                    for ConnectSvc<T> {
                        type Response = super::ChaincodeMessage;
                        type ResponseStream = T::ConnectStream;
                        type Future = BoxFuture<
                            tonic::Response<Self::ResponseStream>,
                            tonic::Status,
                        >;
                        fn call(
                            &mut self,
                            request: tonic::Request<
                                tonic::Streaming<super::ChaincodeMessage>,
                            >,
                        ) -> Self::Future {
                            let inner = Arc::clone(&self.0);
                            let fut = async move {
                                <T as Chaincode>::connect(&inner, request).await
                            };
                            Box::pin(fut)
                        }
                    }
                    let accept_compression_encodings = self.accept_compression_encodings;
                    let send_compression_encodings = self.send_compression_encodings;
                    let max_decoding_message_size = self.max_decoding_message_size;
                    let max_encoding_message_size = self.max_encoding_message_size;
                    let inner = self.inner.clone();
                    let fut = async move {
                        let method = ConnectSvc(inner);
                        let codec = tonic_prost::ProstCodec::default();
                        let mut grpc = tonic::server::Grpc::new(codec)
                            .apply_compression_config(
                                accept_compression_encodings,
                                send_compression_encodings,
                            )
                            .apply_max_message_size_config(
                                max_decoding_message_size,
                                max_encoding_message_size,
                            );
                        let res = grpc.streaming(method, req).await;
                        Ok(res)
                    };
                    Box::pin(fut)
                }
                _ => {
                    Box::pin(async move {
                        let mut response = http::Response::new(
                            tonic::body::Body::default(),
                        );
                        let headers = response.headers_mut();
                        headers
                            .insert(
                                tonic::Status::GRPC_STATUS,
                                (tonic::Code::Unimplemented as i32).into(),
                            );
                        headers
                            .insert(
                                http::header::CONTENT_TYPE,
                                tonic::metadata::GRPC_CONTENT_TYPE,
                            );
                        Ok(response)
                    })
                }
            }
        }
    }
    impl<T> Clone for ChaincodeServer<T> {
        fn clone(&self) -> Self {
            let inner = self.inner.clone();
            Self {
                inner,
                accept_compression_encodings: self.accept_compression_encodings,
                send_compression_encodings: self.send_compression_encodings,
                max_decoding_message_size: self.max_decoding_message_size,
                max_encoding_message_size: self.max_encoding_message_size,
            }
        }
    }
    /// Generated gRPC service name
    pub const SERVICE_NAME: &str = "protos.Chaincode";
    impl<T> tonic::server::NamedService for ChaincodeServer<T> {
        const NAME: &'static str = SERVICE_NAME;
    }
}
/// ApplicationPolicy captures the diffenrent policy types that
/// are set and evaluted at the application level.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ApplicationPolicy {
    #[prost(oneof = "application_policy::Type", tags = "1, 2")]
    pub r#type: ::core::option::Option<application_policy::Type>,
}
/// Nested message and enum types in `ApplicationPolicy`.
pub mod application_policy {
    #[derive(serde::Serialize, serde::Deserialize)]
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Type {
        /// SignaturePolicy type is used if the policy is specified as
        /// a combination (using threshold gates) of signatures from MSP
        /// principals
        #[prost(message, tag = "1")]
        SignaturePolicy(super::super::common::SignaturePolicyEnvelope),
        /// ChannelConfigPolicyReference is used when the policy is
        /// specified as a string that references a policy defined in
        /// the configuration of the channel
        #[prost(string, tag = "2")]
        ChannelConfigPolicyReference(::prost::alloc::string::String),
    }
}
/// CollectionConfigPackage represents an array of CollectionConfig
/// messages; the extra struct is required because repeated oneof is
/// forbidden by the protobuf syntax
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CollectionConfigPackage {
    #[prost(message, repeated, tag = "1")]
    pub config: ::prost::alloc::vec::Vec<CollectionConfig>,
}
/// CollectionConfig defines the configuration of a collection object;
/// it currently contains a single, static type.
/// Dynamic collections are deferred.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CollectionConfig {
    #[prost(oneof = "collection_config::Payload", tags = "1")]
    pub payload: ::core::option::Option<collection_config::Payload>,
}
/// Nested message and enum types in `CollectionConfig`.
pub mod collection_config {
    #[derive(serde::Serialize, serde::Deserialize)]
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Payload {
        #[prost(message, tag = "1")]
        StaticCollectionConfig(super::StaticCollectionConfig),
    }
}
/// StaticCollectionConfig constitutes the configuration parameters of a
/// static collection object. Static collections are collections that are
/// known at chaincode instantiation time, and that cannot be changed.
/// Dynamic collections are deferred.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StaticCollectionConfig {
    /// the name of the collection inside the denoted chaincode
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
    /// a reference to a policy residing / managed in the config block
    /// to define which orgs have access to this collection’s private data
    #[prost(message, optional, tag = "2")]
    pub member_orgs_policy: ::core::option::Option<CollectionPolicyConfig>,
    /// The minimum number of peers private data will be sent to upon
    /// endorsement. The endorsement would fail if dissemination to at least
    /// this number of peers is not achieved.
    #[prost(int32, tag = "3")]
    pub required_peer_count: i32,
    /// The maximum number of peers that private data will be sent to
    /// upon endorsement. This number has to be bigger than required_peer_count.
    #[prost(int32, tag = "4")]
    pub maximum_peer_count: i32,
    /// The number of blocks after which the collection data expires.
    /// For instance if the value is set to 10, a key last modified by block number 100
    /// will be purged at block number 111. A zero value is treated same as MaxUint64
    #[prost(uint64, tag = "5")]
    pub block_to_live: u64,
    /// The member only read access denotes whether only collection member clients
    /// can read the private data (if set to true), or even non members can
    /// read the data (if set to false, for example if you want to implement more granular
    /// access logic in the chaincode)
    #[prost(bool, tag = "6")]
    pub member_only_read: bool,
    /// The member only write access denotes whether only collection member clients
    /// can write the private data (if set to true), or even non members can
    /// write the data (if set to false, for example if you want to implement more granular
    /// access logic in the chaincode)
    #[prost(bool, tag = "7")]
    pub member_only_write: bool,
    /// a reference to a policy residing / managed in the config block
    /// to define the endorsement policy for this collection
    #[prost(message, optional, tag = "8")]
    pub endorsement_policy: ::core::option::Option<ApplicationPolicy>,
}
/// Collection policy configuration. Initially, the configuration can only
/// contain a SignaturePolicy. In the future, the SignaturePolicy may be a
/// more general Policy. Instead of containing the actual policy, the
/// configuration may in the future contain a string reference to a policy.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CollectionPolicyConfig {
    #[prost(oneof = "collection_policy_config::Payload", tags = "1")]
    pub payload: ::core::option::Option<collection_policy_config::Payload>,
}
/// Nested message and enum types in `CollectionPolicyConfig`.
pub mod collection_policy_config {
    #[derive(serde::Serialize, serde::Deserialize)]
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Payload {
        /// Initially, only a signature policy is supported.
        ///
        /// Later, the SignaturePolicy will be replaced by a Policy.
        ///         Policy policy = 1;
        /// A reference to a Policy is planned to be added later.
        ///         string reference = 2;
        #[prost(message, tag = "1")]
        SignaturePolicy(super::super::common::SignaturePolicyEnvelope),
    }
}