Documentation
¶
Index ¶
- Variables
- func Close()
- func Init() (err error)
- type AssetsContract
- type Client
- type DevicesContract
- func (dc *DevicesContract) Exists(id string) (bool, error)
- func (dc *DevicesContract) ListenCommands(ctx context.Context, deviceID string, ...) error
- func (dc *DevicesContract) Retrieve(id string) (*models.Device, error)
- func (dc *DevicesContract) SubmitCommandResults(id string, req requests.DeviceCommandResultsSubmitRequest) error
- func (dc *DevicesContract) Subscribe(ctx context.Context, event string, action func(*models.Device, string) error) error
- func (dc *DevicesContract) Unbind(id string) error
- func (dc *DevicesContract) Update(id string, req requests.DeviceUpdateRequest) error
- type ReadingsContract
- type RequirementsContract
Constants ¶
This section is empty.
Variables ¶
var ( // Contracts exposes blockchain network SmartContracts pool. Contracts = struct { Devices *DevicesContract Assets *AssetsContract Requirements *RequirementsContract Readings *ReadingsContract }{ Devices: &DevicesContract{}, Assets: &AssetsContract{}, Requirements: &RequirementsContract{}, Readings: &ReadingsContract{}, } )
Functions ¶
Types ¶
type AssetsContract ¶
type AssetsContract struct {
// contains filtered or unexported fields
}
AssetsContract defines interface for communication with assets-managing Smart Contract.
func (*AssetsContract) Receive ¶
func (ac *AssetsContract) Receive(query requests.AssetsQuery) ([]*models.Asset, error)
Receive retrieves models.Asset records from blockchain ledger by a given `query`.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client defines an interface for communicating with blockchain network.
type DevicesContract ¶
type DevicesContract struct {
// contains filtered or unexported fields
}
DevicesContract defines access to blockchain Smart Contract for managing device.
func (*DevicesContract) Exists ¶
func (dc *DevicesContract) Exists(id string) (bool, error)
Exists verify whether the device with `id` exists on the blockchain ledger.
func (*DevicesContract) ListenCommands ¶
func (dc *DevicesContract) ListenCommands( ctx context.Context, deviceID string, handler func(id string, cmd models.DeviceCommand, args ...interface{}) error, ) error
ListenCommands subscribes and starts listening for device commands from the blockchain network.
func (*DevicesContract) Retrieve ¶
func (dc *DevicesContract) Retrieve(id string) (*models.Device, error)
Retrieve fetches models.Device from the blockchain ledger.
func (*DevicesContract) SubmitCommandResults ¶
func (dc *DevicesContract) SubmitCommandResults(id string, req requests.DeviceCommandResultsSubmitRequest) error
SubmitCommandResults submits command execution results to log them in the blockchain ledger.
func (*DevicesContract) Subscribe ¶
func (dc *DevicesContract) Subscribe( ctx context.Context, event string, action func(*models.Device, string) error, ) error
Subscribe listens to blockchain events related to device and triggers `action` on each event occurrence.
func (*DevicesContract) Unbind ¶
func (dc *DevicesContract) Unbind(id string) error
Unbind removes device from the blockchain ledger.
func (*DevicesContract) Update ¶
func (dc *DevicesContract) Update(id string, req requests.DeviceUpdateRequest) error
Update updates device on the blockchain ledger.
type ReadingsContract ¶
type ReadingsContract struct {
// contains filtered or unexported fields
}
ReadingsContract defines access to blockchain Smart Contract for managing metric readings.
func (*ReadingsContract) Post ¶
func (rc *ReadingsContract) Post(readings models.MetricReadings) error
Post sends models.MetricReadings record to blockchain network for processing.
type RequirementsContract ¶
type RequirementsContract struct {
// contains filtered or unexported fields
}
RequirementsContract defines access to blockchain Smart Contract for managing requirements.
func (*RequirementsContract) ReceiveFor ¶
func (rc *RequirementsContract) ReceiveFor(assets ...string) ([]*models.Requirements, error)
ReceiveFor retrieves models.Requirements records from blockchain ledger for a given `assets`.