Skip to content

Commit

Permalink
Merge branch 'dev_node_ex' of https://github.com/GeniusVentures/Super…
Browse files Browse the repository at this point in the history
…Genius into dev_node_ex
  • Loading branch information
itsafuu committed May 24, 2024
2 parents c2f5d2d + 0311d2b commit e44631c
Show file tree
Hide file tree
Showing 18 changed files with 256 additions and 521 deletions.
2 changes: 0 additions & 2 deletions example/processing_dapp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
add_executable(processing_dapp
processing_dapp.cpp
processing_task_queue_impl.hpp
)


Expand All @@ -15,7 +14,6 @@ add_executable(processing_dapp_processor
processing_dapp_processor.cpp
processing_subtask_result_storage.cpp
processing_subtask_result_storage_impl.hpp
processing_task_queue_impl.hpp
)


Expand Down
2 changes: 1 addition & 1 deletion example/processing_dapp/processing_dapp.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "processing_task_queue_impl.hpp"
#include "processing/impl/processing_task_queue_impl.hpp"

#include <crdt/globaldb/globaldb.hpp>
#include <crdt/globaldb/keypair_file_storage.hpp>
Expand Down
20 changes: 9 additions & 11 deletions example/processing_dapp/processing_dapp_processor.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
#include "processing_task_queue_impl.hpp"
#include "processing_subtask_result_storage_impl.hpp"

#include <processing/processing_service.hpp>
#include <processing/processing_subtask_enqueuer_impl.hpp>

#include <crdt/globaldb/keypair_file_storage.hpp>
#include <crdt/globaldb/globaldb.hpp>

#include <iostream>
#include <boost/program_options.hpp>
#include <libp2p/multi/multibase_codec/multibase_codec_impl.hpp>
#include <libp2p/log/configurator.hpp>
#include <libp2p/log/logger.hpp>
#include "processing/impl/processing_task_queue_impl.hpp"
#include "processing_subtask_result_storage_impl.hpp"
#include "processing/processing_service.hpp"
#include "processing/processing_subtask_enqueuer_impl.hpp"
#include "crdt/globaldb/keypair_file_storage.hpp"
#include "crdt/globaldb/globaldb.hpp"


#include <boost/program_options.hpp>

#include <iostream>

using namespace sgns::processing;

Expand Down
7 changes: 4 additions & 3 deletions example/processing_dapp/processing_subtask_result_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ void SubTaskResultStorageImpl::RemoveSubTaskResult(const std::string& subTaskId)
sgns::crdt::HierarchicalKey((boost::format("results/%s") % subTaskId).str().c_str()));
}

void SubTaskResultStorageImpl::GetSubTaskResults(
const std::set<std::string>& subTaskIds,
std::vector<SGProcessing::SubTaskResult>& results)
std::vector<SGProcessing::SubTaskResult> SubTaskResultStorageImpl::GetSubTaskResults(
const std::set<std::string>& subTaskIds)
{
std::vector<SGProcessing::SubTaskResult> results;
for (const auto& subTaskId : subTaskIds)
{
auto data = m_db->Get(sgns::crdt::HierarchicalKey((boost::format("results/%s") % subTaskId).str().c_str()));
Expand All @@ -41,6 +41,7 @@ void SubTaskResultStorageImpl::GetSubTaskResults(
}
}
}
return results;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ namespace sgns::processing
*/
void AddSubTaskResult(const SGProcessing::SubTaskResult& result) override;
void RemoveSubTaskResult(const std::string& subTaskId) override;
void GetSubTaskResults(
const std::set<std::string>& subTaskIds,
std::vector<SGProcessing::SubTaskResult>& results) override;
std::vector<SGProcessing::SubTaskResult> GetSubTaskResults(
const std::set<std::string>& subTaskIds) override;

private:
std::shared_ptr<sgns::crdt::GlobalDB> m_db;
Expand Down
256 changes: 0 additions & 256 deletions example/processing_dapp/processing_task_queue_impl.hpp

This file was deleted.

15 changes: 7 additions & 8 deletions example/processing_room/processing_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ namespace
public:
void AddSubTaskResult(const SGProcessing::SubTaskResult& subTaskResult) override {}
void RemoveSubTaskResult(const std::string& subTaskId) override {}
void GetSubTaskResults(
const std::set<std::string>& subTaskIds,
std::vector<SGProcessing::SubTaskResult>& results) override {}
std::vector<SGProcessing::SubTaskResult> GetSubTaskResults(
const std::set<std::string>& subTaskIds) override { return {};}
};

class TaskSplitter
Expand Down Expand Up @@ -121,19 +120,19 @@ namespace
return false;
}

bool GrabTask(std::string& taskKey, SGProcessing::Task& task) override
outcome::result<std::pair<std::string, SGProcessing::Task>> GrabTask() override
{
if (m_tasks.empty())
{
return false;
return outcome::failure(boost::system::error_code{});
}


SGProcessing::Task task;
task = std::move(m_tasks.back());
m_tasks.pop_back();
taskKey = (boost::format("TASK_%d") % m_tasks.size()).str();
std::string taskKey = (boost::format("TASK_%d") % m_tasks.size()).str();

return true;
return std::make_pair(taskKey, task);
};

bool CompleteTask(const std::string& taskKey, const SGProcessing::TaskResult& task) override
Expand Down
Loading

0 comments on commit e44631c

Please sign in to comment.