iota.py icon indicating copy to clipboard operation
iota.py copied to clipboard

Create decode_bundle_messages.py

Open harleylang opened this issue 6 years ago • 3 comments

I really struggled in writing code that grabs messages across transactions in a bundle, so here is a mwe that others may find beneficial.

harleylang avatar Sep 05 '18 20:09 harleylang

Hi @harleylang thanks for submitting this!

Have a look at Bundle.get_messages() — it might be possible to make the code even simpler by using this method.

todofixthis avatar Sep 05 '18 21:09 todofixthis

Hey, thanks for your feedback! I was unaware of that function at the time of my OP and I appreciate the reference.

I have been giving this a lot of thought and have tested a few options for message gathering over the past few months. So far I have found that the most efficient message-gathering function pings a node for tangle information only as needed. `Bundle.get_messages()' pings the node for info on each recursion. Larger messages take exponentially more time to recover with this method. In my next comment to this thread, I am going to propose a function that cuts-down node/tangle pings by gathering transaction trytes at the onset. Next, the function iterates through that information for the message. From my testing, that seems to be the most efficient way to gather messages. For a 32-index message, this cuts the duration down from ~25 seconds to 5 seconds.

After I post my solution, I welcome peer review to ensure that we identify and accept the function that is the most efficient, but also safe. (The latter of which is not currently within my expertise.)

harleylang avatar Feb 21 '19 05:02 harleylang

Further to my last comment, I want to clarify that the ping issue is not /specifically/ with Bundle.get_messages() but instead with Iota.get_bundles() which I understand needs to be used to generate a bundle object and therefore call bundleobj.get_messages().

I will post comparison code and function options soon.

harleylang avatar Feb 22 '19 04:02 harleylang