github.com/adnan-c/fabric_e2e_couchdb@v0.6.1-preview.0.20170228180935-21ce6b23cf91/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  // PKIidType defines the type that holds the PKI-id
    20  // which is the security identifier of a peer
    21  type PKIidType []byte
    22  
    23  // MessageAcceptor is a predicate that is used to
    24  // determine in which messages the subscriber that created the
    25  // instance of the MessageAcceptor is interested in.
    26  type MessageAcceptor func(interface{}) bool
    27  
    28  // Payload defines an object that contains a ledger block
    29  type Payload struct {
    30  	ChainID ChainID // The channel's ID of the block
    31  	Data    []byte  // The content of the message, possibly encrypted or signed
    32  	Hash    string  // The message hash
    33  	SeqNum  uint64  // The message sequence number
    34  }
    35  
    36  // ChainID defines the identity representation of a chain
    37  type ChainID []byte
    38  
    39  // MessageReplacingPolicy Returns:
    40  // MESSAGE_INVALIDATES if this message invalidates that
    41  // MESSAGE_INVALIDATED if this message is invalidated by that
    42  // MESSAGE_NO_ACTION otherwise
    43  type MessageReplacingPolicy func(this interface{}, that interface{}) InvalidationResult
    44  
    45  // InvalidationResult determines how a message affects another message
    46  // when it is put into gossip message store
    47  type InvalidationResult int
    48  
    49  const (
    50  	// MessageNoAction means messages have no relation
    51  	MessageNoAction = iota
    52  	// MessageInvalidates means message invalidates the other message
    53  	MessageInvalidates
    54  	// MessageInvalidated means message is invalidated by the other message
    55  	MessageInvalidated
    56  )