Skip to content

Commit

Permalink
Merge pull request #202 from Taraxa-project/fix_rewards_and_balances
Browse files Browse the repository at this point in the history
  • Loading branch information
kstdl authored Sep 19, 2024
2 parents 79c394e + 4739775 commit b09b579
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
6 changes: 5 additions & 1 deletion internal/chain/block_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ func scheduleBlockDataTasks(tp pool.Pool, c Client, period uint64, bd *BlockData
tp.Go(common.MakeTaskWithResult(c.GetPreviousBlockCertVotes, period, &bd.Votes, err).Run)
tp.Go(common.MakeTaskWithResult(c.GetValidatorsAtBlock, period, &bd.Validators, err).Run)
tp.Go(common.MakeTaskWithResult(c.GetTotalAmountDelegated, period, &bd.TotalAmountDelegated, err).Run)
tp.Go(common.MakeTaskWithResult(c.GetTotalSupply, period, &bd.TotalSupply, err).Run)
supplyPeriod := period
if period > 100 {
supplyPeriod = period - 100
}
tp.Go(common.MakeTaskWithResult(c.GetTotalSupply, supplyPeriod, &bd.TotalSupply, err).Run)
}

func GetBlockData(c Client, period uint64) (bd *BlockData, err error) {
Expand Down
7 changes: 4 additions & 3 deletions internal/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import (
)

var rewardTopics = map[string]bool{
"CommissionRewardsClaimed(address,address,uint256)": true,
"RewardsClaimed(address,address,uint256)": true,
"UndelegateConfirmed(address,address,uint256)": true,
"CommissionRewardsClaimed(address,address,uint256)": true,
"RewardsClaimed(address,address,uint256)": true,
"UndelegateConfirmed(address,address,uint256)": true,
"UndelegateConfirmedV2(address,address,uint64,uint256)": true,
}

func DecodeEventDynamic(log models.EventLog) (string, any, error) {
Expand Down
1 change: 1 addition & 0 deletions internal/indexer/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func (bc *blockContext) processTransactions() (err error) {
}
// remove value from sender and add to receiver
receiver := bc.Block.Transactions[t_idx].To
// handle contract creation
if receiver == "" {
receiver = bc.Block.Transactions[t_idx].ContractAddress
}
Expand Down
4 changes: 3 additions & 1 deletion internal/storage/pebble/batch.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pebble

import (
"encoding/json"
"sync"

"github.com/Taraxa-project/taraxa-indexer/internal/storage"
Expand Down Expand Up @@ -67,7 +68,8 @@ func (b *Batch) AddToBatch(o interface{}, key1 string, key2 uint64) {
func (b *Batch) AddToBatchSingleKey(o interface{}, key string) {
err := b.AddToBatchFullKey(o, GetPrefixKey(GetPrefix(o), key))
if err != nil {
log.WithError(err).WithField("key", string(GetPrefixKey(GetPrefix(o), key))).Fatal("AddToBatchSingleKey failed")
obj_json, _ := json.Marshal(o)
log.WithError(err).WithField("object", string(obj_json)).WithField("key", string(GetPrefixKey(GetPrefix(o), key))).Fatal("AddToBatchSingleKey failed")
}
}

Expand Down

0 comments on commit b09b579

Please sign in to comment.