generated from Warchant/cmake-hunter-seed
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathselector.hpp
46 lines (37 loc) · 1.28 KB
/
selector.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "common/outcome.hpp"
#include "primitives/resources/active_resources.hpp"
#include "primitives/seal_tasks/task.hpp"
#include "primitives/sector/sector.hpp"
#include "sector_storage/worker.hpp"
namespace fc::sector_storage {
using primitives::ActiveResources;
using primitives::TaskType;
using primitives::sector::RegisteredSealProof;
struct WorkerHandle {
std::shared_ptr<Worker> worker;
primitives::WorkerInfo info;
ActiveResources preparing;
ActiveResources active;
};
inline bool operator==(const WorkerHandle &lhs, const WorkerHandle &rhs) {
return lhs.info.hostname == rhs.info.hostname
&& lhs.info.resources == rhs.info.resources;
}
class WorkerSelector {
public:
virtual ~WorkerSelector() = default;
virtual outcome::result<bool> is_satisfying(
const TaskType &task,
RegisteredSealProof seal_proof_type,
const std::shared_ptr<WorkerHandle> &worker) = 0;
virtual outcome::result<bool> is_preferred(
const TaskType &task,
const std::shared_ptr<WorkerHandle> &challenger,
const std::shared_ptr<WorkerHandle> ¤t_best) = 0;
};
} // namespace fc::sector_storage