Documentation ¶
Overview ¶
Package handler defines the commands and command handlers that storage service's reply controller supports
Index ¶
- Constants
- Variables
- func AbiRegister(request message.Request, _ *log.Logger, extensions ...*remote.ClientSocket) message.Reply
- func ConfigurationGet(request message.Request, _ *log.Logger, extensions ...*remote.ClientSocket) message.Reply
- func RegisterCommands(c *controller.Controller, extensions ...string)
- func SmartcontractRegister(request message.Request, _ *log.Logger, extensions ...*remote.ClientSocket) message.Reply
- type GetAbiReply
- type GetAbiRequest
- type GetConfigurationReply
- type GetConfigurationRequest
- type GetSmartcontractReply
- type GetSmartcontractRequest
- type SetAbiReply
- type SetAbiRequest
- type SetConfigurationReply
- type SetConfigurationRequest
- type SetSmartcontractReply
- type SetSmartcontractRequest
Constants ¶
const ( // GetAbi Direct GetAbi string = "abi_get" // SetAbi Through the router SetAbi string = "abi_set" // GetConfiguration Through the router GetConfiguration string = "configuration_get" // SetConfiguration Through the router SetConfiguration string = "configuration_set" // SetSmartcontract Through the router SetSmartcontract string = "smartcontract_set" // GetSmartcontract Direct GetSmartcontract string = "smartcontract_get" )
Variables ¶
var AbiGet = func(request message.Request, _ *log.Logger, extensions ...*remote.ClientSocket) message.Reply { dbCon := remote.FindClient(extensions, "github.com/ahmetson/w3storage-extension") if dbCon == nil { return message.Fail("missing extension") } var reqParameters GetAbiRequest err := request.Parameters.Interface(&reqParameters) if err != nil { return message.Fail("request.Parameters -> Command Parameter: " + err.Error()) } if len(reqParameters.Id) == 0 { return message.Fail("missing abi id") } var selectedAbi = abi.Abi{Id: reqParameters.Id} saveErr := selectedAbi.Select(dbCon) if saveErr != nil { return message.Fail("database error:" + saveErr.Error()) } replyMessage, err := command.Reply(selectedAbi) if err != nil { return message.Fail("failed to reply") } return replyMessage }
AbiGet returns the abi Depends on the database extension
var ConfigurationRegister = func(request message.Request, _ *log.Logger, extensions ...*remote.ClientSocket) message.Reply { var conf SetConfigurationRequest err := request.Parameters.Interface(&conf) if err != nil { return message.Fail("failed to parse data") } if err := conf.Validate(); err != nil { return message.Fail("validation: " + err.Error()) } dbCon := remote.FindClient(extensions, "github.com/ahmetson/w3storage-extension") if dbCon == nil { return message.Fail("missing extension") } var crud database.Crud = &conf if err = crud.Insert(dbCon); err != nil { return message.Fail("Configuration saving in the database failed: " + err.Error()) } var reply = conf replyMessage, err := command.Reply(&reply) if err != nil { return message.Fail("failed to reply") } return replyMessage }
ConfigurationRegister Register a new smartcontract in the configuration. It requires smartcontract address. First call smartcontract_register command.
var SmartcontractGet = func(request message.Request, _ *log.Logger, extensions ...*remote.ClientSocket) message.Reply { var key GetSmartcontractRequest err := request.Parameters.Interface(&key) if err != nil { return message.Fail("failed to parse data") } if err := key.Validate(); err != nil { return message.Fail("key.Validate: " + err.Error()) } dbCon := remote.FindClient(extensions, "github.com/ahmetson/w3storage-extension") if dbCon == nil { return message.Fail("missing extension") } var selected = smartcontract.Smartcontract{} err = selected.Select(dbCon) if err != nil { return message.Fail("failed to get configuration from the database: " + err.Error()) } replyMessage, err := command.Reply(&selected) if err != nil { return message.Fail("failed to reply") } return replyMessage }
SmartcontractGet Returns configuration and smartcontract information related to the configuration
Functions ¶
func AbiRegister ¶
func ConfigurationGet ¶
func ConfigurationGet(request message.Request, _ *log.Logger, extensions ...*remote.ClientSocket) message.Reply
ConfigurationGet Returns configuration and smartcontract information related to the configuration
func RegisterCommands ¶
func RegisterCommands(c *controller.Controller, extensions ...string)
RegisterCommands registers the commands and their handlers in the controller
func SmartcontractRegister ¶
func SmartcontractRegister(request message.Request, _ *log.Logger, extensions ...*remote.ClientSocket) message.Reply
SmartcontractRegister Register a new smartcontract. It means we are adding smartcontract parameters into smartcontract database table. Requires abi_id parameter. First call abi_register method first.
Types ¶
type GetAbiReply ¶
type GetAbiRequest ¶
type GetAbiRequest struct {
Id string `json:"abi_id"`
}
type GetConfigurationReply ¶
type GetConfigurationReply = configuration.Configuration
type GetConfigurationRequest ¶
type GetSmartcontractReply ¶
type GetSmartcontractReply = smartcontract.Smartcontract
type GetSmartcontractRequest ¶
type GetSmartcontractRequest = smartcontract_key.Key
type SetAbiReply ¶
type SetAbiRequest ¶
type SetAbiRequest struct {
Body interface{} `json:"body"`
}
type SetConfigurationReply ¶
type SetConfigurationReply = configuration.Configuration
type SetConfigurationRequest ¶
type SetConfigurationRequest = configuration.Configuration
type SetSmartcontractReply ¶
type SetSmartcontractReply = smartcontract.Smartcontract
type SetSmartcontractRequest ¶
type SetSmartcontractRequest = smartcontract.Smartcontract