contract

package
v0.0.0-...-f47aca1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

candy contract is a fork of fabric chaincode.

Index

Constants

View Source
const (
	MetadataFile = "metadata.json"

	CodePackageFile = "code.tar.gz"
)
View Source
const (
	// ContractChannel is a channel for contracts update
	ContractChannel = byte(0x50)
)

Variables

View Source
var BaseDockerLabel = "candy"
View Source
var CommitSHA = "development build"
View Source
var Version = "latest"

Functions

func ContractFileName

func ContractFileName(packageID string) string

func RegisterContractMessage

func RegisterContractMessage(cdc *amino.Codec)

Types

type CodeDescriptor

type CodeDescriptor struct {
	Source       string // absolute path of the source to package
	MetadataRoot string // absolute path META-INF
	Path         string // import path of the package
	Module       bool   // does this represent a go module
}

CodeDescriptor describes the code we're packaging.

func DescribeCode

func DescribeCode(path string) (*CodeDescriptor, error)

DescribeCode returns GOPATH and package information.

type ContainerInstance

type ContainerInstance struct {
	CID      string
	Type     string
	DockerVM *DockerVM
}

func (*ContainerInstance) ContractServerInfo

func (ci *ContainerInstance) ContractServerInfo()

func (*ContainerInstance) Start

func (ci *ContainerInstance) Start(nodeAddress string) (string, string, error)

func (*ContainerInstance) Stop

func (ci *ContainerInstance) Stop() error

func (*ContainerInstance) Wait

func (ci *ContainerInstance) Wait() (int, error)

type ContractInterface

type ContractInterface interface {
	// BuildAndStart builds a docker image and start it
	BuildAndStart(cid string) (string, string, error)

	// SaveContract saves the contract to the contract store.
	SaveContract(contract *types.Contract) error

	// GetContract gets contract from disk
	GetContract(cId contractId) *types.Contract

	// QueryContractList gets all installed contacts
	QueryContractList() []string
}

type ContractManager

type ContractManager struct {
	service.BaseService

	Contracts []contractId
	// contains filtered or unexported fields
}

func NewContractManager

func NewContractManager(nodeAddress string, vm *DockerVM, support *cs.ContractSupport, server *cs.GRPCServer,
	requestsCh chan<- ContractRequest, errorCh chan<- peerError) *ContractManager

func (*ContractManager) AddContract

func (manager *ContractManager) AddContract(peerID p2p.ID, contract *types.Contract, contractSize int)

func (*ContractManager) BuildAndStart

func (manager *ContractManager) BuildAndStart(cId string) (string, string, error)

func (*ContractManager) CallContract

func (manager *ContractManager) CallContract(cId string, args [][]byte) (*pb.ContractOutput, error)

func (*ContractManager) GetContract

func (manager *ContractManager) GetContract(cId contractId) *types.Contract

func (*ContractManager) GetStatus

func (manager *ContractManager) GetStatus() (contracts []contractId, numPending int32, lenRequesters int)

func (*ContractManager) LostContracts

func (manager *ContractManager) LostContracts() (ids []contractId)

func (*ContractManager) OnStart

func (manager *ContractManager) OnStart() error

func (*ContractManager) OnStop

func (manager *ContractManager) OnStop()

func (*ContractManager) PeekContract

func (manager *ContractManager) PeekContract() *types.Contract

func (*ContractManager) PopRequest

func (manager *ContractManager) PopRequest(id contractId)

func (*ContractManager) QueryContractList

func (manager *ContractManager) QueryContractList() []string

func (*ContractManager) RedoRequest

func (manager *ContractManager) RedoRequest(id contractId) p2p.ID

func (*ContractManager) RemovePeer

func (manager *ContractManager) RemovePeer(peerID p2p.ID)

func (*ContractManager) SaveContract

func (manager *ContractManager) SaveContract(contract *types.Contract) error

func (*ContractManager) SetLogger

func (manager *ContractManager) SetLogger(l log.Logger)

func (*ContractManager) SetPeer

func (manager *ContractManager) SetPeer(peerID p2p.ID, ids []contractId)

type ContractMessage

type ContractMessage interface {
	ValidateBasic() error
}

type ContractPacakgeStreamer

type ContractPacakgeStreamer struct {
	PackagePath string
}

func (*ContractPacakgeStreamer) Code

func (*ContractPacakgeStreamer) Exists

func (cps *ContractPacakgeStreamer) Exists() bool

func (*ContractPacakgeStreamer) File

func (cps *ContractPacakgeStreamer) File(name string) (tarFileStream *TarFileStream, err error)

func (*ContractPacakgeStreamer) Metadata

func (*ContractPacakgeStreamer) MetadataBytes

func (cps *ContractPacakgeStreamer) MetadataBytes() ([]byte, error)

type ContractPackageLocator

type ContractPackageLocator struct {
	ContractDir string
}

func (*ContractPackageLocator) ContractPackageStreamer

func (cpl *ContractPackageLocator) ContractPackageStreamer(packageID string) *ContractPacakgeStreamer

type ContractPackageMetadata

type ContractPackageMetadata struct {
	Type  string `json:"type"`
	Path  string `json:"path"`
	Label string `json:"label"`
}

type ContractRequest

type ContractRequest struct {
	Id     contractId
	PeerID p2p.ID
}

type DockerBuildOption

type DockerBuildOption struct {
	Image        string
	Cmd          string
	Env          []string
	InputStream  io.Reader
	OutputStream io.Writer
}

type DockerVM

type DockerVM struct {
	// config
	service.BaseService
	// contains filtered or unexported fields
}

