github.com/adnan-c/fabric_e2e_couchdb@v0.6.1-preview.0.20170228180935-21ce6b23cf91/core/chaincode/shim/response.go (about)

     1  /*Copyright IBM Corp. 2016 All Rights Reserved.
     2  
     3  Licensed under the Apache License, Version 2.0 (the "License");
     4  you may not use this file except in compliance with the License.
     5  You may obtain a copy of the License at
     6  
     7  		 http://www.apache.org/licenses/LICENSE-2.0
     8  
     9  Unless required by applicable law or agreed to in writing, software
    10  distributed under the License is distributed on an "AS IS" BASIS,
    11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  See the License for the specific language governing permissions and
    13  limitations under the License.
    14  */
    15  
    16  package shim
    17  
    18  import (
    19  	pb "github.com/hyperledger/fabric/protos/peer"
    20  )
    21  
    22  const (
    23  	// If status code less than 500, endorser will endorse it.
    24  	// OK means init or invoke successfully.
    25  	OK = 200
    26  
    27  	// Code that greater than or equal to 500 will be considered an error and rejected by endorser.
    28  	ERROR = 500
    29  )
    30  
    31  func Success(payload []byte) pb.Response {
    32  	return pb.Response{
    33  		Status:  OK,
    34  		Payload: payload,
    35  	}
    36  }
    37  
    38  func Error(msg string) pb.Response {
    39  	return pb.Response{
    40  		Status:  ERROR,
    41  		Message: msg,
    42  	}
    43  }