Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
ancelmo committed Mar 28, 2019
1 parent b15cd98 commit 574a8d2
Show file tree
Hide file tree
Showing 34 changed files with 131 additions and 117 deletions.
5 changes: 4 additions & 1 deletion libblockchain/BlockChainImp.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ class BlockChainImp : public BlockChainInterface
void getNonces(
std::vector<dev::eth::NonceKeyType>& _nonceVector, int64_t _blockNumber) override;

void setTableFactoryFactory(dev::storage::TableFactoryFactory::Ptr tableFactoryFactory) { m_tableFactoryFactory = tableFactoryFactory; }
void setTableFactoryFactory(dev::storage::TableFactoryFactory::Ptr tableFactoryFactory)
{
m_tableFactoryFactory = tableFactoryFactory;
}

private:
std::shared_ptr<dev::eth::Block> getBlock(int64_t _i);
Expand Down
3 changes: 2 additions & 1 deletion libblockverifier/ExecutiveContextFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ void ExecutiveContextFactory::initExecutiveContext(
memoryTableFactory->setBlockHash(blockInfo.hash);
memoryTableFactory->setBlockNum(blockInfo.number);
#endif
auto memoryTableFactory = m_tableFactoryFactory->newTableFactory(blockInfo.hash, blockInfo.number);
auto memoryTableFactory =
m_tableFactoryFactory->newTableFactory(blockInfo.hash, blockInfo.number);

auto tableFactoryPrecompiled = std::make_shared<dev::blockverifier::TableFactoryPrecompiled>();
tableFactoryPrecompiled->setMemoryTableFactory(memoryTableFactory);
Expand Down
5 changes: 4 additions & 1 deletion libblockverifier/ExecutiveContextFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ class ExecutiveContextFactory : public std::enable_shared_from_this<ExecutiveCon
virtual void setStateFactory(
std::shared_ptr<dev::executive::StateFactoryInterface> stateFactoryInterface);

virtual void setTableFactoryFactory(dev::storage::TableFactoryFactory::Ptr tableFactoryFactory) { m_tableFactoryFactory = tableFactoryFactory; }
virtual void setTableFactoryFactory(dev::storage::TableFactoryFactory::Ptr tableFactoryFactory)
{
m_tableFactoryFactory = tableFactoryFactory;
}

private:
dev::storage::TableFactoryFactory::Ptr m_tableFactoryFactory;
Expand Down
2 changes: 1 addition & 1 deletion libconsensus/pbft/PBFTEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
#include <libdevcore/FileSystem.h>
#include <libdevcore/LevelDB.h>
#include <libdevcore/concurrent_queue.h>
#include <libstorage/Storage.h>
#include <libsync/SyncStatus.h>
#include <sstream>
#include <libstorage/Storage.h>

#include <libp2p/P2PMessageFactory.h>
#include <libp2p/P2PSession.h>
Expand Down
8 changes: 4 additions & 4 deletions libledger/DBInitializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
* @date: 2018-10-24
*/
#include "DBInitializer.h"
#include <libstorage/SQLStorage.h>
#include "LedgerParam.h"
#include <libconfig/GlobalConfigure.h>
#include <libdevcore/Common.h>
#include <libmptstate/MPTStateFactory.h>
#include <libsecurity/EncryptedLevelDB.h>
#include <libstorage/LevelDBStorage.h>
#include <libstoragestate/StorageStateFactory.h>
#include <libstorage/MemoryTableFactoryFactory.h>
#include <libstorage/MemoryTableFactoryFactory2.h>
#include <libstorage/SQLStorage.h>
#include <libstoragestate/StorageStateFactory.h>

using namespace dev;
using namespace dev::storage;
Expand Down Expand Up @@ -145,9 +145,9 @@ void DBInitializer::initSQLStorage()
m_storage = sqlStorage;

auto tableFactoryFactory = std::make_shared<dev::storage::MemoryTableFactoryFactory2>();
tableFactoryFactory->setStorage(m_storage);
tableFactoryFactory->setStorage(m_storage);

m_tableFactoryFactory = tableFactoryFactory;
m_tableFactoryFactory = tableFactoryFactory;
}

/// create ExecutiveContextFactory
Expand Down
2 changes: 1 addition & 1 deletion libledger/Ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ bool Ledger::initBlockChain()
}
std::shared_ptr<BlockChainImp> blockChain = std::make_shared<BlockChainImp>();
blockChain->setStateStorage(m_dbInitializer->storage());
//blockChain->setTableFactoryFactory(tableFactoryFactory);
// blockChain->setTableFactoryFactory(tableFactoryFactory);
m_blockChain = blockChain;
std::string consensusType = m_param->mutableConsensusParam().consensusType;
std::string storageType = m_param->mutableStorageParam().type;
Expand Down
5 changes: 3 additions & 2 deletions libstorage/LevelDBStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
using namespace dev;
using namespace dev::storage;

