Skip to content

Commit

Permalink
feat: adding referrer discord ID to validator strcut (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
kehiy authored Dec 20, 2023
1 parent f84e22c commit 5fdad8a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
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

0 comments on commit 5fdad8a

Please sign in to comment.