Skip to content

Commit

Permalink
check 5
Browse files Browse the repository at this point in the history
  • Loading branch information
OsauravO committed Apr 27, 2024
1 parent 0837c57 commit 2e989d6
Show file tree
Hide file tree
Showing 2 changed files with 3,241 additions and 10 deletions.
11 changes: 5 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,21 +334,20 @@ func Ordering() (uint64, []string, []string) {
var reward uint64 = 0
var allowedTxs []TxInfo
var maxWeight uint64 = 4000000
var targetScore float64 = 108.0

for _, tx := range txInfo {
remainingWeight := maxWeight - tx.Weight
currentScore := float64(reward+tx.Fee) / float64(maxWeight-remainingWeight) * 100.0

if remainingWeight >= 0 && currentScore <= targetScore {
if maxWeight >= tx.Weight {
allowedTxs = append(allowedTxs, tx)
maxWeight = remainingWeight
maxWeight -= tx.Weight
allowedTxIDs = append(allowedTxIDs, tx.TxID)
notAllowedTxIDs = append(notAllowedTxIDs, tx.WTxID)
reward += tx.Fee
}
}

fmt.Println("weight: ", maxWeight)
fmt.Println("reward: ", reward)

return reward, allowedTxIDs, notAllowedTxIDs
}

Expand Down
Loading

0 comments on commit 2e989d6

Please sign in to comment.