Skip to content

Reindexation options #76

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

Open
hclivess opened this issue Nov 20, 2023 · 2 comments
Open

Reindexation options #76

hclivess opened this issue Nov 20, 2023 · 2 comments

Comments

@hclivess
Copy link
Owner

Add option to reindex entire chain from raw blocks. This can also be used for quicker sync.

@hclivess
Copy link
Owner Author

hclivess commented Nov 20, 2023

# checks are not included, should be run only on self data

from ops.data_ops import sort_list_dict
from ops.transaction_ops import index_transactions
from ops.account_ops import change_balance, increase_produced_count, get_totals, index_totals

blocks = []
logger = None
block_height = None

for block in blocks:
    sorted_transactions = sort_list_dict(block["block_transactions"])

    index_transactions(block=block,
                       sorted_transactions=sorted_transactions,
                       logger=logger,
                       block_height=block_height)

    change_balance(address=block["block_creator"],
                   amount=block["block_reward"],
                   logger=logger
                   )

    increase_produced_count(address=block["block_creator"],
                            amount=block["block_reward"],
                            logger=logger
                            )

    totals = get_totals(block=block)

    index_totals(produced=totals["produced"],
                 fees=totals["fees"],
                 burned=totals["burned"],
                 block_height=block["block_number"])

@hclivess
Copy link
Owner Author

Improve reindexer to batch properly:

Take a range of blocks, extract transactions from them

  • now there are two lists, one of blocks, one of transactions
  • without verification, bulk insert those blocks into block index and those transactions into transaction index

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant