Documentation
¶
Index ¶
- Constants
- Variables
- type ChaincodeDefinition
- type ChaincodePackage
- type ChaincodeUpdateProposal
- type ChaincodeUpdateProposalInput
- type DeploymentEventDetail
- type History
- type HistoryQueryParams
- type SmartContract
- func (s *SmartContract) Acknowledge(ctx contractapi.TransactionContextInterface, ...) error
- func (s *SmartContract) GetAllProposals(ctx contractapi.TransactionContextInterface) (map[string]*ChaincodeUpdateProposal, error)
- func (s *SmartContract) GetHistories(ctx contractapi.TransactionContextInterface, params HistoryQueryParams) (map[string]*History, error)
- func (s *SmartContract) GetProposal(ctx contractapi.TransactionContextInterface, proposalID string) (*ChaincodeUpdateProposal, error)
- func (s *SmartContract) GetVotingConfig(ctx contractapi.TransactionContextInterface) (*VotingConfig, error)
- func (s *SmartContract) NotifyCommitResult(ctx contractapi.TransactionContextInterface, ...) error
- func (s *SmartContract) RequestProposal(ctx contractapi.TransactionContextInterface, ...) (*ChaincodeUpdateProposal, error)
- func (s *SmartContract) SetMaxMaliciousOrgsInVotes(ctx contractapi.TransactionContextInterface, number int) error
- func (s *SmartContract) UnsetMaxMaliciousOrgsInVotes(ctx contractapi.TransactionContextInterface) error
- func (s *SmartContract) Vote(ctx contractapi.TransactionContextInterface, ...) error
- func (s *SmartContract) WithdrawProposal(ctx contractapi.TransactionContextInterface, proposalID string) error
- type TaskStatusUpdateRequest
- type VotingConfig
Constants ¶
const ( ProposalObjectType = "proposal" HistoryObjectType = "history" VotingConfigObjectType = "votingConfig" )
Object types
const ( NewProposalEvent = "newProposalEvent" NewVoteEvent = "newVoteEvent" PrepareToDeployEvent = "prepareToDeployEvent" DeployEvent = "deployEvent" CommittedEvent = "committedEvent" RejectedEvent = "rejectedEvent" WithdrawnEvent = "withdrawnEvent" )
Chaincode event names
const ( Vote = "vote" Acknowledge = "acknowledge" Commit = "commit" )
Task IDs
const ( Proposed = "proposed" Approved = "approved" Rejected = "rejected" Acknowledged = "acknowledged" Committed = "committed" Failed = "failed" // Unsupported Withdrawn = "withdrawn" )
Status for Proposal
const ( Agreed = "agreed" Disagreed = "disagreed" )
Status for Vote Tasks
const ( Success = "success" Failure = "failure" )
Status for Acknowledge and Commit Tasks
const ( ALL = "all" MAJORITY = "majority" )
Criteria for moving the next task
const ( ChannelOpsChaincodeNameEnv = "CH_OPS_CC_NAME" DefaultChannelOpsChaincodeName = "channel-ops" )
Const for channel-ops
Variables ¶
var ( // ErrProposalNotFound is returned when the requested object is not found. ErrProposalNotFound = fmt.Errorf("proposal not found") // ErrProposalIDAreadyInUse is returned when the requested proposal ID is already in use. ErrProposalIDAreadyInUse = fmt.Errorf("proposalID already in use") )
Functions ¶
This section is empty.
Types ¶
type ChaincodeDefinition ¶
type ChaincodeDefinition struct { Sequence int64 `json:"sequence"` InitRequired bool `json:"initRequired"` ValidationParameter string `json:"validationParameter"` Collections string `json:"collections,omitempty" metadata:",optional"` }
ChaincodeDefinition represents information on chaincode definition of a proposed update.
type ChaincodePackage ¶
type ChaincodePackage struct { Repository string `json:"repository"` CommitID string `json:"commitID"` PathToSourceFiles string `json:"pathToSourceFiles,omitempty" metadata:",optional"` Type string `json:"type"` }
ChaincodePackage represents information on chaincode package of a proposed update.
type ChaincodeUpdateProposal ¶
type ChaincodeUpdateProposal struct { ObjectType string `json:"docType"` //docType is used to distinguish the various types of objects in state database ID string `json:"ID"` Creator string `json:"creator"` ChannelID string `json:"channelID"` ChaincodeName string `json:"chaincodeName"` ChaincodePackage ChaincodePackage `json:"chaincodePackage"` ChaincodeDefinition ChaincodeDefinition `json:"chaincodeDefinition"` Status string `json:"status"` Time string `json:"time"` }
ChaincodeUpdateProposal describes a new chaincode update proposal that is stored as a state in the ledger.
type ChaincodeUpdateProposalInput ¶
type ChaincodeUpdateProposalInput struct { ID string `json:"ID"` ChannelID string `json:"channelID"` ChaincodeName string `json:"chaincodeName"` ChaincodePackage ChaincodePackage `json:"chaincodePackage"` ChaincodeDefinition ChaincodeDefinition `json:"chaincodeDefinition"` }
ChaincodeUpdateProposalInput represents a request input of a new chaincode update proposal.
type DeploymentEventDetail ¶
type DeploymentEventDetail struct { Proposal ChaincodeUpdateProposal `json:"proposal"` OperationTargets []string `json:"operationTargets"` }
DeploymentEventDetail represents details of DeploymentEvent.
type History ¶
type History struct { ObjectType string `json:"docType"` //docType is used to distinguish the various types of objects in state database ProposalID string `json:"proposalID"` TaskID string `json:"taskID"` OrgID string `json:"orgID"` Status string `json:"status"` Data string `json:"data"` Time string `json:"time"` }
History describes a history of each task (e.g., vote, chaincode commit), and which is stored as a state in the ledger.
type HistoryQueryParams ¶
type HistoryQueryParams struct { ProposalID string `json:"proposalID,omitempty"` TaskID string `json:"taskID,omitempty" metadata:",optional"` OrgID string `json:"orgID,omitempty" metadata:",optional"` }
HistoryQueryParams represents query parameters for getting histories from the ledger.
type SmartContract ¶
type SmartContract struct {
contractapi.Contract
}
SmartContract provides functions for operating chaincode
func (*SmartContract) Acknowledge ¶
func (s *SmartContract) Acknowledge(ctx contractapi.TransactionContextInterface, taskStatusUpdateRequest TaskStatusUpdateRequest) error
Acknowledge records the task status executed by agents for preparing the deployment based on the chaincode update proposal. This function records the result of the task as a state into the ledger. Also, if the proposal is acknowledged by ALL organizations, this changes the status of the proposal from approved to acknowledged.
Arguments:
0: taskStatusUpdateRequest - the task status executed by agents for preparing the deployment based on the chaincode update proposal
Returns:
0: error
Events:
(if the status is changed to acknowledged) name: DeployEvent(<proposalID>) payload: DeploymentEventDetail
func (*SmartContract) GetAllProposals ¶
func (s *SmartContract) GetAllProposals(ctx contractapi.TransactionContextInterface) (map[string]*ChaincodeUpdateProposal, error)
GetAllProposals returns the all chaincode update proposals.
Arguments: none
Returns:
0: the map of the all chaincode update proposals 1: error
func (*SmartContract) GetHistories ¶
func (s *SmartContract) GetHistories(ctx contractapi.TransactionContextInterface, params HistoryQueryParams) (map[string]*History, error)
GetHistories returns the histories with the given query parameters.
Arguments:
0: params - the history query parameters
Returns:
0: the map of the histories with the given query parameters 1: error
func (*SmartContract) GetProposal ¶
func (s *SmartContract) GetProposal(ctx contractapi.TransactionContextInterface, proposalID string) (*ChaincodeUpdateProposal, error)
GetProposal returns the proposal with the given ID.
Arguments:
0: params - the ID of the proposal
Returns:
0: the proposal with the given ID 1: error
func (*SmartContract) GetVotingConfig ¶
func (s *SmartContract) GetVotingConfig(ctx contractapi.TransactionContextInterface) (*VotingConfig, error)
GetVotingConfig returns the voting config.
Arguments: None
Returns:
0: the voting config (if voting config is not set, the func returns null) 1: error
func (*SmartContract) NotifyCommitResult ¶
func (s *SmartContract) NotifyCommitResult(ctx contractapi.TransactionContextInterface, taskStatusUpdateRequest TaskStatusUpdateRequest) error
NotifyCommitResult records the task status executed by agents for commiting the deployment based on the chaincode update proposal. This function records the result of the task as a state into the ledger. Also, if the proposal is acknowledged by ALL organizations, this changes the status of the proposal from acknowledged to committed.
Arguments:
0: taskStatusUpdateRequest - the task status executed by agents for commiting the deployment based on the chaincode update proposal
Returns:
0: error
Events:
(if the status is changed to acknowledged) name: CommittedEvent(<proposalID>) payload: nil
func (*SmartContract) RequestProposal ¶
func (s *SmartContract) RequestProposal(ctx contractapi.TransactionContextInterface, input ChaincodeUpdateProposalInput) (*ChaincodeUpdateProposal, error)
RequestProposal requests a new chaincode update proposal.
Arguments:
0: input - the request input for the chaincode update proposal
Returns:
0: the created proposal 1: error
Events:
(if the request can be approved without any other votes) name: PrepareToCommitEvent(<proposalID>) payload: DeploymentEventDetail (else) name: newProposalEvent(<proposalID>) payload: the created proposal
func (*SmartContract) SetMaxMaliciousOrgsInVotes ¶
func (s *SmartContract) SetMaxMaliciousOrgsInVotes(ctx contractapi.TransactionContextInterface, number int) error
SetMaxMaliciousOrgsInVotes sets number of max malicious orgs in votes.
Arguments:
0: number - number of max malicious orgs in votes
Returns:
0: error
func (*SmartContract) UnsetMaxMaliciousOrgsInVotes ¶
func (s *SmartContract) UnsetMaxMaliciousOrgsInVotes(ctx contractapi.TransactionContextInterface) error
UnsetMaxMaliciousOrgsInVotes unsets number of max malicious orgs in votes.
Arguments: None
Returns:
0: error
func (*SmartContract) Vote ¶
func (s *SmartContract) Vote(ctx contractapi.TransactionContextInterface, taskStatusUpdateRequest TaskStatusUpdateRequest) error
Vote votes for / against the chaincode update proposal. This function records the vote as a state into the ledger. Also, if the proposal is voted by MAJORITY, this changes the status of the proposal from proposed to approved.
Arguments:
0: taskStatusUpdateRequest - the request input for voting for/against the chaincode update proposal
Returns:
0: error
Events:
(if the status is changed to approved) name: PrepareToCommitEvent(<proposalID>) payload: DeploymentEventDetail (else) name: NewVoteEvent(<proposalID>) payload: nil
func (*SmartContract) WithdrawProposal ¶
func (s *SmartContract) WithdrawProposal(ctx contractapi.TransactionContextInterface, proposalID string) error
WithdrawProposal withdraws the chaincode update proposal. This only accepts the request from the proposing organization. This function is only available before the decision of the proposal.
Arguments:
0: proposalID - the ID for the chaincode update proposal
Returns:
0: error
Events:
name: withdrawnEvent(<proposalID>) payload: nil
type TaskStatusUpdateRequest ¶
type TaskStatusUpdateRequest struct { ProposalID string `json:"proposalID"` Status string `json:"status,omitempty" metadata:",optional"` Data string `json:"data,omitempty" metadata:",optional"` }
TaskStatusUpdateRequest represents a request input for updating a task status of a proposal.
type VotingConfig ¶
type VotingConfig struct { ObjectType string `json:"docType"` //docType is used to distinguish the various types of objects in state database MaxMaliciousOrgs int `json:"maxMaliciousOrgs"` }
VotingConfig represents voting config.