Loading...
Searching...
No Matches
resdb_poc_config.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
23
24namespace resdb {
25
26// TODO read from a proto json file.
28 public:
29 ResDBPoCConfig(const ResDBConfig& bft_config,
30 const ResConfigData& config_data, const ReplicaInfo& self_info,
31 const KeyInfo& private_key,
32 const CertificateInfo& public_key_cert_info);
33
34 const ResDBConfig* GetBFTConfig() const;
35
36 void SetMaxNonceBit(uint32_t bit);
37 uint32_t GetMaxNonceBit() const;
38
39 void SetDifficulty(uint32_t difficulty);
40 uint32_t GetDifficulty() const;
41
42 // If target value is zero, target value will be 1<<difficulty.
43 void SetTargetValue(uint32_t target_value);
44 uint32_t GetTargetValue() const;
45
46 // BFT cluster.
47 std::vector<ReplicaInfo> GetBFTReplicas();
48 void SetBFTReplicas(const std::vector<ReplicaInfo>& replicas);
49
50 // Batch
51 uint32_t BatchTransactionNum() const;
52 void SetBatchTransactionNum(uint32_t batch_num);
53
54 uint32_t GetWokerNum();
55 void SetWorkerNum(uint32_t worker_num);
56
57 uint32_t GetMiningTime() const { return mining_time_ms_; }
58 void SetMiningTime(uint32_t time_ms) { mining_time_ms_ = time_ms; }
59
60 private:
61 uint32_t difficulty_ = 0;
62 uint32_t max_nonce_bit_ = 0;
63 uint32_t target_value_ = 0;
64 uint32_t batch_num_ = 12000;
65 uint32_t worker_num_ = 16;
66 uint32_t mining_time_ms_ = 60000; // 60s
67 std::vector<ReplicaInfo> bft_replicas_;
68 ResDBConfig bft_config_;
69};
70
71} // namespace resdb
void SetWorkerNum(uint32_t worker_num)
void SetTargetValue(uint32_t target_value)
void SetMiningTime(uint32_t time_ms)
void SetBFTReplicas(const std::vector< ReplicaInfo > &replicas)
void SetBatchTransactionNum(uint32_t batch_num)
uint32_t BatchTransactionNum() const
void SetDifficulty(uint32_t difficulty)
const ResDBConfig * GetBFTConfig() const
uint32_t GetMaxNonceBit() const
uint32_t GetMiningTime() const
void SetMaxNonceBit(uint32_t bit)
uint32_t GetTargetValue() const
uint32_t GetDifficulty() const
std::vector< ReplicaInfo > GetBFTReplicas()