-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2442 from fluidity-money/develop-fix-solana-and-e…
…xtra-logging Replace the locations of the accounts for testing a Mint
- Loading branch information
Showing
8 changed files
with
128 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...e/101-up-postgres/20231211120959-solana_winner_tracking_add_intermediate_winning_hash.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
-- migrate:up | ||
|
||
CREATE TABLE solana_intermediate_winners ( | ||
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
winning_signature VARCHAR NOT NULL, -- corresponds to winners send_transaction_hash | ||
payout_signature VARCHAR NOT NULL -- corresponds to winners transaction_hash | ||
); | ||
|
||
-- migrate:down | ||
|
||
DROP TABLE solana_intermediate_winners; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2022 Fluidity Money. All rights reserved. Use of this | ||
// source code is governed by a GPL-style license that can be found in the | ||
// LICENSE.md file. | ||
|
||
package solana | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/fluidity-money/fluidity-app/lib/log" | ||
"github.com/fluidity-money/fluidity-app/lib/postgres" | ||
) | ||
|
||
// GetIntermediateWinner using a payout transaction signature | ||
func GetIntermediateWinner(payoutSignature string) (winningSignature string) { | ||
databaseClient := postgres.Client() | ||
|
||
statementText := fmt.Sprintf( | ||
`SELECT winning_signature | ||
FROM %s | ||
WHERE payout_signature = $1;`, | ||
|
||
TableIntermediateWinners, | ||
) | ||
|
||
row := databaseClient.QueryRow(statementText, payoutSignature) | ||
|
||
if err := row.Err(); err != nil { | ||
log.Fatal(func(k *log.Log) { | ||
k.Context = Context | ||
|
||
k.Format( | ||
"Failed to query for an intermediate winner with payout sig %v", | ||
payoutSignature, | ||
) | ||
|
||
k.Payload = err | ||
}) | ||
} | ||
|
||
err := row.Scan(&winningSignature) | ||
|
||
if err != nil { | ||
log.Fatal(func(k *log.Log) { | ||
k.Context = Context | ||
|
||
k.Format( | ||
"Failed to scan the intermediate winners table for payout signature %v", | ||
payoutSignature, | ||
) | ||
|
||
k.Payload = err | ||
}) | ||
} | ||
|
||
return winningSignature | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters