github.com/adnan-c/fabric_e2e_couchdb@v0.6.1-preview.0.20170228180935-21ce6b23cf91/protos/common/common.proto (about) 1 /* 2 Copyright IBM Corp. 2016 All Rights Reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 syntax = "proto3"; 18 19 import "google/protobuf/timestamp.proto"; 20 21 option go_package = "github.com/hyperledger/fabric/protos/common"; 22 23 package common; 24 25 // These status codes are intended to resemble selected HTTP status codes 26 enum Status { 27 UNKNOWN = 0; 28 SUCCESS = 200; 29 BAD_REQUEST = 400; 30 FORBIDDEN = 403; 31 NOT_FOUND = 404; 32 REQUEST_ENTITY_TOO_LARGE = 413; 33 INTERNAL_SERVER_ERROR = 500; 34 SERVICE_UNAVAILABLE = 503; 35 } 36 37 enum HeaderType { 38 MESSAGE = 0; // Used for messages which are signed but opaque 39 CONFIG = 1; // Used for messages which express the channel config 40 CONFIG_UPDATE = 2; // Used for transactions which update the channel config 41 ENDORSER_TRANSACTION = 3; // Used by the SDK to submit endorser based transactions 42 ORDERER_TRANSACTION = 4; // Used internally by the orderer for management 43 DELIVER_SEEK_INFO = 5; // Used as the type for Envelope messages submitted to instruct the Deliver API to seek 44 } 45 46 // This enum enlists indexes of the block metadata array 47 enum BlockMetadataIndex { 48 SIGNATURES = 0; // Block metadata array position for block signatures 49 LAST_CONFIG = 1; // Block metadata array poistion to store last configuration block sequence number 50 TRANSACTIONS_FILTER = 2; // Block metadata array poistion to store serialized bit array filter of invalid transactions 51 ORDERER = 3; // Block metadata array position to store operational metadata for orderers 52 // e.g. For Kafka, this is where we store the last offset written to the local ledger. 53 } 54 55 // LastConfig is the encoded value for the Metadata message which is encoded in the LAST_CONFIGURATION block metadata index 56 message LastConfig { 57 uint64 index = 1; 58 } 59 60 // Metadata is a common structure to be used to encode block metadata 61 message Metadata { 62 bytes value = 1; 63 repeated MetadataSignature signatures = 2; 64 } 65 66 message MetadataSignature { 67 bytes signature_header = 1; // An encoded SignatureHeader 68 bytes signature = 2; // The signature over the concatenation of the Metadata value bytes, signatureHeader, and block header 69 } 70 71 message Header { 72 bytes channel_header = 1; 73 bytes signature_header = 2; 74 } 75 76 // Header is a generic replay prevention and identity message to include in a signed payload 77 message ChannelHeader { 78 int32 type = 1; // Header types 0-10000 are reserved and defined by HeaderType 79 80 // Version indicates message protocol version 81 int32 version = 2; 82 83 // Timestamp is the local time when the message was created 84 // by the sender 85 google.protobuf.Timestamp timestamp = 3; 86 87 // Identifier of the channel this message is bound for 88 string channel_id = 4; 89 90 // An unique identifier that is used end-to-end. 91 // - set by higher layers such as end user or SDK 92 // - passed to the endorser (which will check for uniqueness) 93 // - as the header is passed along unchanged, it will be 94 // be retrieved by the committer (uniqueness check here as well) 95 // - to be stored in the ledger 96 string tx_id = 5; 97 98 // The epoch in which this header was generated, where epoch is defined based on block height 99 // Epoch in which the response has been generated. This field identifies a 100 // logical window of time. A proposal response is accepted by a peer only if 101 // two conditions hold: 102 // 1. the epoch specified in the message is the current epoch 103 // 2. this message has been only seen once during this epoch (i.e. it hasn't 104 // been replayed) 105 uint64 epoch = 6; 106 107 // Extension that may be attached based on the header type 108 bytes extension = 7; 109 } 110 111 message SignatureHeader { 112 // Creator of the message, specified as a certificate chain 113 bytes creator = 1; 114 115 // Arbitrary number that may only be used once. Can be used to detect replay attacks. 116 bytes nonce = 2; 117 } 118 119 // Payload is the message contents (and header to allow for signing) 120 message Payload { 121 122 // Header is included to provide identity and prevent replay 123 Header header = 1; 124 125 // Data, the encoding of which is defined by the type in the header 126 bytes data = 2; 127 } 128 129 // Envelope wraps a Payload with a signature so that the message may be authenticated 130 message Envelope { 131 // A marshaled Payload 132 bytes payload = 1; 133 134 // A signature by the creator specified in the Payload header 135 bytes signature = 2; 136 } 137 138 // This is finalized block structure to be shared among the orderer and peer 139 // Note that the BlockHeader chains to the previous BlockHeader, and the BlockData hash is embedded 140 // in the BlockHeader. This makes it natural and obvious that the Data is included in the hash, but 141 // the Metadata is not. 142 message Block { 143 BlockHeader header = 1; 144 BlockData data = 2; 145 BlockMetadata metadata = 3; 146 } 147 148 // BlockHeader is the element of the block which forms the block chain 149 // The block header is hashed using the configured chain hashing algorithm 150 // over the ASN.1 encoding of the BlockHeader 151 message BlockHeader { 152 uint64 number = 1; // The position in the blockchain 153 bytes previous_hash = 2; // The hash of the previous block header 154 bytes data_hash = 3; // The hash of the BlockData, by MerkleTree 155 } 156 157 message BlockData { 158 repeated bytes data = 1; 159 } 160 161 message BlockMetadata { 162 repeated bytes metadata = 1; 163 }