diff --git a/onionr/api.py b/onionr/api.py index c47b5339..29f8282f 100755 --- a/onionr/api.py +++ b/onionr/api.py @@ -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 diff --git a/onionr/communicator.py b/onionr/communicator.py index 40979bbc..ec29fb3d 100755 --- a/onionr/communicator.py +++ b/onionr/communicator.py @@ -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/'): diff --git a/onionr/core.py b/onionr/core.py index b3398738..0c476217 100644 --- a/onionr/core.py +++ b/onionr/core.py @@ -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