correct updateblockinfo docstring and format
This commit is contained in:
parent
361853cc95
commit
9369a22841
@ -1,9 +1,12 @@
|
|||||||
'''
|
"""Onionr - Private P2P Communication.
|
||||||
Onionr - Private P2P Communication
|
|
||||||
|
|
||||||
Update block information in the metadata database by a field name
|
Update block information in the metadata database by a field name
|
||||||
'''
|
"""
|
||||||
'''
|
import sqlite3
|
||||||
|
|
||||||
|
from .. import dbfiles
|
||||||
|
from etc import onionrvalues
|
||||||
|
"""
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
@ -16,30 +19,29 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
'''
|
"""
|
||||||
import sqlite3
|
|
||||||
from .. import dbfiles
|
|
||||||
from etc import onionrvalues
|
|
||||||
def update_block_info(hash, key, data):
|
def update_block_info(hash, key, data):
|
||||||
'''
|
"""set info associated with a block
|
||||||
sets info associated with a block
|
|
||||||
|
|
||||||
hash - the hash of a block
|
hash - the hash of a block
|
||||||
dateReceived - the date the block was recieved, not necessarily when it was created
|
dateReceived - the date the block was recieved, not necessarily when it was created
|
||||||
decrypted - if we can successfully decrypt the block (does not describe its current state)
|
decrypted - if we can successfully decrypt the block
|
||||||
dataType - data type of the block
|
dataType - data type of the block
|
||||||
dataFound - if the data has been found for the block
|
dataFound - if the data has been found for the block
|
||||||
dataSaved - if the data has been saved for the block
|
dataSaved - if the data has been saved for the block
|
||||||
sig - optional signature by the author (not optional if author is specified)
|
sig - defunct
|
||||||
author - multi-round partial sha3-256 hash of authors public key
|
author - defunct
|
||||||
dateClaimed - timestamp claimed inside the block, only as trustworthy as the block author is
|
dateClaimed - timestamp claimed inside the block, only as trustworthy as the block author is
|
||||||
expire - expire date for a block
|
expire - expire date for a block
|
||||||
'''
|
"""
|
||||||
if key not in ('dateReceived', 'decrypted', 'dataType', 'dataFound',
|
if key not in ('dateReceived', 'decrypted', 'dataType', 'dataFound',
|
||||||
'dataSaved', 'sig', 'author', 'dateClaimed', 'expire'):
|
'dataSaved', 'sig', 'author', 'dateClaimed', 'expire'):
|
||||||
raise ValueError('Key must be in the allowed list')
|
raise ValueError('Key must be in the allowed list')
|
||||||
|
|
||||||
conn = sqlite3.connect(dbfiles.block_meta_db, timeout=onionrvalues.DATABASE_LOCK_TIMEOUT)
|
conn = sqlite3.connect(dbfiles.block_meta_db,
|
||||||
|
timeout=onionrvalues.DATABASE_LOCK_TIMEOUT)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
args = (data, hash)
|
args = (data, hash)
|
||||||
# Unfortunately, not really possible to prepare this statement
|
# Unfortunately, not really possible to prepare this statement
|
||||||
@ -47,4 +49,4 @@ def update_block_info(hash, key, data):
|
|||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user