diff --git a/src/blockstore/implementations/versioncounting/VersionCountingBlockStore2.h b/src/blockstore/implementations/versioncounting/VersionCountingBlockStore2.h index f73d96f0..251deb3d 100644 --- a/src/blockstore/implementations/versioncounting/VersionCountingBlockStore2.h +++ b/src/blockstore/implementations/versioncounting/VersionCountingBlockStore2.h @@ -48,22 +48,9 @@ public: boost::future store(const Key &key, const cpputils::Data &data) override { _checkNoPastIntegrityViolations(); - //TODO There's a bug in the next branch in override(). They have to load and read the old version number too. - return load(key).then([this, key, data = data.copy()] (boost::future> loaded_) { - auto loaded = loaded_.get(); - if (boost::none == loaded) { - return tryCreate(key, data).then([] (boost::future success) { - if (!success.get()) { - throw std::runtime_error("Could neither store nor create the block in VersionCountingBlockStore::store"); - } - }); - } - // Loading the block already read the newest version number into _knownBlockVersions, now we only have to increment it - // TODO Check that (with a caching blockstore below) this doesn't impact performance - uint64_t version = _knownBlockVersions.incrementVersion(key); - cpputils::Data dataWithHeader = _prependHeaderToData(_knownBlockVersions.myClientId(), version, data); - return _baseBlockStore->store(key, dataWithHeader); - }); + uint64_t version = _knownBlockVersions.incrementVersion(key); + cpputils::Data dataWithHeader = _prependHeaderToData(_knownBlockVersions.myClientId(), version, data); + return _baseBlockStore->store(key, dataWithHeader); } private: diff --git a/src/blockstore/interface/BlockStore2.h b/src/blockstore/interface/BlockStore2.h index 26fb3e0e..55b2daa1 100644 --- a/src/blockstore/interface/BlockStore2.h +++ b/src/blockstore/interface/BlockStore2.h @@ -22,6 +22,8 @@ public: virtual boost::future remove(const Key &key) = 0; virtual boost::future> load(const Key &key) const = 0; + + // Store the block with the given key. If it doesn't exist, it is created. virtual boost::future store(const Key &key, const cpputils::Data &data) = 0; boost::future create(cpputils::Data data) {