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

feat: adding referrer discord ID to validator strcut #11

Merged
merged 1 commit into from
Dec 20, 2023
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
4 changes: 2 additions & 2 deletions discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (b *Bot) messageHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
return
}

err = b.store.SetData(peerID, address, m.Author.Username, m.Author.ID, amount)
err = b.store.SetData(peerID, address, m.Author.Username, m.Author.ID, referral.DiscordID, amount)
if err != nil {
log.Printf("error saving faucet information: %v\n", err)
}
Expand Down Expand Up @@ -305,7 +305,7 @@ func (b *Bot) messageHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
return
}

err = b.store.SetData(peerID, trimmedAddress, m.Author.Username, m.Author.ID, b.cfg.FaucetAmount)
err = b.store.SetData(peerID, trimmedAddress, m.Author.Username, m.Author.ID, "", b.cfg.FaucetAmount)
if err != nil {
log.Printf("error saving faucet information: %v\n", err)
}
Expand Down
12 changes: 7 additions & 5 deletions discord/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import (

// Validator is a value stored in the cache.
type Validator struct {
DiscordName string `json:"discord_name"`
DiscordID string `json:"discord_id"`
ValidatorAddress string `json:"validator_address"`
FaucetAmount float64 `json:"faucet_amount"`
DiscordName string `json:"discord_name"`
DiscordID string `json:"discord_id"`
ValidatorAddress string `json:"validator_address"`
ReferrerDiscordID string `json:"referrer_discord_id"`
FaucetAmount float64 `json:"faucet_amount"`
}

type ValidatorRoundOne struct {
Expand Down Expand Up @@ -61,10 +62,11 @@ func LoadData(cfg *config.Config) (*SafeStore, error) {
}

// SetData Set a given value to the data storage.
func (ss *SafeStore) SetData(peerID, address, discordName, discordID string, amount float64) error {
func (ss *SafeStore) SetData(peerID, address, discordName, discordID, referrerDiscordID string, amount float64) error {
ss.syncMap.Store(peerID, &Validator{
DiscordName: discordName, DiscordID: discordID,
ValidatorAddress: address, FaucetAmount: amount,
ReferrerDiscordID: referrerDiscordID,
})
// save record
data, err := marshalJSON(ss.syncMap)
Expand Down