Documentation ¶
Index ¶
- Constants
- Variables
- func ParamKeyTable() params.KeyTable
- func RegisterCodec(cdc *codec.Codec)
- func ValidateGenesis(data GenesisState) error
- type BankKeeper
- type ChannelUpdate
- type DataNode
- type DataRecord
- type DataRecordHash
- type GenesisState
- type MsgAddRecords
- type MsgSetOwner
- type MsgUpdateChannels
- type NewRecord
- type NodeChannel
- type ParamSubspace
- type Params
- type QueryResRecords
- type QueryResRecordsList
- type Record
Constants ¶
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 )
const ( QueryDataNode = "datanode" QueryRecords = "records" )
Query endpoints supported by the datanode querier
const (
AttributeValueCategory = ModuleName
)
datanode module event types
const (
DefaultParamspace = ModuleName
)
Default parameter namespace
Variables ¶
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") )
var ModuleCdc *codec.Codec
ModuleCdc defines the module codec
Functions ¶
func RegisterCodec ¶
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
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
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) 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) 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 (*Params) ParamSetPairs ¶
func (p *Params) ParamSetPairs() params.ParamSetPairs
ParamSetPairs - Implements params.ParamSet
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