Skip to content

Design Documentation for Token tracking rollback

tripathyr edited this page Oct 31, 2021 · 1 revision

Rollback process for the token table

Design A

  • We will rollback only from the transaction history data
  • We will then create a setting inside the sqlite database called rollback phase = on
  • If rollback phase is on then the balance is the sum of the pid table balance + the rollback table balance for every FLO address
  • Rollback FLO address balance for a token can be both positive and negative
  • Pid table balance will always be positive
  • The sum of these 2 tables will always be positive for any given address
  • Now we will start finding out how many transactions we have to roll back from the transaction table on the basis of the block number to which we have rolled back
  • Create another table pid undo table

Design B

  • Write the actual quantities and parent id information

  • Write another column in the pid table called consumed pid details which will have pids and the actual amount of token that was consumed in that pid Now when we rollback a consumed id, we will not have the consumed id’s parent ID information

  • Roll back and roll forward will be one operation, and it has to finish totally. Otherwise all the operations will have to be discarded and original db before the rollback has to be restored | check out sqlite’s documentation is there is a method to hold state

Design C

  • Make a modification in consumedTable and write the number of tokens that were consumed before it became 0
  • Then we can calculate back how much credit has to be given to FLO IDs that were totally consumed
  • Pid = partially consumed amount, consumedpid = totally consumed amount .. when rolling back, all consumed-pie balances we get form the consumed table … balance consumed partially = total amount transferred in the tx - total consumed pid balance

Go to Home Page