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
18 changes: 18 additions & 0 deletions code/go/0chain.net/blobbercore/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions code/go/0chain.net/blobbercore/handler/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion code/go/0chain.net/blobbercore/readmarker/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
18 changes: 12 additions & 6 deletions code/go/0chain.net/core/transaction/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions config/0chain_blobber.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ db:
host: postgres
port: 5432

geolocation:
latitude: 0
longitude: 0

minio:
# Enable or disable minio backup service
start: false
Expand Down