common

package
v0.0.0-...-3b47f62 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyAndSumCode

func CopyAndSumCode(r io.Reader) ([]byte, *bytes.Buffer, error)

func DownloadCode

func DownloadCode(url string, retry int) (*http.Response, error)

func StoreCode

func StoreCode(codeDir string, r io.Reader) ([]byte, error)

func WriteCodeFile

func WriteCodeFile(codeDir string, codeID []byte, r io.Reader) error

Types

type CallContext

type CallContext interface {
	Sender() []byte
	BlockHash() []byte
	BlockHeight() uint64
	Input() []byte

	GetState(key []byte) []byte
	SetState(key, value []byte)
}

type Chaincode

type Chaincode interface {
	// Init is called when chaincode is deployed
	Init(ctx CallContext) error
	Invoke(ctx CallContext) error
	Query(ctx CallContext) ([]byte, error)
}

Chaincode all chaincodes implements this interface

type CodeDriver

type CodeDriver interface {
	// Install is called when code deployment transaction is received
	// Example data field - download url for code binary
	// After successful Install, getInstance should give a Chaincode instance without error
	Install(codeID, data []byte) error
	GetInstance(codeID []byte) (Chaincode, error)
}

type CodeInfo

type CodeInfo struct {
	DriverType DriverType `json:"driverType"`
	CodeID     []byte     `json:"codeID"`
}

type DeploymentInput

type DeploymentInput struct {
	CodeInfo    CodeInfo `json:"codeInfo"`
	InstallData []byte   `json:"installData"`
	InitInput   []byte   `json:"initInput"`
}

type DriverType

type DriverType uint8
const (
	DriverTypeNative DriverType = iota + 1
	DriverTypeBincc
	DriverTypeEVM
)

type MockCallContext

type MockCallContext struct {
	MockSender      []byte
	MockBlockHeight uint64
	MockBlockHash   []byte
	MockInput       []byte
	*MockState
}

func (*MockCallContext) BlockHash

func (wc *MockCallContext) BlockHash() []byte

func (*MockCallContext) BlockHeight

func (wc *MockCallContext) BlockHeight() uint64

func (*MockCallContext) Input

func (wc *MockCallContext) Input() []byte

func (*MockCallContext) Sender

func (wc *MockCallContext) Sender() []byte

type MockState

type MockState struct {
	StateMap    map[string][]byte
	VerifyError error
}

func NewMockState

func NewMockState() *MockState

func (*MockState) GetState

func (ms *MockState) GetState(key []byte) []byte

func (*MockState) SetState

func (ms *MockState) SetState(key, value []byte)

func (*MockState) VerifyState

func (ms *MockState) VerifyState(key []byte) ([]byte, error)

type QueryData

type QueryData struct {
	CodeAddr []byte
	Input    []byte
}

Jump to

Keyboard shortcuts

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