bumped network version and main version, lots of test work and some stability improvements
This commit is contained in:
parent
e77d422fc2
commit
572e29f5d5
24 changed files with 243 additions and 33 deletions
|
@ -77,7 +77,7 @@ def store(data, blockHash=''):
|
|||
raise ValueError('Hash specified does not meet internal hash check')
|
||||
else:
|
||||
blockHash = ourHash
|
||||
|
||||
|
||||
if DB_ENTRY_SIZE_LIMIT >= sys.getsizeof(data):
|
||||
_dbInsert(blockHash, data)
|
||||
else:
|
||||
|
@ -86,21 +86,23 @@ def store(data, blockHash=''):
|
|||
|
||||
|
||||
def getData(bHash):
|
||||
|
||||
if not stringvalidators.validate_hash(bHash): raise ValueError
|
||||
|
||||
bHash = bytesconverter.bytes_to_str(bHash)
|
||||
|
||||
bHash = bHash.strip()
|
||||
# First check DB for data entry by hash
|
||||
# if no entry, check disk
|
||||
# If no entry in either, raise an exception
|
||||
retData = None
|
||||
fileLocation = '%s/%s.dat' % (filepaths.block_data_location, bHash)
|
||||
not_found_msg = "Flock data not found for: "
|
||||
not_found_msg = "Block data not found for: "
|
||||
if os.path.exists(fileLocation):
|
||||
with open(fileLocation, 'rb') as block:
|
||||
retData = block.read()
|
||||
else:
|
||||
retData = _dbFetch(bHash)
|
||||
|
||||
if retData is None:
|
||||
raise onionrexceptions.NoDataAvailable(not_found_msg + str(bHash))
|
||||
return retData
|
||||
|
|
|
@ -1,13 +1,31 @@
|
|||
import sys, sqlite3
|
||||
"""Onionr - Private P2P Communication.
|
||||
|
||||
Test Onionr as it is running
|
||||
"""
|
||||
import sys
|
||||
import sqlite3
|
||||
|
||||
import onionrstorage, onionrexceptions, onionrcrypto as crypto
|
||||
import filepaths
|
||||
from onionrblocks import storagecounter
|
||||
from coredb import dbfiles
|
||||
from onionrutils import blockmetadata, bytesconverter
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
def set_data(data)->str:
|
||||
'''
|
||||
Set the data assciated with a hash
|
||||
'''
|
||||
"""Set the data assciated with a hash."""
|
||||
storage_counter = storagecounter.StorageCounter()
|
||||
data = data
|
||||
dataSize = sys.getsizeof(data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue