In
my previous post I posted the code for a python script that streams the json output from
steemd
, and being a relative newbie to JSON encoding, I didn't realise that JSON does not use or accept single quotes. Here is the output of it (unmodified) from block one:
This has turned out to be an error in piston-lib, which I now am not using anymore, because it's broken and useless. @xeroc
{'extensions': [],
'previous': '0000000000000000000000000000000000000000',
'timestamp': '2016-03-24T16:05:00',
'transaction_merkle_root': '0000000000000000000000000000000000000000',
'transactions': [],
'witness': 'initminer',
'witness_signature': '204f8ad56a8f5cf722a02b035a61b500aa59b9519b2c33c77a80c0a714680a5a5a7a340d909d19996613c5e4ae92146b9add8a7a663eef37d837ef881477313043'}
This is the raw output that I pushed into a file you can see on ftp://projectinception.lt/block_log.json.xz (I am not making the uncompressed form because it is 31Gb (this is basically the whole block_log
up until sometime yesterday).
Anyone who knows JSON can tell you this is the wrong format. But guess what, this is what comes out of an RPC node. I had to write this little gem to fix it:
out_block = json.loads ( str ( block ).replace("'", '%temp%').replace('"', '\"').replace('%temp%', '"') )
and to be clear, this is how that data was acquired, in the same code:
props = rpc.get_dynamic_global_properties ( )
current_block = args.startblock
last_confirmed_block = props [ 'last_irreversible_block_num' ]
if args.startblock == -1:
current_block = last_confirmed_block
while True:
os.write ( 2, str.encode( "Block #" + str ( current_block ) + '\r' ) )
#try:
block = rpc.get_block(current_block)
I don't think this is @xeroc's error, this is a raw string coming out of steemd
This is the kind of inane nonsense that us developers are dealing with. I am making it known exactly what goes on because it is precisely this kind of repeated experience of incorrect programming that is probably an unspoken reason why so few developers are working with the chain.
I am doing this because I am determined to resolve this for the community and if Steemit isn't going to do the right thing, then we are going to give you all an exit route.
If you know a bit of how to work with python, you can find this code in the 'misc' repository on the dawn-network
here: https://github.com/dawn-network/misc
Update
I have realised that the already long string substitution is going to break the single quotes inside the double quotes. I am importing the whole chain snapshot I made two days ago, so I have to write the correct substitution. I will write it in sed script because it will be a lot faster. Stay tuned for an update.
It gets worse too:
'Without any further ado, here is '
'the python script, it depends on '
"`piston-lib`'s module `pistonapi` "
'from @xeroc.\n'
For absolutely no good reason, now I have to write a very complex string processing algorithm that recognises correct sections, and leaves them alone, but fixes all the ones that are wrong. This is so nonstandard and wrong, my mind is blowing at the amount of work that this is going to cause me to have to do.
In fact I'd say that it would probably be less work after everything I have had to do so far, to just write a program that reads the binary data out of the block_log
itself.
UPDATE
It is an error in piston-lib. So now I am quitting with working with python. Here is the request performed by curl
:
{"id":1,"result":{"previous":"0000000000000000000000000000000000000000","timestamp":"2016-03-24T16:05:00","witness":"initminer","transaction_merkle_root":"0000000000000000000000000000000000000000","extensions":[],"witness_signature":"204f8ad56a8f5cf722a02b035a61b500aa59b9519b2c33c77a80c0a714680a5a5a7a340d909d19996613c5e4ae92146b9add8a7a663eef37d837ef881477313043","transactions":[]}}
curl --data '{"jsonrpc": "2.0", "method": "get_block", "params": [1], "id": 1 }' http://127.0.0.1:8090/rpc
We can't code here! This is Whale country!
Vote #1 l0k1
Go to steemit.com/~witnesses to cast your vote by copying and pasting l0k1
into the text entry at the bottom of the leaderboard.
(note, my username is spelled El Zero Kay One
or Lima Zero Kilo One
, all lower case)