2019-06-26 05:26:50 +00:00
|
|
|
'''
|
|
|
|
Onionr - Private P2P Communication
|
|
|
|
|
|
|
|
Get a list of expired blocks still stored
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
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/>.
|
|
|
|
'''
|
2019-06-22 21:16:12 +00:00
|
|
|
import sqlite3
|
2019-06-25 23:07:35 +00:00
|
|
|
from onionrutils import epoch
|
2019-07-17 16:58:40 +00:00
|
|
|
from .. import dbfiles
|
|
|
|
def get_expired_blocks():
|
2019-06-22 21:16:12 +00:00
|
|
|
'''Returns a list of expired blocks'''
|
2019-07-17 16:58:40 +00:00
|
|
|
conn = sqlite3.connect(dbfiles.block_meta_db, timeout=30)
|
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
|