-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathApplication.cpp
More file actions
48 lines (43 loc) · 1.61 KB
/
Application.cpp
File metadata and controls
48 lines (43 loc) · 1.61 KB
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
47
48
// Copyright 2014 Stellar Development Foundation and contributors. Licensed
// under the Apache License, Version 2.0. See the COPYING file at the root
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
#include "Application.h"
#include "ApplicationImpl.h"
#include "database/Database.h"
#include "util/GlobalChecks.h"
#include <fmt/format.h>
namespace stellar
{
using namespace std;
void
validateNetworkPassphrase(Application::pointer app)
{
std::string networkPassphrase = app->getConfig().NETWORK_PASSPHRASE;
if (networkPassphrase.empty())
{
throw std::invalid_argument("NETWORK_PASSPHRASE not configured");
}
auto& persistentState = app->getPersistentState();
std::string prevNetworkPassphrase = persistentState.getState(
PersistentState::kNetworkPassphrase, app->getDatabase().getSession());
if (prevNetworkPassphrase.empty())
{
persistentState.setMainState(PersistentState::kNetworkPassphrase,
networkPassphrase,
app->getDatabase().getSession());
}
else if (networkPassphrase != prevNetworkPassphrase)
{
throw std::invalid_argument(
fmt::format(FMT_STRING("NETWORK_PASSPHRASE \"{}\" does not match"
" previous NETWORK_PASSPHRASE \"{}\""),
networkPassphrase, prevNetworkPassphrase));
}
}
Application::pointer
Application::create(VirtualClock& clock, Config const& cfg, bool newDB,
bool forceRebuild)
{
return create<ApplicationImpl>(clock, cfg, newDB, forceRebuild);
}
}