github.com/leonlxy/hyperledger@v1.0.0-alpha.0.20170427033203-34922035d248/gossip/common/common.go (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 package common 18 19 func init() { 20 // This is just to satisfy the code coverage tool 21 // miss any methods 22 switch true { 23 24 } 25 } 26 27 // PKIidType defines the type that holds the PKI-id 28 // which is the security identifier of a peer 29 type PKIidType []byte 30 31 // MessageAcceptor is a predicate that is used to 32 // determine in which messages the subscriber that created the 33 // instance of the MessageAcceptor is interested in. 34 type MessageAcceptor func(interface{}) bool 35 36 // Payload defines an object that contains a ledger block 37 type Payload struct { 38 ChainID ChainID // The channel's ID of the block 39 Data []byte // The content of the message, possibly encrypted or signed 40 Hash string // The message hash 41 SeqNum uint64 // The message sequence number 42 } 43 44 // ChainID defines the identity representation of a chain 45 type ChainID []byte 46 47 // MessageReplacingPolicy Returns: 48 // MESSAGE_INVALIDATES if this message invalidates that 49 // MESSAGE_INVALIDATED if this message is invalidated by that 50 // MESSAGE_NO_ACTION otherwise 51 type MessageReplacingPolicy func(this interface{}, that interface{}) InvalidationResult 52 53 // InvalidationResult determines how a message affects another message 54 // when it is put into gossip message store 55 type InvalidationResult int 56 57 const ( 58 // MessageNoAction means messages have no relation 59 MessageNoAction = iota 60 // MessageInvalidates means message invalidates the other message 61 MessageInvalidates 62 // MessageInvalidated means message is invalidated by the other message 63 MessageInvalidated 64 )