types

package
v0.1.2-0...-bccb0d0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ModuleName is the name of the module
	ModuleName = "datanode"

	// StoreKey to be used when creating the KVStore
	StoreKey = ModuleName

	// RouterKey to be used for routing msgs
	RouterKey = ModuleName

	// QuerierRoute to be used for querierer msgs
	QuerierRoute = ModuleName
)
View Source
const (
	QueryDataNode = "datanode"
	QueryRecords  = "records"
)

Query endpoints supported by the datanode querier

View Source
const (
	AttributeValueCategory = ModuleName
)

datanode module event types

View Source
const (
	DefaultParamspace = ModuleName
)

Default parameter namespace

Variables

View Source
var (
	// ErrInvalidDataNode no datanode present with the given address
	ErrInvalidDataNode = sdkerrors.Register(ModuleName, 1, "no datanode present with the given address")
	// ErrInvalidDataNodeChannel no channel present with the given id on the datanode
	ErrInvalidDataNodeChannel = sdkerrors.Register(ModuleName, 2, "no channel present with the given id on the datanode")
	// ErrInvalidDataRecord no datarecord present with the given address
	ErrInvalidDataRecord = sdkerrors.Register(ModuleName, 3, "no datarecord present with the given hash")
)
View Source
var ModuleCdc *codec.Codec

ModuleCdc defines the module codec

Functions

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable for datanode module

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on codec

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the datanode genesis parameters

Types

type BankKeeper

type BankKeeper interface {
	SubtractCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, error)
	SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error
}

BankKeeper we expect to be able to substract and send coins for DataNode transfers and DataRecord append

type ChannelUpdate

type ChannelUpdate struct {
	Action   string `json:"action"`   // set, delete
	ID       string `json:"id"`       // channel within the datanode
	Variable string `json:"variable"` // variable of the channel (ex. temperature, humidity)
}

ChannelUpdate - channel update action definition

type DataNode

type DataNode struct {
	ID       sdk.AccAddress   `json:"id,omitempty"` // id of the datanode
	Owner    sdk.AccAddress   `json:"owner"`        // account address that owns the DataNode
	Name     string           `json:"name"`         // name of the datanode
	Channels []NodeChannel    `json:"channels"`     // channel definition
	Records  []DataRecordHash `json:"records"`      // datarecords associated to this DataNode
}

DataNode holds the configuration and the owner of the DataNode Device

func NewDataNode

func NewDataNode(address sdk.AccAddress, owner sdk.AccAddress) DataNode

NewDataNode returns a new DataNode with the ID

func (DataNode) String

func (d DataNode) String() string

implement fmt.Stringer

type DataRecord

type DataRecord struct {
	DataNode    sdk.AccAddress `json:"datanode"`  // datanode which push the records
	NodeChannel NodeChannel    `json:"channel"`   // channel within the datanode
	TimeFrame   int64          `json:"timeframe"` // timeframe of the datarecord
	Records     []Record       `json:"records"`   // records of the timerange
}

DataRecord is a time frame package of records

func NewDataRecord

func NewDataRecord(dataNode sdk.AccAddress, channel *NodeChannel, date int64) DataRecord

NewDataRecord returns a new DataRecord with the DataNode and the NodeChannel and empty records set

func (DataRecord) String

func (r DataRecord) String() string

implement fmt.Stringer

type DataRecordHash

type DataRecordHash [16]byte

DataRecordHash is the hash key of the records time frame

func GetActualDataRecordHash

func GetActualDataRecordHash(dataNode sdk.AccAddress, channel *NodeChannel) DataRecordHash

GetActualDataRecordHash returns the hash key to be used for KVStore at actual time

func GetDataRecordHash

func GetDataRecordHash(dataNode sdk.AccAddress, channel *NodeChannel, date int64) DataRecordHash

GetDataRecordHash returns the hash key to be used for KVStore

type GenesisState

type GenesisState struct {
	DataNodes   []DataNode   `json:"datanodes"`
	DataRecords []DataRecord `json:"datarecords"`
}

GenesisState - all datanode state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState - default GenesisState used by Cosmos Hub

func NewGenesisState

func NewGenesisState() GenesisState

NewGenesisState creates a new GenesisState object

type MsgAddRecords

type MsgAddRecords struct {
	DataNode sdk.AccAddress `json:"datanode"`
	Records  []NewRecord    `json:"records"`
}

MsgAddRecords - adds new records to the datarecord time frame

func NewMsgAddRecords

func NewMsgAddRecords(dataNode sdk.AccAddress, records []NewRecord) MsgAddRecords

NewMsgAddRecords is a constructor function for MsgAddRecords

func (MsgAddRecords) GetSignBytes

func (msg MsgAddRecords) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgAddRecords) GetSigners

func (msg MsgAddRecords) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required

func (MsgAddRecords) Route

func (msg MsgAddRecords) Route() string

