Skip to content
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ docker.local/blobber1/files/e55/003/7d3/f56519dff06156f16a19a40389414f94cfd4c3a5
docker.local/blobber1/files/e55/003/7d3/f56519dff06156f16a19a40389414f94cfd4c3a548f46c218cb484e/refs/123/6e9/a3b/6c8bbc889679c68af4372b7d68e2f2343c03ae7aaa4b25fbb8257c3
docker.local/blobber1/files/e55/003/7d3/f56519dff06156f16a19a40389414f94cfd4c3a548f46c218cb484e/refs/388/12d/bd3/b084ff297706d7bd307996c3363c2df53acc49c97b83201f8dc7bd9
docker.local/blobber1/data/badgerdb/blobberstate/MANIFEST

dev.local/data
16 changes: 16 additions & 0 deletions code/go/0chain.net/blobber/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/0chain/blobber/code/go/0chain.net/core/logging"
. "github.com/0chain/blobber/code/go/0chain.net/core/logging"
"github.com/0chain/blobber/code/go/0chain.net/core/node"
"github.com/0chain/blobber/code/go/0chain.net/core/transaction"

"github.com/0chain/gosdk/zcncore"
"github.com/gorilla/handlers"
Expand Down Expand Up @@ -139,6 +140,21 @@ func setupWorkerConfig() {
config.Configuration.MaxStake = int64(viper.GetFloat64("max_stake") * 1e10)
config.Configuration.NumDelegates = viper.GetInt("num_delegates")
config.Configuration.ServiceCharge = viper.GetFloat64("service_charge")

config.Configuration.MinSubmit = viper.GetInt("min_submit")
if config.Configuration.MinSubmit < 1 {
config.Configuration.MinSubmit = 50
} else if config.Configuration.MinSubmit > 100 {
config.Configuration.MinSubmit = 100
}
config.Configuration.MinConfirmation = viper.GetInt("min_confirmation")
if config.Configuration.MinConfirmation < 1 {
config.Configuration.MinConfirmation = 50
} else if config.Configuration.MinConfirmation > 100 {
config.Configuration.MinConfirmation = 100
}

transaction.MinConfirmation = config.Configuration.MinConfirmation
}

func setupMinioConfig(reader io.Reader) error {
Expand Down
4 changes: 2 additions & 2 deletions code/go/0chain.net/blobbercore/allocation/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func RequestReadPools(clientID, allocationID string) (
"allocation_id": allocationID,
"blobber_id": blobberID,
},
chain.GetServerChain(), nil)
chain.GetServerChain())
if err != nil {
return nil, fmt.Errorf("requesting read pools stat: %v", err)
}
Expand Down Expand Up @@ -245,7 +245,7 @@ func RequestWritePools(clientID, allocationID string) (
"allocation_id": allocationID,
"blobber_id": blobberID,
},
chain.GetServerChain(), nil)
chain.GetServerChain())
if err != nil {
return nil, fmt.Errorf("requesting write pools stat: %v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions code/go/0chain.net/blobbercore/allocation/workers.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ func requestAllocation(allocID string) (
transaction.STORAGE_CONTRACT_ADDRESS,
"/allocation",
map[string]string{"allocation": allocID},
chain.GetServerChain(),
nil)
chain.GetServerChain())
if err != nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion code/go/0chain.net/blobbercore/challenge/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func FindChallenges(ctx context.Context) {

var blobberChallenges BCChallengeResponse
blobberChallenges.Challenges = make([]*ChallengeEntity, 0)
retBytes, err := transaction.MakeSCRestAPICall(transaction.STORAGE_CONTRACT_ADDRESS, "/openchallenges", params, chain.GetServerChain(), nil)
retBytes, err := transaction.MakeSCRestAPICall(transaction.STORAGE_CONTRACT_ADDRESS, "/openchallenges", params, chain.GetServerChain())

if err != nil {
Logger.Error("Error getting the open challenges from the blockchain", zap.Error(err))
Expand Down
9 changes: 7 additions & 2 deletions code/go/0chain.net/blobbercore/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const (
)

type GeolocationConfig struct {
Latitude float64 `mapstructure:"latitude"`
Latitude float64 `mapstructure:"latitude"`
Longitude float64 `mapstructure:"longitude"`
}

Expand Down Expand Up @@ -125,6 +125,11 @@ type Config struct {
ServiceCharge float64 `json:"service_charge"`

Geolocation GeolocationConfig `mapstructure:"geolocation"`

// MinSubmit minial submit from miners
MinSubmit int
// MinConfirmation minial confirmation from sharders
MinConfirmation int
}

/*Configuration of the system */
Expand All @@ -145,7 +150,7 @@ func Geolocation() GeolocationConfig {
g := Configuration.Geolocation
if g.Latitude > 90.00 || g.Latitude < -90.00 ||
g.Longitude > 180.00 || g.Longitude < -180.00 {
panic("Fatal error in config file")
panic("Fatal error in config file")

}
return g
Expand Down
4 changes: 1 addition & 3 deletions code/go/0chain.net/blobbercore/handler/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func getStorageNode() (*transaction.StorageNode, error) {

// Add or update blobber on blockchain
func BlobberAdd(ctx context.Context) (string, error) {
time.Sleep(transaction.SLEEP_FOR_TXN_CONFIRMATION * time.Second)

// initialize storage node (ie blobber)
txn, err := transaction.NewTransactionEntity()
Expand Down Expand Up @@ -153,7 +152,6 @@ func BlobberHealthCheck(ctx context.Context) (string, error) {
}

func TransactionVerify(txnHash string) (t *transaction.Transaction, err error) {
time.Sleep(transaction.SLEEP_FOR_TXN_CONFIRMATION * time.Second)

for i := 0; i < util.MAX_RETRIES; i++ {
time.Sleep(transaction.SLEEP_FOR_TXN_CONFIRMATION * time.Second)
Expand All @@ -162,7 +160,7 @@ func TransactionVerify(txnHash string) (t *transaction.Transaction, err error) {
}
}

return
return nil, errors.New("[txn]max retries exceeded with " + txnHash)
}

func WalletRegister() error {
Expand Down
2 changes: 1 addition & 1 deletion code/go/0chain.net/blobbercore/readmarker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func RedeemReadMarker(ctx context.Context, rmEntity *ReadMarkerEntity) (

latestRMBytes, err = transaction.MakeSCRestAPICall(
transaction.STORAGE_CONTRACT_ADDRESS, "/latestreadmarker", params,
chain.GetServerChain(), nil)
chain.GetServerChain())

if err != nil {
Logger.Error("Error from sc rest api call", zap.Error(err))
Expand Down
Loading