Skip to content

Commit

Permalink
Move leveldb specific calls to Database
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphtheninja committed Dec 15, 2018
1 parent 3ede7b3 commit 20f2aea
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions napi/leveldown.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ struct Database {
}
}

leveldb::Status Open(const leveldb::Options& options,
const char* location) {
return leveldb::DB::Open(options, location, &db_);
}

leveldb::Status Put(const leveldb::WriteOptions& options,
leveldb::Slice key,
leveldb::Slice value) {
return db_->Put(options, key, value);
}

napi_env env_;
leveldb::DB* db_;
leveldb::Cache* blockCache_;
Expand Down Expand Up @@ -219,7 +230,7 @@ struct OpenWorker : public BaseWorker {
}

virtual void DoExecute() {
status_ = leveldb::DB::Open(options_, location_, &database_->db_);
status_ = database_->Open(options_, location_);
}

leveldb::Options options_;
Expand Down Expand Up @@ -352,7 +363,7 @@ struct PutWorker : public BaseWorker {
}

virtual void DoExecute() {
status_ = database_->db_->Put(options_, key_, value_);
status_ = database_->Put(options_, key_, value_);
}

leveldb::WriteOptions options_;
Expand Down

0 comments on commit 20f2aea

Please sign in to comment.