dao: migrate nep5 balances with the contract
Fixes #1144. It's quite simple approach, we just update balance info right upon contract migration. It will slow down migration transactions, but it takes about 1-2 seconds to Seek through balances at mainnet's 3.8M, so the approach should still work good enough. The other idea was to make lazy updates (maintaining contract migration map), but it's more complicated to implement (and implies that a balance get might also do a write). There also is a concern about memory usage, it can give a spike of some tens of megabytes, but that also is considered to be acceptable.
This commit is contained in:
parent
a6fc5cfdf1
commit
ae9658a108
2 changed files with 70 additions and 1 deletions
|
@ -154,6 +154,7 @@ func contractUpdate(ic *interop.Context, v *vm.VM) error {
|
|||
if err := ic.DAO.DeleteContractState(oldHash); err != nil {
|
||||
return fmt.Errorf("failed to update script: %v", err)
|
||||
}
|
||||
ic.DAO.MigrateNEP5Balances(oldHash, newHash)
|
||||
}
|
||||
// if manifest was provided, update the old contract manifest and check associated
|
||||
// storage items if needed
|
||||
|
@ -181,6 +182,7 @@ func contractUpdate(ic *interop.Context, v *vm.VM) error {
|
|||
return fmt.Errorf("failed to update manifest: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue