From c912b0b70c2c5e74bec30227f05f0c87f5d180ed Mon Sep 17 00:00:00 2001
From: Holger Nahrstaedt <holger@nahrstaedt.de>
Date: Tue, 1 May 2018 20:59:38 +0200
Subject: [PATCH] Improved Tutorial and Readme

Added Use nobroadcast for testing and Clear BlockchainObject Caching
---
 README.rst         | 22 ++++++-------
 beem/market.py     | 14 ++++----
 docs/tutorials.rst | 81 +++++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 92 insertions(+), 25 deletions(-)

diff --git a/README.rst b/README.rst
index 53e42033..a39fbd3d 100644
--- a/README.rst
+++ b/README.rst
@@ -42,9 +42,11 @@ Current build status
    :target: https://codeclimate.com/github/holgern/beem/test_coverage
    :alt: Test Coverage
 
-Support
-=======
-You may find help at https://discord.gg/4HM592V. The discord channel can also be used to discuss things about beem.
+Support & Documentation
+=======================
+You may find help in the `discord-channel`_. The discord channel can also be used to discuss things about beem.
+
+A complete library documentation is available at  `beem-readthedocs-io`_.
 
 Installation
 ============
@@ -116,15 +118,11 @@ Signing and Verify can be fasten (200 %) by installing cryptography::
     conda install cryptography
     
 
-CLI tool bundled
-----------------
-I started to work on a CLI tool::
-
-    beempy
+CLI tool beempy
+---------------
+A command line tool is available. The help output shows the available commands:
 
-Documentation
-=============
-Documentation is available at http://beem.readthedocs.io/en/latest/
+    beempy --help
 
 Changelog
 =========
@@ -310,3 +308,5 @@ Acknowledgements
 .. _python-bitshares: https://github.com/xeroc/python-bitshares
 .. _Python: http://python.org
 .. _Anaconda: https://www.continuum.io
+.. _beem-readthedocs-io: http://beem.readthedocs.io/en/latest/
+.. _discord-channel: https://discord.gg/4HM592V
diff --git a/beem/market.py b/beem/market.py
index 37714b07..594603f3 100644
--- a/beem/market.py
+++ b/beem/market.py
@@ -121,12 +121,14 @@ class Market(dict):
 
             .. code-block:: js
 
-                 {'highest_bid': 0.30100226633322913,
-                  'latest': 0.0,
-                  'lowest_ask': 0.3249636958897082,
-                  'percent_change': 0.0,
-                  'sbd_volume': 108329611.0,
-                  'steem_volume': 355094043.0}
+                 {
+                    'highest_bid': 0.30100226633322913,
+                    'latest': 0.0,
+                    'lowest_ask': 0.3249636958897082,
+                    'percent_change': 0.0,
+                    'sbd_volume': 108329611.0,
+                    'steem_volume': 355094043.0
+                }
 
         """
         data = {}
diff --git a/docs/tutorials.rst b/docs/tutorials.rst
index ac6ec1f9..ec15276e 100644
--- a/docs/tutorials.rst
+++ b/docs/tutorials.rst
@@ -10,6 +10,7 @@ transactions. This can be used to do a multi-send (one sender, multiple
 receivers), but it also allows to use any other kind of operation. The
 advantage here is that the user can be sure that the operations are
 executed in the same order as they are added to the transaction.
+
 A block can only include one vote operation and
 one comment operation from each sender.
 
@@ -21,19 +22,18 @@ one comment operation from each sender.
   from beem.comment import Comment
   from beem.instance import set_shared_steem_instance
 
-  # Only for testing not a real working key
+  # not a real working key
   wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
 
-  # set nobroadcast always to True, when testing
-  testnet = Steem(
-      nobroadcast=True,
-      bundle=True,
+  stm = Steem(
+      bundle=True, # Enable bundle broadcast
+      # nobroadcast=True, # Enable this for testing
       keys=[wif],
   )
-  # Set testnet as shared instance
-  set_shared_steem_instance(testnet)
+  # Set stm as shared instance
+  set_shared_steem_instance(stm)
 
-  # Account and Comment will use now testnet
+  # Account and Comment will use now stm
   account = Account("test")
 
   # Post 
@@ -48,6 +48,71 @@ one comment operation from each sender.
   pprint(testnet.broadcast())
 
 
+Use nobroadcast for testing
+---------------------------
+
+When using  `nobroadcast=True` the transaction is not broadcasted but printed.
+
+.. code-block:: python
+
+  from pprint import pprint
+  from beem import Steem
+  from beem.account import Account
+  from beem.instance import set_shared_steem_instance
+
+  # Only for testing not a real working key
+  wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
+
+  # set nobroadcast always to True, when testing
+  testnet = Steem(
+      nobroadcast=True, # Set to false when want to go live
+      keys=[wif],
+  )
+  # Set testnet as shared instance
+  set_shared_steem_instance(testnet)
+
+  # Account will use now testnet
+  account = Account("test")
+
+  pprint(account.transfer("test1", 1, "STEEM"))
+
+When excecuting the script above, the output will be similar to the following:
+
+.. code-block:: js
+
+    Not broadcasting anything!
+    {'expiration': '2018-05-01T16:16:57',
+     'extensions': [],
+     'operations': [['transfer',
+                     {'amount': '1.000 STEEM',
+                      'from': 'test',
+                      'memo': '',
+                      'to': 'test1'}]],
+     'ref_block_num': 33020,
+     'ref_block_prefix': 2523628005,
+     'signatures': ['1f57da50f241e70c229ed67b5d61898e792175c0f18ae29df8af414c46ae91eb5729c867b5d7dcc578368e7024e414c237f644629cb0aa3ecafac3640871ffe785']}
+
+Clear BlockchainObject Caching
+------------------------------
+
+Each BlockchainObject (Account, Comment, Vote, Witness, Amount, ...) has a glocal cache. This cache
+stores all objects and could lead to increased memory consumption. The global cache can be cleared
+with a `clear_cache()` call from any BlockchainObject.
+
+.. code-block:: python
+
+  from pprint import pprint
+  from beem.account import Account
+
+  account = Account("test")
+  pprint(str(account._cache))
+  account1 = Account("test1")
+  pprint(str(account._cache))
+  pprint(str(account1._cache))
+  account.clear_cache()
+  pprint(str(account._cache))
+  pprint(str(account1._cache))
+
 Simple Sell Script
 ------------------
 
-- 
GitLab