2024-07-12 18:12:14 +00:00
|
|
|
package connector
|
|
|
|
|
2024-07-18 15:30:10 +00:00
|
|
|
import "github.com/status-im/status-go/services/connector/commands"
|
|
|
|
|
2024-07-12 18:12:14 +00:00
|
|
|
type CommandRegistry struct {
|
2024-07-18 15:30:10 +00:00
|
|
|
commands map[string]commands.RPCCommand
|
2024-07-12 18:12:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewCommandRegistry() *CommandRegistry {
|
|
|
|
return &CommandRegistry{
|
2024-07-18 15:30:10 +00:00
|
|
|
commands: make(map[string]commands.RPCCommand),
|
2024-07-12 18:12:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-18 15:30:10 +00:00
|
|
|
func (r *CommandRegistry) Register(method string, command commands.RPCCommand) {
|
2024-07-12 18:12:14 +00:00
|
|
|
r.commands[method] = command
|
|
|
|
}
|
|
|
|
|
2024-07-18 15:30:10 +00:00
|
|
|
func (r *CommandRegistry) GetCommand(method string) (commands.RPCCommand, bool) {
|
2024-07-12 18:12:14 +00:00
|
|
|
command, exists := r.commands[method]
|
|
|
|
return command, exists
|
|
|
|
}
|