Package: crisscross-py
crisscross_pyPython Client for CrissCross NetworkCrissCross - Like IPFS... but with Redis Protocol, a SQL Layer, privacy and distribution as well as file downloadsCrissCross is a new way to share immutable structures. Build a tree, get a hash and distribute it in your own private cluster. Connect with any language that has a redis client.This packageClient to access a Node on the CrissCross network:https://github.com/SoCal-Software-Labs/CrissCrossUsageFollow the instructions on how to setup a CrissCross node:https://github.com/SoCal-Software-Labs/CrissCrossInstall the client:pipinstallcrisscross-pyTourWith CrissCross, you insert values into a hash and get a new hash back. To start a new tree, insert into an empty hash:Bash$MYVAR=$(crisscrossput"""hello""world")# In the bash you get the Base58 Representation$echo$MYVARE555NKZfKRoUc5F62desomHFaQRz6tinAmehCbymudhv
$crisscrossget$MYVAR"hello"worldPythonYou can access the tree programmatically with Python (or any Redis client):>>>client=CrissCross()>>>location=client.put_multi("",[("hello","world")])# In the python client you manipulate the raw hash bytes, not the Base58 Representation>>>locationb"\xc22\xdcz'\x8c\xa0\xc9}Y;\xbe\x1bD4<G6@?\x95\xc1k\x05{\x18\xc4\xc9\xbb\xba\xa65">>>base58.b58encode(location)b'E555NKZfKRoUc5F62desomHFaQRz6tinAmehCbymudhv'>>>client.get_multi(location,["hello"]){b"hello":b"world"}With python you can store arbitrary data... tuples, lists, dictionaries, booleans, integers, floats and atoms. Not just binary text:>>>location=client.put_multi("",[(("wow",1.2),{1:(True,None)})])>>>client.get_multi(location,[("wow",1.2)]){1:(True,None)}UpdatesUpdate a tree by referencing the hash of its previous state:Python>>new_location=client.put_multi(location,[("cool",12345)])b"HfTbW1XjXdT8RbQ7CMJnD2P73RHe3PJvSiPAFNj6Zzhp">>client.get(new_location,"cool")12345Bash$crisscrossput$MYVAR"hello2""world2"47ZGfGj7V3M4HLUirhWWXD7sxD2sciro5YwSBnLinXXpClone and Share TreesOnce you have a hash, you can share it on the network and others can clone it from you:# On one machine$crisscrossannounce^defaultcluster47ZGfGj7V3M4HLUirhWWXD7sxD2sciro5YwSBnLinXXp
47ZGfGj7V3M4HLUirhWWXD7sxD2sciro5YwSBnLinXXp# On other machine query the tree without fully downloading it$crisscrossremote_get^defaultcluster47ZGfGj7V3M4HLUirhWWXD7sxD2sciro5YwSBnLinXXp"hello2""world2"# They can clone the tree to get a local copy$crisscrossremote_clone^defaultcluster47ZGfGj7V3M4HLUirhWWXD7sxD2sciro5YwSBnLinXXp
True
$crisscrossget47ZGfGj7V3M4HLUirhWWXD7sxD2sciro5YwSBnLinXXp"hello""world"SQL EngineFrom Python or Redis you can access the SQL engine. Currently its rather limited (no ALTER TABLE staments and no INDEX support). Those things are supported by the engine (GlueSQL) however are not currently connected to the storage layer and need to be hooked up.>>client=CrissCross()>>>location,ret=client.sql("","CREATE TABLE MyCrissCrossTable (id INTEGER);")>>>print(ret)# Get the result of the execution[(Atom(b'ok'),b'Create')]>>>location2,_=client.sql(location,"INSERT INTO MyCrissCrossTable VALUES (100);")>>>location3,_=client.sql(location2,"INSERT INTO MyCrissCrossTable VALUES (200);")>>>loc,ret=client.sql(location3,"SELECT * FROM MyCrissCrossTable WHERE id > 100;")>>>print(ret[0][1]){b'Select':{b'labels':[b'id'],b'rows':[[{b'I64':200}]]}}Execute many statements at once:>>>location,sqlreturns=client.sql("","CREATE TABLE MyCrissCrossTable (id INTEGER);","INSERT INTO MyCrissCrossTable VALUES (100);","INSERT INTO MyCrissCrossTable VALUES (200);","SELECT * FROM MyCrissCrossTable WHERE id > 100;")>>>print(sqlreturns)[(Atom(b'ok'),b'Create'),(Atom(b'ok'),{b'Insert':1}),(Atom(b'ok'),{b'Insert':1}),(Atom(b'ok'),{b'Select':{b'labels':[b'id'],b'rows':[[{b'I64':200}]]}})]JobsBuild a job server.Servertree,public,priv=client.keypair()client.job_announce(read_var("^defaultcluster"),tree)whileTrue:method,arg,ref=r.job_get(tree)arg=arg+1client.job_respond(ref,arg,tree)Clientresp=client.remote_job_do(read_var("^defaultcluster"),tree,"method",42)print(resp)print(client.job_verify(tree,"method",42,resp[0],resp[1],public))