From 54c303b0160528bc7335b0a2855a0a3ba9e80f30 Mon Sep 17 00:00:00 2001 From: Vladimir Kamarzin Date: Wed, 3 Apr 2019 11:34:29 +0500 Subject: [PATCH] Add storagedemo example from previously removed strategy --- docs/storage.rst | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/docs/storage.rst b/docs/storage.rst index d9c02c6d1..4f813ab21 100644 --- a/docs/storage.rst +++ b/docs/storage.rst @@ -40,16 +40,31 @@ Where ```` is ``dexbot`` and ```` is Simple example -------------- +.. code-block:: python -.. literalinclude:: ../dexbot/strategies/storagedemo.py - :language: python - :linenos: + from dexbot.basestrategy import BaseStrategy + + + class Strategy(BaseStrategy): + """ + Storage demo strategy + Strategy that prints all new blocks in the blockchain + """ + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.ontick += self.tick + + def tick(self, i): + print("previous block: %s" % self["block"]) + print("new block: %s" % i) + self["block"] = i **Example Output:** :: - Current Wallet Passphrase: + Current Wallet Passphrase: previous block: None new block: 008c4c2424e6394ad4bf5a9756ae2ee883b0e049 previous block: 008c4c2424e6394ad4bf5a9756ae2ee883b0e049