diff --git a/code/go/0chain.net/blobbercore/config/config.go b/code/go/0chain.net/blobbercore/config/config.go index bf95a8d8f..2830bda9d 100644 --- a/code/go/0chain.net/blobbercore/config/config.go +++ b/code/go/0chain.net/blobbercore/config/config.go @@ -63,6 +63,11 @@ const ( DeploymentMainNet = 2 ) +type GeolocationConfig struct { + Latitude float64 `mapstructure:"latitude"` + Longitude float64 `mapstructure:"longitude"` +} + type Config struct { *config.Config DBHost string @@ -118,6 +123,8 @@ type Config struct { NumDelegates int `json:"num_delegates"` // ServiceCharge for blobber. ServiceCharge float64 `json:"service_charge"` + + Geolocation GeolocationConfig `mapstructure:"geolocation"` } /*Configuration of the system */ @@ -133,6 +140,17 @@ func Development() bool { return Configuration.DeploymentMode == DeploymentDevelopment } +// get validated geolocatiion +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") + + } + return g +} + /*ErrSupportedChain error for indicating which chain is supported by the server */ var ErrSupportedChain error diff --git a/code/go/0chain.net/blobbercore/handler/protocol.go b/code/go/0chain.net/blobbercore/handler/protocol.go index 9a4bfa9e8..b19c42d8a 100644 --- a/code/go/0chain.net/blobbercore/handler/protocol.go +++ b/code/go/0chain.net/blobbercore/handler/protocol.go @@ -151,6 +151,7 @@ func getStorageNode() (*transaction.StorageNode, error) { sn := &transaction.StorageNode{} sn.ID = node.Self.ID sn.BaseURL = node.Self.GetURLBase() + sn.Geolocation = transaction.StorageNodeGeolocation(config.Geolocation()) sn.Capacity = config.Configuration.Capacity readPrice := config.Configuration.ReadPrice writePrice := config.Configuration.WritePrice diff --git a/code/go/0chain.net/blobbercore/readmarker/entity.go b/code/go/0chain.net/blobbercore/readmarker/entity.go index be13cd12c..f816554e3 100644 --- a/code/go/0chain.net/blobbercore/readmarker/entity.go +++ b/code/go/0chain.net/blobbercore/readmarker/entity.go @@ -106,7 +106,6 @@ func GetLatestReadMarkerEntity(ctx context.Context, clientID string) (*ReadMarke } func SaveLatestReadMarker(ctx context.Context, rm *ReadMarker, isCreate bool) error { - var ( db = datastore.GetStore().GetTransaction(ctx) rmEntity = &ReadMarkerEntity{} diff --git a/code/go/0chain.net/core/transaction/entity.go b/code/go/0chain.net/core/transaction/entity.go index 72f8eabe5..0f17ae06e 100644 --- a/code/go/0chain.net/core/transaction/entity.go +++ b/code/go/0chain.net/core/transaction/entity.go @@ -68,13 +68,19 @@ type StakePoolSettings struct { ServiceCharge float64 `json:"service_charge"` } +type StorageNodeGeolocation struct { + Latitude float64 `json:"latitude"` + Longitude float64 `json:"longitude"` +} + type StorageNode struct { - ID string `json:"id"` - BaseURL string `json:"url"` - Terms Terms `json:"terms"` - Capacity int64 `json:"capacity"` - PublicKey string `json:"-"` - StakePoolSettings StakePoolSettings `json:"stake_pool_settings"` + ID string `json:"id"` + BaseURL string `json:"url"` + Geolocation StorageNodeGeolocation `json:"geolocation"` + Terms Terms `json:"terms"` + Capacity int64 `json:"capacity"` + PublicKey string `json:"-"` + StakePoolSettings StakePoolSettings `json:"stake_pool_settings"` } type BlobberAllocation struct { diff --git a/config/0chain_blobber.yaml b/config/0chain_blobber.yaml index b43b2502d..c084f4821 100755 --- a/config/0chain_blobber.yaml +++ b/config/0chain_blobber.yaml @@ -87,6 +87,10 @@ db: host: postgres port: 5432 +geolocation: + latitude: 0 + longitude: 0 + minio: # Enable or disable minio backup service start: false