From 4c51d7cb0a17df46632df4595540eb52b57d66eb Mon Sep 17 00:00:00 2001 From: Martin Boehm Date: Mon, 12 Mar 2018 16:28:52 +0100 Subject: [PATCH] Add rocksdb reopen db method Mainly used for debugging purposes --- db/rocksdb.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/db/rocksdb.go b/db/rocksdb.go index d5b9360a..d178a973 100644 --- a/db/rocksdb.go +++ b/db/rocksdb.go @@ -120,6 +120,22 @@ func (d *RocksDB) Close() error { return nil } +// Reopen reopens the database +// It closes and reopens db, nobody can access the database during the operation! +func (d *RocksDB) Reopen() error { + err := d.closeDB() + if err != nil { + return err + } + d.db = nil + db, cfh, err := openDB(d.path) + if err != nil { + return err + } + d.db, d.cfh = db, cfh + return nil +} + // GetTransactions finds all input/output transactions for address specified by outputScript. // Transaction are passed to callback function. func (d *RocksDB) GetTransactions(outputScript []byte, lower uint32, higher uint32, fn func(txid string, vout uint32, isOutput bool) error) (err error) {