Skip to content

Commit

Permalink
move pending winners type to lib
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-d committed Dec 14, 2023
1 parent 20fffc7 commit 3e5b175
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
4 changes: 2 additions & 2 deletions cmd/microservice-user-transactions-aggregate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"math"
"math/big"

"github.com/fluidity-money/fluidity-app/lib/databases/timescale/spooler"
user_actions "github.com/fluidity-money/fluidity-app/lib/databases/timescale/user-actions"
"github.com/fluidity-money/fluidity-app/lib/log"
queue "github.com/fluidity-money/fluidity-app/lib/queues/user-actions"
"github.com/fluidity-money/fluidity-app/lib/queues/winners"
userActionsType "github.com/fluidity-money/fluidity-app/lib/types/user-actions"
winnerTypes "github.com/fluidity-money/fluidity-app/lib/types/winners"
)

func main() {
Expand Down Expand Up @@ -91,7 +91,7 @@ func main() {
})

// pending winners have the same behaviour as winners
winners.PendingWinners(func (pendingWinner spooler.PendingWinner) {
winners.PendingWinners(func (pendingWinner winnerTypes.PendingWinner) {
var (
network = pendingWinner.Network
transactionHash = pendingWinner.TransactionHash.String()
Expand Down
16 changes: 1 addition & 15 deletions lib/databases/timescale/spooler/spooler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"github.com/fluidity-money/fluidity-app/lib/log"
"github.com/fluidity-money/fluidity-app/lib/timescale"
"github.com/fluidity-money/fluidity-app/lib/types/applications"
"github.com/fluidity-money/fluidity-app/lib/types/ethereum"
"github.com/fluidity-money/fluidity-app/lib/types/misc"
"github.com/fluidity-money/fluidity-app/lib/types/network"
token_details "github.com/fluidity-money/fluidity-app/lib/types/token-details"
"github.com/fluidity-money/fluidity-app/lib/types/winners"
Expand All @@ -28,19 +26,7 @@ const (
TablePendingWinners = "ethereum_pending_winners"
)

type PendingWinner struct {
TokenDetails token_details.TokenDetails `json:"token_details"`
TransactionHash ethereum.Hash `json:"transaction_hash"`
SenderAddress ethereum.Address `json:"sender_address"`
NativeWinAmount misc.BigInt `json:"native_win_amount"`
UsdWinAmount float64 `json:"usd_win_amount"`
Utility applications.UtilityName `json:"utility"`
BlockNumber *misc.BigInt `json:"block_number"`
Network network.BlockchainNetwork `json:"network"`
RewardType winners.RewardType `json:"reward_type"`
LogIndex *misc.BigInt `json:"log_index"`
Application applications.Application `json:"application"`
}
type PendingWinner = winners.PendingWinner

// CreatePendingWinners to aggregate a list of pending winners in the given announcement
func CreatePendingWinners(winner worker.EthereumWinnerAnnouncement, tokenDetails map[applications.UtilityName]token_details.TokenDetails) []PendingWinner {
Expand Down
2 changes: 1 addition & 1 deletion lib/queues/winners/winners.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func BlockedWinnersAll(f func(BlockedWinner)) {

func PendingWinners(f func(spooler.PendingWinner)) {
queue.GetMessages(TopicPendingWinners, func(message queue.Message) {
var pendingWinner spooler.PendingWinner
var pendingWinner types.PendingWinner

message.Decode(&pendingWinner)

Expand Down
17 changes: 17 additions & 0 deletions lib/types/winners/winners.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/fluidity-money/fluidity-app/lib/types/applications"
"github.com/fluidity-money/fluidity-app/lib/types/ethereum"
"github.com/fluidity-money/fluidity-app/lib/types/misc"
"github.com/fluidity-money/fluidity-app/lib/types/network"
"github.com/fluidity-money/fluidity-app/lib/types/token-details"
Expand Down Expand Up @@ -52,3 +53,19 @@ type BlockedWinner struct {
BatchFirstBlock misc.BigInt `json:"first_block"`
BatchLastBlock misc.BigInt `json:"last_block"`
}

// PendingWinner is a winner that has been spooled but not sent
type PendingWinner struct {
TokenDetails token_details.TokenDetails `json:"token_details"`
TransactionHash ethereum.Hash `json:"transaction_hash"`
SenderAddress ethereum.Address `json:"sender_address"`
NativeWinAmount misc.BigInt `json:"native_win_amount"`
UsdWinAmount float64 `json:"usd_win_amount"`
Utility applications.UtilityName `json:"utility"`
BlockNumber *misc.BigInt `json:"block_number"`
Network network.BlockchainNetwork `json:"network"`
RewardType RewardType `json:"reward_type"`
LogIndex *misc.BigInt `json:"log_index"`
Application applications.Application `json:"application"`
}

0 comments on commit 3e5b175

Please sign in to comment.