// Copyright the Hyperledger Fabric contributors. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

option java_package = "org.hyperledger.fabric.protos.peer";
option go_package = "github.com/hyperledger/fabric-protos-go/peer";

package protos;

import "common/configtx.proto";

// ChaincodeIdentifier identifies a piece of chaincode.  For a peer to accept invocations of
// this chaincode, the hash of the installed code must match, as must the version string
// included with the install command.
message ChaincodeIdentifier {
    bytes hash = 1;     // The hash of the chaincode bytes
    string version = 2; // A user friendly human readable name corresponding to the ID
}

// ChaincodeValidation instructs the peer how transactions for this chaincode should be
// validated.  The only validation mechanism which ships with fabric today is the standard
// 'vscc' validation mechanism.  This built in validation method utilizes an endorsement policy
// which checks that a sufficient number of signatures have been included.  The 'arguement'
// field encodes any parameters required by the validation implementation.
message ChaincodeValidation {
    string name = 1;    // Specifies which code to run to validate transactions, defaults to 'vscc'
    bytes argument = 2; // When 'vscc' a marshaled VSCCArgs
}

// VSCCArgs is passed (marshaled) as a parameter to the VSCC imlementation via the
// argument field of the ChaincodeValidation message.
message VSCCArgs {
    string endorsement_policy_ref = 1;  // A named reference to an endorsement policy,
                                        // for instance /Channel/Application/Writers
}

// ChaincodeEndorsement instructs the peer how transactions should be endorsed.  The only
// endorsement mechanism which ships with the fabric today is the standard 'escc' mechanism.
// This code simply simulates the proposal to generate a RW set, then signs the result
// using the peer's local signing identity.
message ChaincodeEndorsement {
    string name = 1; // Specifies what code to run for endorsements, defaults 'escc'
    // Eventually we may wish add an arg here, just like the ChaincodeValidation message, but
    // omitting now until there is a need for it.
}

// ConfigTree encapsulates channel and resources configuration of a channel.
// Both configurations are represented as common.Config
message ConfigTree {
    common.Config channel_config = 1;
    common.Config resources_config = 2;
}
