Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rent blobber managing wallet #1534

Open
wants to merge 7 commits into
base: staging
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion code/go/0chain.net/blobber/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ func initHandlers(r *mux.Router, devMode bool) {
handler.SetupHandlers(r)
handler.SetupSwagger()
common.SetAdminCredentials(devMode)
common.Set0boxDetails()
}

func initProfHandlers(mux *http.ServeMux) {
Expand Down
2 changes: 2 additions & 0 deletions code/go/0chain.net/blobber/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func main() {
panic(err)
}

common.Set0boxDetails()

if err := setupNode(); err != nil {
logging.Logger.Error("Error setting up blobber node " + err.Error())
panic(err)
Expand Down
18 changes: 8 additions & 10 deletions code/go/0chain.net/blobbercore/handler/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package handler
import (
"context"
"errors"
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/datastore"
"strings"
"sync"

"github.com/0chain/gosdk/core/client"
coreTxn "github.com/0chain/gosdk/core/transaction"

"github.com/0chain/blobber/code/go/0chain.net/blobbercore/allocation"
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/config"
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/datastore"
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/filestore"
"github.com/0chain/blobber/code/go/0chain.net/core/common"
"github.com/0chain/blobber/code/go/0chain.net/core/logging"
Expand Down Expand Up @@ -70,6 +71,8 @@ func getStorageNode() (*transaction.StorageNode, error) {
sn.IsEnterprise = config.Configuration.IsEnterprise
sn.StorageVersion = allocation.StorageV2

sn.ManagingWallet = common.ClientId0box

return sn, nil
}

Expand All @@ -80,15 +83,10 @@ func RegisterBlobber(ctx context.Context) error {
return e
})

if err != nil { // blobber is not registered yet
txn, err := sendSmartContractBlobberAdd()
if err != nil {
logging.Logger.Error("Error in add blobber", zap.Any("err", err))
return err
}

logging.Logger.Info("Verified blobber register transaction", zap.String("txn_hash", txn.Hash), zap.Any("txn_output", txn.TransactionOutput))
return nil
_, err = sendSmartContractBlobberAdd()
if err != nil && !strings.Contains(err.Error(), "blobber already exists") {
logging.Logger.Error("Error in add blobber", zap.Any("err", err))
return err
}

txnHash, err := SendHealthCheck(common.ProviderTypeBlobber)
Expand Down
3 changes: 2 additions & 1 deletion code/go/0chain.net/core/common/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
// global username and password used to access endpoints only by admin
var gUsername, gPassword string
var isDevelopment bool
var PublicKey0box string
var ClientId0box, PublicKey0box string

func SetAdminCredentials(devMode bool) {
gUsername = viper.GetString("admin.username")
Expand Down Expand Up @@ -42,6 +42,7 @@ func AuthenticateAdmin(handler ReqRespHandlerf) ReqRespHandlerf {

func Set0boxDetails() {
logging.Logger.Info("Setting 0box details")
ClientId0box = viper.GetString("0box.client_id")
PublicKey0box = viper.GetString("0box.public_key")
logging.Logger.Info("0box public key", zap.Any("public_key", PublicKey0box))
}
1 change: 1 addition & 0 deletions code/go/0chain.net/core/transaction/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type StorageNode struct {
StakePoolSettings StakePoolSettings `json:"stake_pool_settings"`
IsEnterprise bool `json:"is_enterprise"`
StorageVersion int `json:"storage_version"`
ManagingWallet string `json:"managing_wallet"`
}

type BlobberAllocation struct {
Expand Down
Loading