shared

package
v0.0.0-...-f8e0f19 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllIDRefs

func GetAllIDRefs(id string)

func InitConfig

func InitConfig()

InitConfig reades and fixes the config

func PrintConfig

func PrintConfig()

PrintConfig prints the full config to stdout

Types

type Address

type Address struct {
	Number  string
	Street  string
	City    string
	ZipCode string
	Country string
}

type Asset

type Asset struct {
	ID        string
	AssetType AssetType
	Refs      map[string]string
	Data      map[string]string
}

func (*Asset) ToCocoaBag

func (a *Asset) ToCocoaBag() *CocoaBag

toCocoaBag converts an Asset to CocoaBag struct

func (*Asset) ToFarm

func (a *Asset) ToFarm() *Farm

toCocoaBag converts an Asset to Farm struct

func (*Asset) ToFarmer

func (a *Asset) ToFarmer() *Farmer

toCocoaBag converts an Asset to Farmer struct

func (*Asset) ToJson

func (a *Asset) ToJson() ([]byte, error)

func (*Asset) ToPrettyJson

func (a *Asset) ToPrettyJson() ([]byte, error)

func (*Asset) UnmarshalJSON

func (a *Asset) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Asset using the helper class

type AssetType

type AssetType int64
const (
	AssetTypeCocoaBag AssetType = iota
	AssetTypeChocolateBar
	AssetTypeFarmer
	AssetTypeFarm
	AssetTypeFactory
	AssetTypeVendor
)

func (AssetType) MarshalJSON

func (at AssetType) MarshalJSON() ([]byte, error)

func (AssetType) String

func (at AssetType) String() string

func (*AssetType) UnmarshalJSON

func (at *AssetType) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

type ChainConnection

type ChainConnection struct {
	// contains filtered or unexported fields
}

func CreateChainConnection

func CreateChainConnection() *ChainConnection

func (*ChainConnection) CloseConnection

func (c *ChainConnection) CloseConnection()

func (*ChainConnection) CreateAsset

func (c *ChainConnection) CreateAsset(a *Asset) error

CreateAsset Creates an asset synchronously

func (*ChainConnection) DeleteAsset

func (c *ChainConnection) DeleteAsset(id string) (string, error)

DeleteAsset deletes a single Asset synchronously

func (*ChainConnection) GetAllAssets

func (c *ChainConnection) GetAllAssets() ([]Asset, error)

GetAllAssets Returns all Assets on the ledger

func (*ChainConnection) GetMetadata

func (c *ChainConnection) GetMetadata() (string, error)

GetMetadata returns all the metadata of the chaincode, e.g. available functions

func (*ChainConnection) InitLedger

func (c *ChainConnection) InitLedger()

InitLedger runs the InitLedger function on the chaincode, which currently creates some dummy assets

func (*ChainConnection) ReadAssetByID

func (c *ChainConnection) ReadAssetByID(id string) (Asset, error)

ReadAssetByID queries a single Asset

func (*ChainConnection) UpdateAsset

func (c *ChainConnection) UpdateAsset(a *Asset) error

UpdateAsset Creates an asset synchronously

type CocoaBag

type CocoaBag struct {
	ID               string
	Type             string
	Weight           int
	FarmReference    string
	FactoryReference string `json:",omitempty"`
	Price            int
	Currency         string
}

CocoaBag

func (*CocoaBag) ToAsset

func (c *CocoaBag) ToAsset() *Asset

ToAsset generalizes the Cocoabag to an Asset

func (*CocoaBag) ToJson

func (c *CocoaBag) ToJson() ([]byte, error)

ToJson converts the CocoaBag to json

func (*CocoaBag) ToPrettyJson

func (c *CocoaBag) ToPrettyJson() ([]byte, error)

ToJson converts the CocoaBag to human readable json

type Farm

type Farm struct {
	ID              string
	Name            string
	Address         Address
	Size            int
	FarmerReference string
}

Farm

func (*Farm) ToAsset

func (f *Farm) ToAsset() *Asset

ToAsset generalizes the Farm to an Asset

func (*Farm) ToJson

func (f *Farm) ToJson() ([]byte, error)

ToJson converts the Farm to json

func (*Farm) ToPrettyJson

func (f *Farm) ToPrettyJson() ([]byte, error)

ToJson converts the Farm to human readable json

type Farmer

type Farmer struct {
	ID        string
	Surname   string
	Firstname string
	Address   Address
	Phone     string
	Email     string
}

Farmer

func (*Farmer) ToAsset

func (f *Farmer) ToAsset() *Asset

ToAsset generalizes the Farmer to an Asset

func (*Farmer) ToJson

func (f *Farmer) ToJson() ([]byte, error)

ToJson converts the Farmer to json

func (*Farmer) ToPrettyJson

func (f *Farmer) ToPrettyJson() ([]byte, error)

ToJson converts the Farmer to human readable json

type HypercocoaConfig

type HypercocoaConfig struct {
	MspID         string
	CryptoPath    string
	CertPath      string
	KeyPath       string
	TlsCertPath   string
	PeerEndpoint  string
	GatewayPeer   string
	ChannelName   string
	ChaincodeName string
	// Config options for gateway mode
	BaseURL     string
	GatewayHost string
	GatewayPort string
}

config options for the chain connection

var Hyperconfig *HypercocoaConfig

Jump to

Keyboard shortcuts

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