contract

package
v0.0.0-...-0030b84 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

* Smart contracts and chaincode functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeviceRegistry

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

DeviceRegistry core utilities for managing devices on the ledger

func (*DeviceRegistry) Deregister

func (r *DeviceRegistry) Deregister(device *common.Device) error

Deregister remove a device from the ledger

func (*DeviceRegistry) Get

func (r *DeviceRegistry) Get(organizationId string, deviceId string) (*common.Device, error)

Get return a device by its organization ID and device ID

func (*DeviceRegistry) GetAll

func (r *DeviceRegistry) GetAll(organizationId string) ([]*common.Device, error)

GetAll return a list of devices by their organization ID

func (*DeviceRegistry) Register

func (r *DeviceRegistry) Register(device *common.Device) error

Register create or update a device in the ledger

type DeviceRegistryInterface

type DeviceRegistryInterface interface {
	// Register create or update a device in the ledger
	Register(device *common.Device) error

	// Get return a device by its organization ID and device ID
	Get(organizationId string, deviceId string) (*common.Device, error)

	// GetAll return a list of devices by their organization ID
	GetAll(organizationId string) ([]*common.Device, error)

	// Deregister remove a device from the ledger
	Deregister(device *common.Device) error
}

DeviceRegistryInterface core utilities for managing devices on the ledger

type DeviceRegistrySmartContract

type DeviceRegistrySmartContract struct {
	contractapi.Contract
}

DeviceRegistrySmartContract smart contract for managing devices on the ledger

func (*DeviceRegistrySmartContract) Deregister

Deregister remove a device and its services from the ledger

func (*DeviceRegistrySmartContract) Get

func (s *DeviceRegistrySmartContract) Get(ctx TransactionContextInterface, organizationId string, deviceId string) (*common.Device, error)

Get return a device by its organization ID and device ID

func (*DeviceRegistrySmartContract) GetAll

GetAll return a list of devices by their organization ID

func (*DeviceRegistrySmartContract) Register

Register create or update a device in the ledger

type ServiceBroker

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

ServiceBroker core utilities for managing IoT service requests and responses on the ledger

func (*ServiceBroker) Get

func (b *ServiceBroker) Get(requestId string) (*common.ServiceRequestResponse, error)

Get return an IoT service request and its response by the request ID

func (*ServiceBroker) GetAll

func (b *ServiceBroker) GetAll(organizationId string, deviceId string, serviceName string) ([]*common.ServiceRequestResponse, error)

GetAll return a list of IoT service requests and their responses by their organization ID, device ID, and service name

func (*ServiceBroker) Remove

func (b *ServiceBroker) Remove(requestId string) error

Remove remove a (request, response) pair from the ledger

func (*ServiceBroker) Request

func (b *ServiceBroker) Request(request *common.ServiceRequest) error

Request make a request to an IoT service

func (*ServiceBroker) Respond

func (b *ServiceBroker) Respond(response *common.ServiceResponse) error

Respond respond to an IoT service request

type ServiceBrokerInterface

type ServiceBrokerInterface interface {
	// Request make a request to an IoT service
	Request(request *common.ServiceRequest) error

	// Respond respond to an IoT service request
	Respond(response *common.ServiceResponse) error

	// Get return an IoT service request and its response by the request ID
	Get(requestId string) (*common.ServiceRequestResponse, error)

	// GetAll return a list of IoT service requests and their responses by their organization ID, device ID, and service name
	GetAll(organizationId string, deviceId string, serviceName string) ([]*common.ServiceRequestResponse, error)

	// Remove remove a (request, response) pair from the ledger
	Remove(requestId string) error
}

ServiceBrokerInterface core utilities for managing service requests on ledger

type ServiceBrokerSmartContract

type ServiceBrokerSmartContract struct {
	contractapi.Contract
}

ServiceBrokerSmartContract smart contract for managing IoT service requests and responses

func (*ServiceBrokerSmartContract) Get

Get return an IoT service request and its response by the request ID

func (*ServiceBrokerSmartContract) GetAll

func (s *ServiceBrokerSmartContract) GetAll(ctx TransactionContextInterface, organizationId string, deviceId string, serviceName string) ([]*common.ServiceRequestResponse, error)

GetAll return a list of IoT service requests and their responses by their organization ID, device ID, and service name

func (*ServiceBrokerSmartContract) Remove

Remove remove a (request, response) pair from the ledger

func (*ServiceBrokerSmartContract) Request

Request make a request to an IoT service

func (*ServiceBrokerSmartContract) Respond

Respond respond to an IoT service request

type ServiceRegistry

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

ServiceRegistry core utilities for managing services on the ledger

func (*ServiceRegistry) Deregister

func (r *ServiceRegistry) Deregister(service *common.Service) error

Deregister remove a service from the ledger

func (*ServiceRegistry) Get

func (r *ServiceRegistry) Get(organizationId string, deviceId string, name string) (*common.Service, error)

Get return a service by its organization ID, device ID, and name

func (*ServiceRegistry) GetAll

func (r *ServiceRegistry) GetAll(organizationId string, deviceId string) ([]*common.Service, error)

