Loading...
Searching...
No Matches
contract_service.cpp
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#include <glog/logging.h>
21
27
31using resdb::ResConfigData;
33using resdb::Stats;
35
36void ShowUsage() {
37 printf(
38 "<config> <private_key> <cert_file> <durability_option> [logging_dir]\n");
39}
40
41int main(int argc, char** argv) {
42 if (argc < 4) {
43 ShowUsage();
44 exit(0);
45 }
46
47 char* config_file = argv[1];
48 char* private_key_file = argv[2];
49 char* cert_file = argv[3];
50 char* logging_dir = nullptr;
51
52 if (argc >= 7) {
53 logging_dir = argv[5];
54 }
55
56 if (argc >= 6) {
57 auto monitor_port = Stats::GetGlobalStats(5);
58 monitor_port->SetPrometheus(argv[4]);
59 }
60
61 std::unique_ptr<ResDBConfig> config =
62 GenerateResDBConfig(config_file, private_key_file, cert_file);
63 ResConfigData config_data = config->GetConfigData();
64
65 auto server = CustomGenerateResDBServer<ConsensusManagerPBFT>(
66 config_file, private_key_file, cert_file,
67 std::make_unique<ContractTransactionManager>(), logging_dir);
68
69 server->Run();
70}
static Stats * GetGlobalStats(int sleep_seconds=5)
Definition stats.cpp:29
int main(int argc, char **argv)
void ShowUsage()
std::unique_ptr< ServiceNetwork > CustomGenerateResDBServer(char *config_file, char *private_key_file, char *cert_file, std::unique_ptr< TransactionManager > executor, char *logging_dir=nullptr, std::function< void(ResDBConfig *config)> config_handler=nullptr)
std::unique_ptr< ResDBConfig > GenerateResDBConfig(const std::string &config_file, const std::string &private_key_file, const std::string &cert_file, std::optional< ReplicaInfo > self_info, std::optional< ConfigGenFunc > gen_func)