Skip to content

Commit

Permalink
1347 data destruction (#1661)
Browse files Browse the repository at this point in the history
* 1347 data destruction. Added data destruction to the database

* 1347 clang format check

* Fixed typo
  • Loading branch information
kladkogex authored Sep 21, 2023
1 parent 09e76a6 commit 76ca0f4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions libskale/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,19 @@ void State::clearStorage( Address const& _contract ) {
for ( auto const& hashPairPair : storage_WITHOUT_LOCK( _contract ) ) {
auto const& key = hashPairPair.second.first;
auto const& value = hashPairPair.second.first;
// Set storage to zero in state cache
clearStorageValue( _contract, key, value );
// Set storage to zero in the account storage cache
// we have lots of caches, some of them may be unneeded
// will analyze this more in future releases
acc->setStorageCache( key, 0 );
/* The corresponding key/value pair needs to be cleared in database
Inserting ZERO deletes the key during commit
at the end of transaction
see OverlayDB::commitStorageValues()
*/
h256 ZERO( 0 );
m_db_ptr->insert( _contract, key, ZERO );
}

totalStorageUsed_ -= ( accStorageUsed + storageUsage[_contract] );
Expand Down

0 comments on commit 76ca0f4

Please sign in to comment.