2020-08-17 00:52:50 +00:00
|
|
|
"""Onionr - Private P2P Communication.
|
2019-06-26 05:26:50 +00:00
|
|
|
|
2020-08-17 00:52:50 +00:00
|
|
|
Get a list of expired blocks still stored
|
|
|
|
"""
|
|
|
|
import sqlite3
|
|
|
|
from onionrutils import epoch
|
|
|
|
from .. import dbfiles
|
|
|
|
from etc import onionrvalues
|
|
|
|
"""
|
2019-06-26 05:26:50 +00:00
|
|
|
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/>.
|
2020-08-17 00:52:50 +00:00
|
|
|
"""
|
|
|
|
|
2019-10-29 05:36:56 +00:00
|
|
|
|
2019-07-17 16:58:40 +00:00
|
|
|
def get_expired_blocks():
|
2020-08-17 00:52:50 +00:00
|
|
|
"""Return a list of expired blocks"""
|
|
|
|
conn = sqlite3.connect(
|
|
|
|
dbfiles.block_meta_db, timeout=onionrvalues.DATABASE_LOCK_TIMEOUT)
|
2019-06-22 21:16:12 +00:00
|
|
|
c = conn.cursor()
|
2019-06-25 23:07:35 +00:00
|
|
|
date = int(epoch.get_epoch())
|
2019-06-22 21:16:12 +00:00
|
|
|
|
2019-09-09 00:21:36 +00:00
|
|
|
compiled = (date,)
|
|
|
|
execute = 'SELECT hash FROM hashes WHERE expire <= ? ORDER BY dateReceived;'
|
2019-06-22 21:16:12 +00:00
|
|
|
|
|
|
|
rows = list()
|
2019-09-09 00:21:36 +00:00
|
|
|
for row in c.execute(execute, compiled):
|
2019-06-22 21:16:12 +00:00
|
|
|
for i in row:
|
|
|
|
rows.append(i)
|
|
|
|
conn.close()
|
|
|
|
return rows
|