deploy: d8286623879d42e7b8401a62a7bd2e53d1dc4189

This commit is contained in:
kaiserd 2022-04-23 09:15:35 +00:00
parent 9775a50c8b
commit adf517bddb

View File

@ -100,6 +100,12 @@ proc init*(T: type WakuMessageStore, db: SqliteDatabase, storeCapacity: int = 50
let numMessages = messageCount(db).get()
debug "number of messages in sqlite database", messageNum=numMessages
# add index on receiverTimestamp
let addIndexStmt = "CREATE INDEX IF NOT EXISTS i_rt ON " & TABLE_TITLE & "(receiverTimestamp);"
let resIndex = db.query(addIndexStmt, proc(s: ptr sqlite3_stmt) = discard)
if resIndex.isErr:
return err("Could not establish index on receiverTimestamp: " & resIndex.error)
let storeMaxLoad = int(float(storeCapacity) * MaxStoreOverflow)
let deleteWindow = int(float(storeMaxLoad - storeCapacity) / 2)
let wms = WakuMessageStore(database: db,