added get data function, work on submitting/recieving data
This commit is contained in:
parent
b62f799b02
commit
5af2b99135
@ -129,8 +129,10 @@ class API:
|
|||||||
pass
|
pass
|
||||||
elif action == 'getPGP':
|
elif action == 'getPGP':
|
||||||
resp = Response(self._utils.exportMyPubkey())
|
resp = Response(self._utils.exportMyPubkey())
|
||||||
elif action == 'storeData':
|
elif action == 'setData':
|
||||||
pass
|
pass
|
||||||
|
elif action == 'getData':
|
||||||
|
resp = Response(self._core.getData(data))
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ class OnionrCommunicate:
|
|||||||
def sendPeerProof(self, peerID, data):
|
def sendPeerProof(self, peerID, data):
|
||||||
'''This function sends the proof result to a peer previously fetched with getPeerProof'''
|
'''This function sends the proof result to a peer previously fetched with getPeerProof'''
|
||||||
return
|
return
|
||||||
|
|
||||||
def performGet(self, action, peer, data=None, type='tor'):
|
def performGet(self, action, peer, data=None, type='tor'):
|
||||||
'''performs a request to a peer through Tor or i2p (currently only tor)'''
|
'''performs a request to a peer through Tor or i2p (currently only tor)'''
|
||||||
if not peer.endswith('.onion') and not peer.endswith('.onion/'):
|
if not peer.endswith('.onion') and not peer.endswith('.onion/'):
|
||||||
|
@ -31,8 +31,8 @@ class Core:
|
|||||||
self.peerDB = 'data/peers.db'
|
self.peerDB = 'data/peers.db'
|
||||||
self.ownPGPID = ''
|
self.ownPGPID = ''
|
||||||
self.blockDB = 'data/blocks.db'
|
self.blockDB = 'data/blocks.db'
|
||||||
|
self.blockDataLocation = 'data/blocks/'
|
||||||
|
|
||||||
#self.daemonQueue() # Call to create the DB if it doesn't exist
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def generateMainPGP(self, myID):
|
def generateMainPGP(self, myID):
|
||||||
@ -118,6 +118,13 @@ class Core:
|
|||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
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):
|
def dataDirEncrypt(self, password):
|
||||||
'''
|
'''
|
||||||
Encrypt the data directory on Onionr shutdown
|
Encrypt the data directory on Onionr shutdown
|
||||||
|
Loading…
Reference in New Issue
Block a user