Route should return the name of the module

func (MsgAddRecords) Type

func (msg MsgAddRecords) Type() string

Type should return the action

func (MsgAddRecords) ValidateBasic

func (msg MsgAddRecords) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type MsgSetOwner

type MsgSetOwner struct {
	DataNode sdk.AccAddress `json:"datanode"`
	Owner    sdk.AccAddress `json:"owner"`
	NewOwner sdk.AccAddress `json:"newowner"`
	Name     string         `json:"name"`
}

MsgSetOwner change the owner of a DataNode or creates a new one if doesn't exist

func NewMsgSetOwner

func NewMsgSetOwner(dataNode sdk.AccAddress, owner sdk.AccAddress, newOwner sdk.AccAddress, name string) MsgSetOwner

NewMsgSetOwner is a constructor function for MsgSetOwner

func (MsgSetOwner) GetSignBytes

func (msg MsgSetOwner) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgSetOwner) GetSigners

func (msg MsgSetOwner) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required

func (MsgSetOwner) Route

func (msg MsgSetOwner) Route() string

Route should return the name of the module

func (MsgSetOwner) Type

func (msg MsgSetOwner) Type() string

Type should return the action

func (MsgSetOwner) ValidateBasic

func (msg MsgSetOwner) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type MsgUpdateChannels

type MsgUpdateChannels struct {
	Owner    sdk.AccAddress  `json:"owner"`    // owner of the datanode
	DataNode sdk.AccAddress  `json:"datanode"` // datanode to update
	Updates  []ChannelUpdate `json:"channels"` // channels updates
}

MsgUpdateChannels - changes a channel on a datanode

func NewMsgUpdateChannels

func NewMsgUpdateChannels(owner sdk.AccAddress, dataNode sdk.AccAddress, updates []ChannelUpdate) MsgUpdateChannels

NewMsgUpdateChannels is a constructor function for MsgUpdateChannels

func (MsgUpdateChannels) GetSignBytes

func (msg MsgUpdateChannels) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgUpdateChannels) GetSigners

func (msg MsgUpdateChannels) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required

func (MsgUpdateChannels) Route

func (msg MsgUpdateChannels) Route() string

Route should return the name of the module

func (MsgUpdateChannels) Type

func (msg MsgUpdateChannels) Type() string

Type should return the action

func (MsgUpdateChannels) ValidateBasic

func (msg MsgUpdateChannels) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type NewRecord

type NewRecord struct {
	NodeChannelID string `json:"channel"`   // channel within the datanode
	TimeStamp     uint32 `json:"timestamp"` // timestamp in seconds since epoch
	Value         uint32 `json:"value"`     // numeric value of the record
	Misc          string `json:"misc"`      // miscellaneous data for other non numeric records
}

NewRecord - record to be added to the DataRecord time frame

type NodeChannel

type NodeChannel struct {
	ID       string `json:"id,omitempty"` // id of the channel
	Variable string `json:"variable"`     // variable of the channel (ex. temperature, humidity)
}

NodeChannel holds information about the data channel of the DataNode

type ParamSubspace

type ParamSubspace interface {
	WithKeyTable(table params.KeyTable) params.Subspace
	Get(ctx sdk.Context, key []byte, ptr interface{})
	GetParamSet(ctx sdk.Context, ps params.ParamSet)
	SetParamSet(ctx sdk.Context, ps params.ParamSet)
}

ParamSubspace defines the expected Subspace interfacace

type Params

type Params struct {
}

Params - used for initializing default parameter for datanode at genesis

func DefaultParams

func DefaultParams() Params

DefaultParams defines the parameters for this module

func NewParams

func NewParams() Params

NewParams creates a new Params object

func (*Params) ParamSetPairs

func (p *Params) ParamSetPairs() params.ParamSetPairs

ParamSetPairs - Implements params.ParamSet

func (Params) String

func (p Params) String() string

String implements the stringer interface for Params

type QueryResRecords

type QueryResRecords struct {
	TimeStamp uint32 `json:"ts"`    // timestamp in seconds since epoch
	Value     uint32 `json:"value"` // numeric value of the record
	Misc      string `json:"misc"`  // miscellaneous data for other non numeric records
}

QueryResRecords - queries result payload for a single record

type QueryResRecordsList

type QueryResRecordsList []QueryResRecords

QueryResRecordsList - queries result payload for datarecords within time frame

func (QueryResRecordsList) String

func (r QueryResRecordsList) String() string

implement fmt.Stringer

type Record

type Record struct {
	TimeStamp uint32 `json:"t"` // timestamp in seconds since epoch
	Value     uint32 `json:"v"` // numeric value of the record
	Misc      string `json:"m"` // miscellaneous data for other non numeric records
}

Record holds a single record from the DataNode device

func (Record) String

func (r Record) String() string

implement fmt.Stringer

Jump to

Keyboard shortcuts

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