Sorry for the late post, but I spent the entire day today getting the storage pruning functionality straight. The more we can prune from the actual blockchain without losing integrity, the bigger our jobs can become without bloating the blockchain itself.
But so you can see that things are going forward quickly,
here one example how to use Elastic directly from within Python. Since I changed several things, and since I was pretty tied up in the storage handling, this is just a very dumb example. But since Elastic PL is a very powerful language, one can easily come up with something better. I will post my GA algorithms tomorrow.
Also, we seriously lack a documentation and a centralized place where everything is collected. So maybe someone likes this and start digging a bit deeper.
Here we go:
First of all, it has to be ensured that a local instance of Elastic is running and at least one connection to a supernode is established. Of course, you can find a "public API peer" as well, but this way is just easier:
In a next step, we have to create our Elastic PL program. This one here is super stupid.
You have to know that:
m[0] to m[11] are random integers that are filled in by the blockchain
m[12] to m[43] are free to use, but the content will be written back to the blockchain (a storage basically) when a bounty is submitted
m[44] to m[44+32*BOUNTY_PER_ITERATION] are the "combined storage values". So let us say you want 2 bounties per iteration, each of them supplying a storage of 32 integers (m12-m43) then, 2*32 integers containing the storage of all bounties from the last iteration are put from m[44] onwards.Pretty lowlevel, let's take a look at the stupidest program ever:
Self explaining: if random integer m[7] is beteen 0 and 30 then set m[1000]=10, otherwise 11.
Then, if m[1000]==10 then take the first element from the combined storage (means the first int from the storage of the first bounty from the last iteration), add one, and store it back in m[12] - the first integer of the storage that will be reported back to the blockchain.
It's very easy actually, if you explain it better than I do.
Last but not least, take your python program which uses the Elastic API bindings to control your work. The example I have written will monitor the blockchain, push the work automatically, and automatically report back the result once finished. I configured 5
You can take a look at the code on github yourself, for completeness - this is how it looks:
Now comes the magic - just start your program and your python program will use the elastic network to compute the result.
As you can see below, the result is correct ;-) The tricky ones of you can try to understand why this is correct. I always say, the best way to learn is try to understand every single step ;-) And I am pretty tired after just another 13 hours of work straight.
Nothing useful, but something that shows: it works! And it works good
And since we have an actual programming language, let me say it with Golem's words: sky is the limit Example and API is here by the way:
https://github.com/OrdinaryDude/elastic-api