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

Fix empty verification map on error #539

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ type Config struct {
InfuraProjectID string
EtherscanAPIKey string

// Exchange price monitoring
RunExchangePriceMonitoring bool

// Emails
SendgridApiKey string
SendgridDomain string
Expand Down Expand Up @@ -168,6 +171,9 @@ func LoadConfig(coreConfig *coreCmd.Config) *Config {
// Etherscan API Key
config.EtherscanAPIKey = viper.GetString("etherscan-api-key")

// Exchange price monitoring
config.RunExchangePriceMonitoring = viper.GetBool("run-exchange-price-monitoring")

// Seed from which DeSo will be sent for orders placed through Wyre and "Buy With BTC" purchases
config.BuyDESOSeed = viper.GetString("buy-deso-seed")

Expand Down
2 changes: 2 additions & 0 deletions routes/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,8 @@ func (fes *APIServer) GetPostsHashHexList(ww http.ResponseWriter, req *http.Requ

postEntryResponses = append(postEntryResponses, postEntryResponse)

postEntryResponse.PostEntryReaderState = utxoView.GetPostEntryReaderState(readerPublicKeyBytes, postEntry)

}

if requestData.OrderBy == "newest" {
Expand Down
15 changes: 9 additions & 6 deletions routes/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,18 +526,21 @@ func NewAPIServer(

fes.StartSeedBalancesMonitoring()

// Call this once upon starting server to ensure we have a good initial value
fes.UpdateUSDCentsToDeSoExchangeRate()
fes.UpdateUSDToBTCPrice()
fes.UpdateUSDToETHPrice()

// Get the transaction fee map from global state if it exists
fes.TransactionFeeMap = fes.GetTransactionFeeMapFromGlobalState()

fes.ExemptPublicKeyMap = fes.GetExemptPublicKeyMapFromGlobalState()

// Then monitor them
fes.StartExchangePriceMonitoring()
if fes.Config.RunExchangePriceMonitoring {
// Call this once upon starting server to ensure we have a good initial value
fes.UpdateUSDCentsToDeSoExchangeRate()
fes.UpdateUSDToBTCPrice()
fes.UpdateUSDToETHPrice()

// Then monitor them
fes.StartExchangePriceMonitoring()
}

if fes.Config.RunHotFeedRoutine {
fes.StartHotFeedRoutine()
Expand Down
17 changes: 9 additions & 8 deletions routes/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,15 @@ func (fes *APIServer) GetVerifiedUsernameToPKIDMapFromGlobalState() (_verificati
verifiedMapStruct.VerifiedUsernameToPKID = make(map[string]*lib.PKID)

// Encode the map and stick it in the database.
metadataDataBuf := bytes.NewBuffer([]byte{})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert these deletions.

if err = gob.NewEncoder(metadataDataBuf).Encode(verifiedMapStruct); err != nil {
return nil, fmt.Errorf("GetVerifiedUsernameToPKIDMapFromGlobalState: cannot encode verifiedMap struct: %v", err)
}
err = fes.GlobalState.Put(_GlobalStatePrefixForVerifiedMap, metadataDataBuf.Bytes())
if err != nil {
return nil, fmt.Errorf("GetVerifiedUsernameToPKIDMapFromGlobalState: Cannot Decode Verification Map: %v", err)
}
// TODO: Disabled code below because it was causing a blank verifiedusername map. We should investigate why.
// metadataDataBuf := bytes.NewBuffer([]byte{})
// if err = gob.NewEncoder(metadataDataBuf).Encode(verifiedMapStruct); err != nil {
// return nil, fmt.Errorf("GetVerifiedUsernameToPKIDMapFromGlobalState: cannot encode verifiedMap struct: %v", err)
// }
// err = fes.GlobalState.Put(_GlobalStatePrefixForVerifiedMap, metadataDataBuf.Bytes())
// if err != nil {
// return nil, fmt.Errorf("GetVerifiedUsernameToPKIDMapFromGlobalState: Cannot Decode Verification Map: %v", err)
// }
}
// Return the verificationMap
return verifiedMapStruct.VerifiedUsernameToPKID, nil
Expand Down
Loading