core

package
v0.0.0-...-db48615 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProposalObjectType     = "proposal"
	HistoryObjectType      = "history"
	VotingConfigObjectType = "votingConfig"
)

Object types

View Source
const (
	NewProposalEvent     = "newProposalEvent"
	NewVoteEvent         = "newVoteEvent"
	PrepareToDeployEvent = "prepareToDeployEvent"
	DeployEvent          = "deployEvent"
	CommittedEvent       = "committedEvent"
	RejectedEvent        = "rejectedEvent"
	WithdrawnEvent       = "withdrawnEvent"
)

Chaincode event names

View Source
const (
	Vote        = "vote"
	Acknowledge = "acknowledge"
	Commit      = "commit"
)

Task IDs

View Source
const (
	Proposed     = "proposed"
	Approved     = "approved"
	Rejected     = "rejected"
	Acknowledged = "acknowledged"
	Committed    = "committed"
	Failed       = "failed" // Unsupported
	Withdrawn    = "withdrawn"
)

Status for Proposal

View Source
const (
	Agreed    = "agreed"
	Disagreed = "disagreed"
)

Status for Vote Tasks

View Source
const (
	Success = "success"
	Failure = "failure"
)

Status for Acknowledge and Commit Tasks

View Source
const (
	ALL      = "all"
	MAJORITY = "majority"
)

Criteria for moving the next task

View Source
const (
	ChannelOpsChaincodeNameEnv     = "CH_OPS_CC_NAME"
	DefaultChannelOpsChaincodeName = "channel-ops"
)

Const for channel-ops

Variables

View Source
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

GetAllProposals returns the all chaincode update proposals.

Arguments: none

Returns:

0: the map of the all chaincode update proposals
1: error

func (*SmartContract) GetHistories

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

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

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

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

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.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL