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

register heads as reputers #40

Merged
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
27 changes: 20 additions & 7 deletions cmd/node/appchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (
"strings"

cosmossdk_io_math "cosmossdk.io/math"
"github.com/blocklessnetwork/b7s/models/blockless"
"github.com/blocklessnetwork/b7s/node/aggregate"
sdktypes "github.com/cosmos/cosmos-sdk/types"
"github.com/ignite/cli/v28/ignite/pkg/cosmosaccount"
"github.com/ignite/cli/v28/ignite/pkg/cosmosclient"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -101,13 +103,24 @@ func NewAppChain(config AppChainConfig, log zerolog.Logger) (*AppChain, error) {
func registerWithBlockchain(appchain *AppChain) {
ctx := context.Background()

msg := &types.MsgRegisterWorker{
Creator: appchain.ReputerAddress,
Owner: appchain.ReputerAddress, // we need to allow a pass in of a claim address
LibP2PKey: appchain.Config.LibP2PKey,
MultiAddress: appchain.Config.MultiAddress,
InitialStake: cosmossdk_io_math.NewUint(1),
TopicId: appchain.Config.TopicId,
var msg sdktypes.Msg
if(appchain.Config.NodeRole == blockless.HeadNode) {
msg = &types.MsgRegisterReputer{
Creator: appchain.ReputerAddress,
LibP2PKey: appchain.Config.LibP2PKey,
MultiAddress: appchain.Config.MultiAddress,
InitialStake: cosmossdk_io_math.NewUint(1),
TopicId: appchain.Config.TopicId,
}
} else {
msg = &types.MsgRegisterWorker{
Creator: appchain.ReputerAddress,
Owner: appchain.ReputerAddress, // we need to allow a pass in of a claim address
LibP2PKey: appchain.Config.LibP2PKey,
MultiAddress: appchain.Config.MultiAddress,
InitialStake: cosmossdk_io_math.NewUint(1),
TopicId: appchain.Config.TopicId,
}
}

txResp, err := appchain.Client.BroadcastTx(ctx, appchain.ReputerAccount, msg)
Expand Down
2 changes: 1 addition & 1 deletion cmd/node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func run() int {
failed := make(chan struct{})

var appchain *AppChain

cfg.AppChainConfig.NodeRole = role
cfg.AppChainConfig.AddressPrefix = "upt"
cfg.AppChainConfig.StringSeperator = "|"
cfg.AppChainConfig.LibP2PKey = host.ID().String()
Expand Down
2 changes: 2 additions & 0 deletions cmd/node/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
cosmossdk_io_math "cosmossdk.io/math"
"github.com/blocklessnetwork/b7s/config"
"github.com/blocklessnetwork/b7s/models/blockless"
"github.com/ignite/cli/v28/ignite/pkg/cosmosaccount"
"github.com/ignite/cli/v28/ignite/pkg/cosmosclient"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -36,6 +37,7 @@ type AppChainConfig struct {
SubmitTx bool // do we need to commit these to the chain, might be a reason not to
MultiAddress string
TopicId uint64
NodeRole blockless.NodeRole
}

type WorkerInference struct {
Expand Down
Loading