added get data function, work on submitting/recieving data

master
Kevin Froman 2018-01-21 03:12:41 -06:00
parent b62f799b02
commit 5af2b99135
3 changed files with 12 additions and 2 deletions

View File

@ -129,8 +129,10 @@ class API:
pass
elif action == 'getPGP':
resp = Response(self._utils.exportMyPubkey())
elif action == 'storeData':
elif action == 'setData':
pass
elif action == 'getData':
resp = Response(self._core.getData(data))
return resp

View File

@ -69,6 +69,7 @@ class OnionrCommunicate:
def sendPeerProof(self, peerID, data):
'''This function sends the proof result to a peer previously fetched with getPeerProof'''
return
def performGet(self, action, peer, data=None, type='tor'):
'''performs a request to a peer through Tor or i2p (currently only tor)'''
if not peer.endswith('.onion') and not peer.endswith('.onion/'):

View File

@ -31,8 +31,8 @@ class Core:
self.peerDB = 'data/peers.db'
self.ownPGPID = ''
self.blockDB = 'data/blocks.db'
self.blockDataLocation = 'data/blocks/'
#self.daemonQueue() # Call to create the DB if it doesn't exist
return
def generateMainPGP(self, myID):
@ -118,6 +118,13 @@ class Core:
conn.commit()
conn.close()
def getData(self,hash):
'''simply return the data associated to a hash'''
dataFile = open(self.blockDataLocation + hash + '.dat')
data = dataFile.read()
dataFile.close()
return data
def dataDirEncrypt(self, password):
'''
Encrypt the data directory on Onionr shutdown