diff --git a/cmd/node/appchain.go b/cmd/node/appchain.go index d8eb81e..3ef2295 100644 --- a/cmd/node/appchain.go +++ b/cmd/node/appchain.go @@ -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" @@ -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) diff --git a/cmd/node/main.go b/cmd/node/main.go index a2d9782..65fcd33 100644 --- a/cmd/node/main.go +++ b/cmd/node/main.go @@ -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() diff --git a/cmd/node/types.go b/cmd/node/types.go index c698556..94017df 100644 --- a/cmd/node/types.go +++ b/cmd/node/types.go @@ -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" @@ -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 {