mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-06-07 14:46:39 +00:00
add config for watchmen
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
a63f390490
commit
238e68808b
26
config/config.go
Normal file
26
config/config.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package app
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/tkanos/gonfig"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Configuration struct {
|
||||||
|
WATCHMEN_ENDPOINT string
|
||||||
|
WATCHMEN_PORT uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetConfig(params ...string) Configuration {
|
||||||
|
configuration := Configuration{}
|
||||||
|
env := "dev"
|
||||||
|
|
||||||
|
if len(params) > 0 {
|
||||||
|
env = params[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
filename := fmt.Sprintf("./%s_config.json", env)
|
||||||
|
gonfig.GetConf(filename, &configuration)
|
||||||
|
|
||||||
|
return configuration
|
||||||
|
}
|
4
config/dev_config.json
Normal file
4
config/dev_config.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"WATCHMEN_ENDPOINT": "localhost",
|
||||||
|
"WATCHMEN_PORT": 7401
|
||||||
|
}
|
4
config/prod_config.json
Normal file
4
config/prod_config.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"WATCHMEN_ENDPOINT": "localhost",
|
||||||
|
"WATCHMEN_PORT": 7401
|
||||||
|
}
|
1
go.mod
1
go.mod
@ -23,6 +23,7 @@ require (
|
|||||||
github.com/spf13/cobra v1.6.1
|
github.com/spf13/cobra v1.6.1
|
||||||
github.com/spf13/pflag v1.0.5
|
github.com/spf13/pflag v1.0.5
|
||||||
github.com/stretchr/testify v1.8.2
|
github.com/stretchr/testify v1.8.2
|
||||||
|
github.com/tkanos/gonfig v0.0.0-20210106201359-53e13348de2f
|
||||||
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4
|
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4
|
||||||
google.golang.org/grpc v1.55.0
|
google.golang.org/grpc v1.55.0
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
gopkg.in/yaml.v2 v2.4.0
|
||||||
|
2
go.sum
2
go.sum
@ -960,6 +960,8 @@ github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2l
|
|||||||
github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
|
github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
|
||||||
github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg=
|
github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg=
|
||||||
github.com/tidwall/btree v1.6.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY=
|
github.com/tidwall/btree v1.6.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY=
|
||||||
|
github.com/tkanos/gonfig v0.0.0-20210106201359-53e13348de2f h1:xDFq4NVQD34ekH5UsedBSgfxsBuPU2aZf7v4t0tH2jY=
|
||||||
|
github.com/tkanos/gonfig v0.0.0-20210106201359-53e13348de2f/go.mod h1:DaZPBuToMc2eezA9R9nDAnmS2RMwL7yEa5YD36ESQdI=
|
||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||||
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
|
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
|
||||||
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
config "planetmint-go/config"
|
||||||
"planetmint-go/x/machine/types"
|
"planetmint-go/x/machine/types"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcutil/hdkeychain"
|
"github.com/btcsuite/btcd/btcutil/hdkeychain"
|
||||||
@ -22,7 +23,7 @@ func (k msgServer) AttestMachine(goCtx context.Context, msg *types.MsgAttestMach
|
|||||||
}
|
}
|
||||||
|
|
||||||
if msg.Machine.Reissue {
|
if msg.Machine.Reissue {
|
||||||
err := k.reissueMachineNFT(msg.Machine)
|
err := k.reissueMachine(msg.Machine)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("an error occured while reissuning the machine")
|
return nil, errors.New("an error occured while reissuning the machine")
|
||||||
}
|
}
|
||||||
@ -43,8 +44,9 @@ func validateIssuerLiquid(issuerLiquid string) bool {
|
|||||||
return isValidLiquidKey
|
return isValidLiquidKey
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k msgServer) reissueMachineNFT(machine *types.Machine) error {
|
func (k msgServer) reissueMachine(machine *types.Machine) error {
|
||||||
client := osc.NewClient("localhost", 8765)
|
conf := config.GetConfig()
|
||||||
|
client := osc.NewClient(conf.WATCHMEN_ENDPOINT, int(conf.WATCHMEN_PORT))
|
||||||
msg := osc.NewMessage("/rddl/*")
|
msg := osc.NewMessage("/rddl/*")
|
||||||
msg.Append(machine.Name)
|
msg.Append(machine.Name)
|
||||||
msg.Append(machine.Ticker)
|
msg.Append(machine.Ticker)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user