func NewDockerVM

func NewDockerVM(config *cfg.VMConfig, nodeId string, hostConfig *docker.HostConfig) (*DockerVM, error)

NewDockerVM returns a new docker client

func (*DockerVM) Build

func (vm *DockerVM) Build(cId string, metadata *ContractPackageMetadata, codePackage io.Reader) (Instance, error)

func (*DockerVM) GetVMName

func (vm *DockerVM) GetVMName(cID string) string

func (*DockerVM) GetVMNameForDocker

func (vm *DockerVM) GetVMNameForDocker(cId string) (string, error)

func (*DockerVM) HealthCheck

func (vm *DockerVM) HealthCheck(ctx context.Context) error

func (*DockerVM) SetLogger

func (vm *DockerVM) SetLogger(log log.Logger)

func (*DockerVM) Start

func (vm *DockerVM) Start(cID, cType string, address string) (string, string, error)

func (*DockerVM) Stop

func (vm *DockerVM) Stop(cID string) error

func (*DockerVM) Wait

func (vm *DockerVM) Wait(cID string) (int, error)

type FallbackPackageLocator

type FallbackPackageLocator struct {
	ContractPackageLocator *ContractPackageLocator
}

func (*FallbackPackageLocator) GetChaincodePackage

func (fpl *FallbackPackageLocator) GetChaincodePackage(packageID string) (*ContractPackageMetadata, []byte, io.ReadCloser, error)

type GolangPlatform

type GolangPlatform struct {
}

func (*GolangPlatform) GenerateDockerBuild

func (p *GolangPlatform) GenerateDockerBuild(cType, path string,
	codePackage io.Reader, client *docker.Client) (io.Reader, error)

----------------------------------------------------------------- generate dockerfile TODO use config's baseos and runtime

func (*GolangPlatform) GetDeploymentPayload

func (p *GolangPlatform) GetDeploymentPayload(codePath string) ([]byte, error)

func (*GolangPlatform) NormalizePath

func (p *GolangPlatform) NormalizePath(cType, path string) (string, error)

type Instance

type Instance interface {
	Start(nodeAddress string) (string, string, error)
	ContractServerInfo()
	Stop() error
	Wait() (int, error)
}

type ModuleInfo

type ModuleInfo struct {
	Dir        string
	GoMod      string
	ImportPath string
	ModulePath string
}

type PackageInfo

type PackageInfo struct {
	ImportPath     string
	Dir            string
	GoFiles        []string
	Goroot         bool
	CFiles         []string
	CgoFiles       []string
	HFiles         []string
	SFiles         []string
	IgnoredGoFiles []string
	Incomplete     bool
}

PackageInfo is the subset of data from `go list -deps -json` that's necessary to calculate chaincode package dependencies.

func (PackageInfo) Files

func (p PackageInfo) Files() []string

type PackageWriter

type PackageWriter interface {
	Write(name string, payload []byte, tw *tar.Writer) error
}

type PackageWriterWrapper

type PackageWriterWrapper func(name string, payload []byte, tw *tar.Writer) error

func (PackageWriterWrapper) Write

func (pw PackageWriterWrapper) Write(name string, payload []byte, tw *tar.Writer) error

type PlatformBuilder

type PlatformBuilder interface {
	GenerateDockerBuild(cType, path string, codePackage io.Reader, client *docker.Client) (io.Reader, error)
}

type PlatformRegistry

type PlatformRegistry interface {
	GetDeploymentPayload(path string) ([]byte, error)
	NormalizePath(cType, path string) (string, error)
}

type Reactor

type Reactor struct {
	p2p.BaseReactor
	// contains filtered or unexported fields
}

func NewContractReactor

func NewContractReactor(nodeAddress string, vm *DockerVM, support *cs.ContractSupport, server *cs.GRPCServer) *Reactor

NewContractReactor returns new reactor instance.

func (*Reactor) AddPeer

func (cR *Reactor) AddPeer(peer p2p.Peer)

func (*Reactor) BroadcastStatusRequest

func (cR *Reactor) BroadcastStatusRequest() error

func (*Reactor) GetChannels

func (cR *Reactor) GetChannels() []*p2p.ChannelDescriptor

func (*Reactor) GetManager

func (cR *Reactor) GetManager() *ContractManager

func (*Reactor) OnStart

func (cR *Reactor) OnStart() error

OnStart implements service.Service.

func (*Reactor) OnStop

func (cR *Reactor) OnStop()

OnStop implements service.Service.

func (*Reactor) Receive

func (cR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)

func (*Reactor) RemovePeer

func (cR *Reactor) RemovePeer(peer p2p.Peer, reason interface{})

func (*Reactor) SetLogger

func (cR *Reactor) SetLogger(l log.Logger)

SetLogger implements service.Service by setting the logger on reactor and contractManager.

type SourceDescriptor

type SourceDescriptor struct {
	Name string
	Path string
}

type SourceMap

type SourceMap map[string]SourceDescriptor

func (SourceMap) Directories

func (s SourceMap) Directories() []string

func (SourceMap) Sources

func (s SourceMap) Sources() Sources

type Sources

type Sources []SourceDescriptor

func (Sources) Len

func (s Sources) Len() int

func (Sources) Less

func (s Sources) Less(i, j int) bool

func (Sources) Swap

func (s Sources) Swap(i, j int)

type TarFileStream

type TarFileStream struct {
	TarFile    io.Reader
	FileStream io.Closer
}

func (*TarFileStream) Close

func (tfs *TarFileStream) Close() error

func (*TarFileStream) Read

func (tfs *TarFileStream) Read(p []byte) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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