GetAll return a list of services by their organization ID and device ID

func (*ServiceRegistry) Register

func (r *ServiceRegistry) Register(service *common.Service) error

Register create or update a service in the ledger

type ServiceRegistryInterface

type ServiceRegistryInterface interface {
	// Register create or update a service in the ledger
	Register(service *common.Service) error

	// Get return a service by its organization ID, device ID, and name
	Get(organizationId string, deviceId string, serviceName string) (*common.Service, error)

	// GetAll return a list of services by their organization ID and device ID
	GetAll(organizationId string, deviceId string) ([]*common.Service, error)

	// Deregister remove a service from the ledger
	Deregister(service *common.Service) error
}

ServiceRegistryInterface core utilities for managing services on the ledger

type ServiceRegistrySmartContract

type ServiceRegistrySmartContract struct {
	contractapi.Contract
}

ServiceRegistrySmartContract smart contract for managing IoT services on the ledger

func (*ServiceRegistrySmartContract) Deregister

Deregister remove an IoT service and its request/responses from the ledger

func (*ServiceRegistrySmartContract) Get

func (s *ServiceRegistrySmartContract) Get(ctx TransactionContextInterface, organizationId string, deviceId string, name string) (*common.Service, error)

Get return a device by its organization ID, device ID, and name

func (*ServiceRegistrySmartContract) GetAll

func (s *ServiceRegistrySmartContract) GetAll(ctx TransactionContextInterface, organizationId string, deviceId string) ([]*common.Service, error)

GetAll return a list of devices by their organization ID and device ID

func (*ServiceRegistrySmartContract) Register

Register create or update an IoT service in the ledger

type StateInterface

type StateInterface interface {
	// GetKeyComponents return components that compose the state key
	GetKeyComponents() []string

	// Serialize transform current state object to JSON string
	Serialize() ([]byte, error)

	// Validate check if the state properties are valid
	Validate() error
}

StateInterface common ledger state interface

type StateRegistry

type StateRegistry struct {

	// Name name of the state list
	Name string

	// Deserialize create a new state instance from its JSON representation
	Deserialize func([]byte) (StateInterface, error)
	// contains filtered or unexported fields
}

StateRegistry default implementations of StateRegistryInterface

func (*StateRegistry) GetState

func (r *StateRegistry) GetState(key ...string) (StateInterface, error)

GetState return a state by its key

func (*StateRegistry) GetStates

func (r *StateRegistry) GetStates(key ...string) ([]StateInterface, error)

GetStates return a list of states by their partial composite key

func (*StateRegistry) PutState

func (r *StateRegistry) PutState(state StateInterface) error

PutState create or update a state in the ledger

func (*StateRegistry) RemoveState

func (r *StateRegistry) RemoveState(state StateInterface) error

RemoveState remove a state from the ledger

type StateRegistryInterface

type StateRegistryInterface interface {
	// PutState create or update a state in the ledger
	PutState(state StateInterface) error

	// GetState return a state by its key components
	GetState(keyComponents ...string) (StateInterface, error)

	// GetStates return a list of states by key components
	GetStates(keyComponents ...string) ([]StateInterface, error)

	// RemoveState remove a state from the ledger
	RemoveState(state StateInterface) error
}

StateRegistryInterface core utilities for managing a list of ledger states

type TransactionContext

type TransactionContext struct {
	contractapi.TransactionContext
	// contains filtered or unexported fields
}

TransactionContext an implementation of TransactionContextInterface

func (*TransactionContext) GetDeviceId

func (c *TransactionContext) GetDeviceId() (string, error)

GetDeviceId returns the ID associated with the invoking identity which is unique within the MSP

func (*TransactionContext) GetDeviceRegistry

func (c *TransactionContext) GetDeviceRegistry() DeviceRegistryInterface

GetDeviceRegistry get the device registry instance

func (*TransactionContext) GetOrganizationId

func (c *TransactionContext) GetOrganizationId() (string, error)

GetOrganizationId return the organization MSP ID

func (*TransactionContext) GetServiceBroker

func (c *TransactionContext) GetServiceBroker() ServiceBrokerInterface

GetServiceBroker get the device broker instance

func (*TransactionContext) GetServiceRegistry

func (c *TransactionContext) GetServiceRegistry() ServiceRegistryInterface

GetServiceRegistry get the device registry instance

type TransactionContextInterface

type TransactionContextInterface interface {
	contractapi.TransactionContextInterface

	// GetOrganizationId return the organization MSP ID
	GetOrganizationId() (string, error)

	// GetDeviceId returns the ID associated with the invoking identity which is unique within the MSP
	GetDeviceId() (string, error)

	// GetDeviceRegistry get the default instance of device registry
	GetDeviceRegistry() DeviceRegistryInterface

	// GetServiceRegistry get the default instance of service registry
	GetServiceRegistry() ServiceRegistryInterface

	// GetServiceBroker get the default instance of service broker
	GetServiceBroker() ServiceBrokerInterface
}

TransactionContextInterface extends the default transaction context with specific services

Jump to

Keyboard shortcuts

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