Documentation
¶
Index ¶
- type Auction
- type BidHash
- type FullBid
- type SmartContract
- func (s *SmartContract) Bid(ctx contractapi.TransactionContextInterface, auctionID string) (string, error)
- func (s *SmartContract) CloseAuction(ctx contractapi.TransactionContextInterface, auctionID string) error
- func (s *SmartContract) CreateAuction(ctx contractapi.TransactionContextInterface, auctionID string, itemsold string) error
- func (s *SmartContract) EndAuction(ctx contractapi.TransactionContextInterface, auctionID string) error
- func (s *SmartContract) GetSubmittingClientIdentity(ctx contractapi.TransactionContextInterface) (string, error)
- func (s *SmartContract) QueryAuction(ctx contractapi.TransactionContextInterface, auctionID string) (*Auction, error)
- func (s *SmartContract) QueryBid(ctx contractapi.TransactionContextInterface, auctionID string, txID string) (*FullBid, error)
- func (s *SmartContract) RevealBid(ctx contractapi.TransactionContextInterface, auctionID string, txID string) error
- func (s *SmartContract) SubmitBid(ctx contractapi.TransactionContextInterface, auctionID string, txID string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Auction ¶
type Auction struct {
Type string `json:"objectType"`
ItemSold string `json:"item"`
Seller string `json:"seller"`
Orgs []string `json:"organizations"`
PrivateBids map[string]BidHash `json:"privateBids"`
RevealedBids map[string]FullBid `json:"revealedBids"`
Winner string `json:"winner"`
Price int `json:"price"`
Status string `json:"status"`
}
Auction data
type FullBid ¶
type FullBid struct {
Type string `json:"objectType"`
Price int `json:"price"`
Org string `json:"org"`
Bidder string `json:"bidder"`
}
FullBid is the structure of a revealed bid
type SmartContract ¶
type SmartContract struct {
contractapi.Contract
}
func (*SmartContract) Bid ¶
func (s *SmartContract) Bid(ctx contractapi.TransactionContextInterface, auctionID string) (string, error)
Bid is used to add a user's bid to the auction. The bid is stored in the private data collection on the peer of the bidder's organization. The function returns the transaction ID so that users can identify and query their bid
func (*SmartContract) CloseAuction ¶
func (s *SmartContract) CloseAuction(ctx contractapi.TransactionContextInterface, auctionID string) error
CloseAuction can be used by the seller to close the auction. This prevents bids from being added to the auction, and allows users to reveal their bid
func (*SmartContract) CreateAuction ¶
func (s *SmartContract) CreateAuction(ctx contractapi.TransactionContextInterface, auctionID string, itemsold string) error
CreateAuction creates on auction on the public channel. The identity that submits the transacion becomes the seller of the auction
func (*SmartContract) EndAuction ¶
func (s *SmartContract) EndAuction(ctx contractapi.TransactionContextInterface, auctionID string) error
EndAuction both changes the auction status to closed and calculates the winners of the auction
func (*SmartContract) GetSubmittingClientIdentity ¶
func (s *SmartContract) GetSubmittingClientIdentity(ctx contractapi.TransactionContextInterface) (string, error)
func (*SmartContract) QueryAuction ¶
func (s *SmartContract) QueryAuction(ctx contractapi.TransactionContextInterface, auctionID string) (*Auction, error)
QueryAuction allows all members of the channel to read a public auction
func (*SmartContract) QueryBid ¶
func (s *SmartContract) QueryBid(ctx contractapi.TransactionContextInterface, auctionID string, txID string) (*FullBid, error)
QueryBid allows the submitter of the bid to read their bid from public state
func (*SmartContract) RevealBid ¶
func (s *SmartContract) RevealBid(ctx contractapi.TransactionContextInterface, auctionID string, txID string) error
RevealBid is used by a bidder to reveal their bid after the auction is closed
func (*SmartContract) SubmitBid ¶
func (s *SmartContract) SubmitBid(ctx contractapi.TransactionContextInterface, auctionID string, txID string) error
SubmitBid is used by the bidder to add the hash of that bid stored in private data to the auction. Note that this function alters the auction in private state, and needs to meet the auction endorsement policy. Transaction ID is used identify the bid