Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Getting peer UPT address #43

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cmd/node/appchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ func (ap *AppChain) SendInferences(ctx context.Context, topicId uint64, results
for _, result := range results {
for _, peer := range result.Peers {
ap.Logger.Info().Any("peer", peer)

// Get Peer $upt address
res, err := ap.QueryClient.GetWorkerAddressByP2PKey(ctx, &types.QueryWorkerAddressByP2PKeyRequest{
Libp2PKey: peer.String(),
})
if err != nil {
ap.Logger.Fatal().Err(err).Msg("error getting peer address")
}

value, err := extractNumber(result.Result.Stdout)
if err != nil || value == "" {
ap.Logger.Fatal().Err(err).Msg("error extracting number from stdout")
Expand All @@ -168,7 +177,7 @@ func (ap *AppChain) SendInferences(ctx context.Context, topicId uint64, results
}
inference := &types.Inference{
TopicId: topicId,
Worker: "upt16ar7k93c6razqcuvxdauzdlaz352sfjp2rpj3i",
Worker: res.Address,
Value: cosmossdk_io_math.NewUint(parsed),
}
inferences = append(inferences, inference)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ toolchain go1.21.5
require (
cosmossdk.io/math v1.2.0
github.com/cockroachdb/pebble v0.0.0-20231102162011-844f0582c2eb
github.com/cosmos/cosmos-sdk v0.50.3
github.com/ignite/cli/v28 v28.1.1
github.com/labstack/echo/v4 v4.11.4
github.com/libp2p/go-libp2p v0.32.2
Expand Down Expand Up @@ -57,7 +58,6 @@ require (
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v1.0.0 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.3 // indirect
github.com/cosmos/cosmos-sdk v0.50.3 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/gogoproto v1.4.11 // indirect
Expand Down Expand Up @@ -272,5 +272,5 @@ require (
replace (
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/libp2p/go-libp2p-raft => github.com/dmikey/go-libp2p-raft v0.0.0-20240110033916-a00d162e5fdd
github.com/upshot-tech/protocol-state-machine-module => github.com/upshot-tech/upshot-appchain/x/emissions v0.0.0-20240131192024-a487d4059e45
github.com/upshot-tech/protocol-state-machine-module => github.com/upshot-tech/upshot-appchain/x/emissions v0.0.0-20240202144809-8383bca5a600
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -956,8 +956,8 @@ github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljT
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/upshot-tech/upshot-appchain/x/emissions v0.0.0-20240131192024-a487d4059e45 h1:fitXjpwDsw57/VBnJKXz80RRdiHFeYN2siedEuK+yHU=
github.com/upshot-tech/upshot-appchain/x/emissions v0.0.0-20240131192024-a487d4059e45/go.mod h1:xLgqdaKfIc1mgAirZpkhOVpGe8z0dO15VltuUuaaZSQ=
github.com/upshot-tech/upshot-appchain/x/emissions v0.0.0-20240202144809-8383bca5a600 h1:8sHUz67uiXQST8Y/XlaZIgeRQylWAYCWEV0QGW3OU88=
github.com/upshot-tech/upshot-appchain/x/emissions v0.0.0-20240202144809-8383bca5a600/go.mod h1:xLgqdaKfIc1mgAirZpkhOVpGe8z0dO15VltuUuaaZSQ=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
Expand Down
Loading