Entries::Ptr LevelDBStorage::select(h256, int, const std::string& table, const std::string& key, Condition::Ptr condition)
Entries::Ptr LevelDBStorage::select(
h256, int, const std::string& table, const std::string& key, Condition::Ptr condition)
{
(void)condition;
(void)condition;
try
{
std::string entryKey = table;
Expand Down
4 changes: 2 additions & 2 deletions libstorage/LevelDBStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class LevelDBStorage : public Storage

virtual ~LevelDBStorage(){};

virtual Entries::Ptr select(
h256 hash, int num, const std::string& table, const std::string& key, Condition::Ptr condition = nullptr) override;
virtual Entries::Ptr select(h256 hash, int num, const std::string& table,
const std::string& key, Condition::Ptr condition = nullptr) override;
virtual size_t commit(
h256 hash, int64_t num, const std::vector<TableData::Ptr>& datas, h256 const&) override;
virtual bool onlyDirty() override;
Expand Down
7 changes: 4 additions & 3 deletions libstorage/MemoryTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,10 @@ class MemoryTable : public Table
{
for (auto& it : *(entry->fields()))
{
if(it.first == "_id_") {
continue;
}
if (it.first == "_id_")
{
continue;
}
if (m_tableInfo->fields.end() ==
find(m_tableInfo->fields.begin(), m_tableInfo->fields.end(), it.first))
{
Expand Down
27 changes: 15 additions & 12 deletions libstorage/MemoryTable2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ Entries::Ptr MemoryTable2::selectNoLock(const std::string& key, Condition::Ptr c
{
try
{
auto entries = std::make_shared<Entries>();
condition->EQ(m_tableInfo->key, key);
auto entries = std::make_shared<Entries>();
condition->EQ(m_tableInfo->key, key);
if (m_remoteDB)
{
// query remoteDB anyway
Expand All @@ -78,14 +78,14 @@ Entries::Ptr MemoryTable2::selectNoLock(const std::string& key, Condition::Ptr c
}
}

auto indices = processEntries(m_newEntries, condition);
for (auto it : indices)
{
m_newEntries->get(it)->setTempIndex(it);
entries->addEntry(m_newEntries->get(it));
}
auto indices = processEntries(m_newEntries, condition);
for (auto it : indices)
{
m_newEntries->get(it)->setTempIndex(it);
entries->addEntry(m_newEntries->get(it));
}

return entries;
return entries;
}
catch (std::exception& e)
{
Expand Down Expand Up @@ -140,7 +140,8 @@ int MemoryTable2::update(
}
catch (std::exception& e)
{
STORAGE_LOG(ERROR) << LOG_BADGE("MemoryTable2") << LOG_DESC("Access MemoryTable2 failed for")
STORAGE_LOG(ERROR) << LOG_BADGE("MemoryTable2")
<< LOG_DESC("Access MemoryTable2 failed for")
<< LOG_KV("msg", boost::diagnostic_information(e));
}

Expand Down Expand Up @@ -175,7 +176,8 @@ int MemoryTable2::insert(
}
catch (std::exception& e)
{
STORAGE_LOG(ERROR) << LOG_BADGE("MemoryTable2") << LOG_DESC("Access MemoryTable2 failed for")
STORAGE_LOG(ERROR) << LOG_BADGE("MemoryTable2")
<< LOG_DESC("Access MemoryTable2 failed for")
<< LOG_KV("msg", boost::diagnostic_information(e));
}

Expand Down Expand Up @@ -219,7 +221,8 @@ int MemoryTable2::remove(
}
catch (std::exception& e)
{
STORAGE_LOG(ERROR) << LOG_BADGE("MemoryTable2") << LOG_DESC("Access MemoryTable2 failed for")
STORAGE_LOG(ERROR) << LOG_BADGE("MemoryTable2")
<< LOG_DESC("Access MemoryTable2 failed for")
<< LOG_KV("msg", boost::diagnostic_information(e));
}

Expand Down
2 changes: 1 addition & 1 deletion libstorage/MemoryTableFactory2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include "MemoryTableFactory2.h"
#include "Common.h"
#include "MemoryTable2.h"
#include "TablePrecompiled.h"
#include "StorageException.h"
#include "TablePrecompiled.h"
#include <libblockverifier/ExecutiveContext.h>
#include <libdevcore/Common.h>
#include <libdevcore/FixedHash.h>
Expand Down
40 changes: 20 additions & 20 deletions libstorage/MemoryTableFactoryFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,34 @@

#pragma once

#include "Table.h"
#include "Storage.h"
#include "MemoryTableFactory.h"
#include "Storage.h"
#include "Table.h"
#include <libdevcore/FixedHash.h>

namespace dev {

namespace storage {

class MemoryTableFactoryFactory: public TableFactoryFactory {
namespace dev
{
namespace storage
{
class MemoryTableFactoryFactory : public TableFactoryFactory
{
public:
virtual TableFactory::Ptr newTableFactory(dev::h256 hash, int64_t number) override {
MemoryTableFactory::Ptr tableFactory = std::make_shared<MemoryTableFactory>();
tableFactory->setStateStorage(m_stroage);
tableFactory->setBlockHash(hash);
tableFactory->setBlockNum(number);
virtual TableFactory::Ptr newTableFactory(dev::h256 hash, int64_t number) override
{
MemoryTableFactory::Ptr tableFactory = std::make_shared<MemoryTableFactory>();
tableFactory->setStateStorage(m_stroage);
tableFactory->setBlockHash(hash);
tableFactory->setBlockNum(number);

return tableFactory;
}
return tableFactory;
}

void setStorage(dev::storage::Storage::Ptr storage) {
m_stroage = storage;
}
void setStorage(dev::storage::Storage::Ptr storage) { m_stroage = storage; }

private:
dev::storage::Storage::Ptr m_stroage;
dev::storage::Storage::Ptr m_stroage;
};

}
} // namespace storage

}
} // namespace dev
40 changes: 20 additions & 20 deletions libstorage/MemoryTableFactoryFactory2.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,34 @@

#pragma once

#include "Table.h"
#include "Storage.h"
#include "MemoryTableFactory2.h"
#include "Storage.h"
#include "Table.h"
#include <libdevcore/FixedHash.h>

namespace dev {

namespace storage {

class MemoryTableFactoryFactory2: public TableFactoryFactory {
namespace dev
{
namespace storage
{
class MemoryTableFactoryFactory2 : public TableFactoryFactory
{
public:
virtual TableFactory::Ptr newTableFactory(dev::h256 hash, int64_t number) override {
MemoryTableFactory2::Ptr tableFactory = std::make_shared<MemoryTableFactory2>();
tableFactory->setStateStorage(m_stroage);
tableFactory->setBlockHash(hash);
tableFactory->setBlockNum(number);
virtual TableFactory::Ptr newTableFactory(dev::h256 hash, int64_t number) override
{
MemoryTableFactory2::Ptr tableFactory = std::make_shared<MemoryTableFactory2>();
tableFactory->setStateStorage(m_stroage);
tableFactory->setBlockHash(hash);
tableFactory->setBlockNum(number);

return tableFactory;
}
return tableFactory;
}

void setStorage(dev::storage::Storage::Ptr storage) {
m_stroage = storage;
}
void setStorage(dev::storage::Storage::Ptr storage) { m_stroage = storage; }

private:
dev::storage::Storage::Ptr m_stroage;
dev::storage::Storage::Ptr m_stroage;
};

}
} // namespace storage

}
} // namespace dev
22 changes: 11 additions & 11 deletions libstorage/Table.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,10 @@ struct Change
std::string key;
struct Record
{

size_t index;
std::string key;
std::string oldValue;
size_t id;
size_t id;
Record(size_t _index, std::string _key = std::string(),
std::string _oldValue = std::string(), size_t _id = 0)
: index(_index), key(_key), oldValue(_oldValue), id(_id)
Expand All @@ -191,11 +190,11 @@ class TableData
entries = std::make_shared<Entries>();
}

//for memorytable2
// for memorytable2
TableInfo::Ptr info;
Entries::Ptr entries;

//for memorytable
// for memorytable
std::string tableName;
std::map<std::string, Entries::Ptr> data;
};
Expand Down Expand Up @@ -236,7 +235,7 @@ class Table : public std::enable_shared_from_this<Table>
virtual void setBlockHash(h256 blockHash) = 0;
virtual void setBlockNum(int blockNum) = 0;
virtual void setTableInfo(TableInfo::Ptr tableInfo) = 0;
virtual size_t cacheSize() { return 0; }
virtual size_t cacheSize() { return 0; }

static bool processCondition(Entry::Ptr entry, Condition::Ptr condition);

Expand All @@ -261,17 +260,18 @@ class TableFactory : public std::enable_shared_from_this<TableFactory>

virtual h256 hash() = 0;
virtual size_t savepoint() = 0;
virtual void rollback(size_t _savepoint) = 0;
virtual void commitDB(h256 const& _blockHash, int64_t _blockNumber) = 0;
virtual void rollback(size_t _savepoint) = 0;
virtual void commitDB(h256 const& _blockHash, int64_t _blockNumber) = 0;
};

class TableFactoryFactory : public std::enable_shared_from_this<TableFactoryFactory> {
class TableFactoryFactory : public std::enable_shared_from_this<TableFactoryFactory>
{
public:
typedef std::shared_ptr<TableFactoryFactory> Ptr;
typedef std::shared_ptr<TableFactoryFactory> Ptr;

virtual ~TableFactoryFactory() {};
virtual ~TableFactoryFactory(){};

virtual TableFactory::Ptr newTableFactory(dev::h256 hash, int64_t number) = 0;
virtual TableFactory::Ptr newTableFactory(dev::h256 hash, int64_t number) = 0;
};

} // namespace storage
Expand Down
Loading

0 comments on commit 574a8d2

Please sign in to comment.