Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #611 from CityOfZion/persist-reset-fix
Browse files Browse the repository at this point in the history
Persist reset fix
  • Loading branch information
localhuman authored Sep 18, 2018
2 parents cfc8361 + 0cc9c03 commit 951de3a
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 155 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ All notable changes to this project are documented in this file.
-----------------------
- Implemented `sendtoaddress` RPC method `#556 <https://github.com/CityOfZion/neo-python/pull/556>`_
- Gracefully handle network packet deserialization failures
- Fix issue resetting storage between Smart Contract invocations
- Default ``ApplicationConfiguration.AcceptIncomingPeers`` to ``False``, if config value is not present


[0.7.8] 2018-09-06
------------------
- Prefix ``vin`` JSON output format to match C#
Expand Down
Binary file modified fixtures/testwallet.db3
Binary file not shown.
2 changes: 1 addition & 1 deletion neo/Core/Blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def CurrentBlock(self):
def AddBlock(self, block):
pass

def AddBlockDirectly(self, block):
def AddBlockDirectly(self, block, do_persist_complete=True):
pass

def AddHeaders(self, headers):
Expand Down
27 changes: 20 additions & 7 deletions neo/Implementations/Blockchains/LevelDB/DBCollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

class DBCollection:
DB = None
# SN = None
Prefix = None

ClassRef = None
Expand All @@ -19,7 +18,10 @@ class DBCollection:

DebugStorage = False

def __init__(self, db, sn, prefix, class_ref):
_ChangedResetState = None
_DeletedResetState = None

def __init__(self, db, prefix, class_ref):

self.DB = db

Expand All @@ -31,6 +33,9 @@ def __init__(self, db, sn, prefix, class_ref):
self.Changed = []
self.Deleted = []

self._ChangedResetState = None
self._DeletedResetState = None

@property
def Keys(self):
if not self._built_keys:
Expand Down Expand Up @@ -71,12 +76,15 @@ def Commit(self, wb, destroy=True):
else:
self.Changed = []
self.Deleted = []
self._ChangedResetState = None
self._DeletedResetState = None

def Reset(self):
for keyval in self.Changed:
self.Collection[keyval] = None
self.Changed = []
self.Deleted = []
self.Changed = self._ChangedResetState
self.Deleted = self._DeletedResetState

self._ChangedResetState = None
self._DeletedResetState = None

def GetAndChange(self, keyval, new_instance=None, debug_item=False):

Expand Down Expand Up @@ -173,6 +181,10 @@ def Remove(self, keyval):
if keyval not in self.Deleted:
self.Deleted.append(keyval)

def MarkForReset(self):
self._ChangedResetState = self.Changed
self._DeletedResetState = self.Deleted

def MarkChanged(self, keyval):
if keyval not in self.Changed:
self.Changed.append(keyval)
Expand Down Expand Up @@ -206,10 +218,11 @@ def Find(self, key_prefix):

def Destroy(self):
self.DB = None
# self.SN = None
self.Collection = None
self.ClassRef = None
self.Prefix = None
self.Deleted = None
self.Changed = None
self._ChangedResetState = None
self._DeletedResetState = None
logger = None
Loading

0 comments on commit 951de3a

Please sign in to comment.