예제 #1
0
파일: Account.cs 프로젝트: zutobg/Meadow
        public void CommitStorageChanges()
        {
            // For each storage cache item, we want to flush those changes to the main trie/database.
            foreach (var key in StorageCache.Keys)
            {
                // If the value is null, it means the value is non existent anymore, so we remove the key value pair
                if (StorageCache[key] == null)
                {
                    StorageTrie.Remove(key);
                }
                else
                {
                    // Otherwise we set the new value.
                    StorageTrie.Set(key, RLP.Encode(StorageCache[key]));
                }
            }

            // Now we clear our cache.
            StorageCache.Clear();

            // And update our account's storage root hash.
            StorageRoot = StorageTrie.GetRootNodeHash();
        }