value

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: BSD-3-Clause Imports: 11 Imported by: 2

Documentation

Overview

Package value implements a simple native contract that can store, delete, and display values.

Index

Constants

View Source
const (
	// ContractUID is the unique (4-bytes) identifier of the contract, it is
	// used to prefix keys in the K/V store and by DARCs for access control.
	ContractUID = "VALU"

	// ContractName is the name of the contract.
	ContractName = "go.dedis.ch/dela.Value"

	// KeyArg is the argument's name in the transaction that contains the
	// provided key to update.
	KeyArg = "value:key"

	// ValueArg is the argument's name in the transaction that contains the
	// provided value to set.
	ValueArg = "value:value"

	// CmdArg is the argument's name to indicate the kind of command we want to
	// run on the contract. Should be one of the Command type.
	CmdArg = "value:command"

	// CredentialAllCommand defines the credential command that is allowed to
	// perform all commands.
	CredentialAllCommand = "all"
)

Variables

This section is empty.

Functions

func NewCreds

func NewCreds() access.Credential

NewCreds creates new credentials for a value contract execution. We might want to use in the future a separate credential for each command.

func RegisterContract

func RegisterContract(exec *native.Service, c Contract)

RegisterContract registers the value contract to the given execution service.

Types

type Command

type Command string

Command defines a type of command for the value contract

const (
	// CmdWrite defines the command to write a value
	CmdWrite Command = "WRITE"

	// CmdRead defines a command to read a value
	CmdRead Command = "READ"

	// CmdDelete defines a command to delete a value
	CmdDelete Command = "DELETE"

	// CmdList defines a command to list all values set (and not deleted)
	// so far.
	CmdList Command = "LIST"
)

type Contract

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

Contract is a simple smart contract that allows one to handle the storage by performing CRUD operations.

- implements native.Contract

func NewContract

func NewContract(srvc access.Service) Contract

NewContract creates a new Value contract

func (Contract) Execute

func (c Contract) Execute(snap store.Snapshot, step execution.Step) error

Execute implements native.Contract. It runs the appropriate command.

func (Contract) UID

func (c Contract) UID() string

UID returns the unique 4-bytes contract identifier.

- implements native.Contract

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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