Skip to content

Commit

Permalink
feat: add settings switch to not send data market in request by default
Browse files Browse the repository at this point in the history
  • Loading branch information
anomit committed Oct 29, 2024
1 parent 040bab0 commit e8b6fba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
10 changes: 0 additions & 10 deletions config/settings.example.json

This file was deleted.

13 changes: 8 additions & 5 deletions config/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ type Settings struct {
TrustedRelayersListUrl string
DataMarketAddress string
MaxStreamPoolSize int
HealthCheckInterval int // Added based on STREAM_POOL_HEALTH_CHECK_INTERVAL
DataMarketInRequest bool
}

func LoadConfig() {
config := Settings{}

// Required fields
if port := os.Getenv("LOCAL_COLLECTOR_PORT"); port != "" {
config.PortNumber = port
Expand All @@ -38,19 +38,22 @@ func LoadConfig() {
} else {
config.DataMarketAddress = contract
}

if value := os.Getenv("DATA_MARKET_IN_REQUEST"); value == "true" {
config.DataMarketInRequest = true
} else {
config.DataMarketInRequest = false
}
// Optional fields with defaults
config.PowerloomReportingUrl = os.Getenv("POWERLOOM_REPORTING_URL")
config.SignerAccountAddress = os.Getenv("SIGNER_ACCOUNT_ADDRESS")
config.TrustedRelayersListUrl = getEnvWithDefault("TRUSTED_RELAYERS_LIST_URL",
config.TrustedRelayersListUrl = getEnvWithDefault("TRUSTED_RELAYERS_LIST_URL",
"https://raw.githubusercontent.com/PowerLoom/snapshotter-lite-local-collector/feat/trusted-relayers/relayers.json")

// Load private key from file or env
config.RelayerPrivateKey = loadPrivateKey()

// Numeric values with defaults
config.MaxStreamPoolSize = getEnvAsInt("MAX_STREAM_POOL_SIZE", 2)
config.HealthCheckInterval = getEnvAsInt("STREAM_POOL_HEALTH_CHECK_INTERVAL", 30)

SettingsObj = &config
}
Expand Down
8 changes: 5 additions & 3 deletions pkgs/service/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ func (s *server) SubmitSnapshot(ctx context.Context, submission *pkgs.SnapshotSu
}

submissionBytes := append(submissionIdBytes, subBytes...)
// Convert to checksum address using go-ethereum's utility
checksummedAddress := common.HexToAddress(config.SettingsObj.DataMarketAddress).Hex()
submissionBytes = append([]byte(checksummedAddress), submissionBytes...)
if config.SettingsObj.DataMarketInRequest {
// Convert to checksum address using go-ethereum's utility
checksummedAddress := common.HexToAddress(config.SettingsObj.DataMarketAddress).Hex()
submissionBytes = append([]byte(checksummedAddress), submissionBytes...)
}
go func() {
err := s.writeToStream(submissionBytes)

Expand Down

0 comments on commit e8b6fba

Please sign in to comment.