Skip to content

Commit

Permalink
Merge pull request omgnetwork#31 from deckmon/master
Browse files Browse the repository at this point in the history
snapshot rotate
  • Loading branch information
deckmon authored Jun 23, 2018
2 parents 62c3aa3 + 66e4cb0 commit 50fca24
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions plasma/child_chain/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def list_snapshots():
dir_path = os.path.join(plasma_config["PICKLE_DIR"], dir_name)
if os.path.isdir(dir_path):
res.append(dir_name)
return res
return sorted(res)


def get_max_snapshot():
Expand Down Expand Up @@ -39,4 +39,8 @@ def make_snapshot():
file_path = os.path.join(plasma_config["PICKLE_DIR"], file_name)
if os.path.isfile(file_path) and file_name.endswith(".pickle"):
shutil.copy(file_path, os.path.join(snapshot_dir, file_name))
print("snapshot created")
print("snapshot created")
snapshots = list_snapshots()
if len(snapshots) > plasma_config["MAX_SNAPSHOTS"]:
for snapshot in snapshots[:len(snapshots) - plasma_config["MAX_SNAPSHOTS"]]:
shutil.rmtree(os.path.join(plasma_config["PICKLE_DIR"], snapshot), ignore_errors=True)
4 changes: 3 additions & 1 deletion plasma/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
ROOT_CHAIN_CONTRACT_ADDRESS="0xa3b2a1804203b75b494028966c0f62e677447a39",
NETWORK="http://localhost:8545",
BLOCK_AUTO_SUMBITTER_INTERVAL=1,
MAX_SNAPSHOTS=100,
MIN_SNAPSHOT_SECONDS=10, # set 0 will not make snapshot
)
else:
plasma_config = dict(
ROOT_CHAIN_CONTRACT_ADDRESS="0xC47e711ac6A3D16Db0826c404d8C5d8bDC01d7b1",
NETWORK="http://localhost:8545",
BLOCK_AUTO_SUMBITTER_INTERVAL=30,
MIN_SNAPSHOT_SECONDS=0, # set 0 will not make snapshot
MAX_SNAPSHOTS=50,
MIN_SNAPSHOT_SECONDS=3600, # set 0 will not make snapshot
)

plasma_config["PICKLE_DIR"] = "child_chain_pickle"
Expand Down
2 changes: 1 addition & 1 deletion plasma_tools/chain_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from plasma.child_chain.snapshot import list_snapshots


list_timestamp = lambda: sorted(list_snapshots())
list_timestamp = list_snapshots


class ChildChainSnapshot(object):
Expand Down

0 comments on commit 50fca24

Please sign in to comment.