Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion console/embedded/explore_css.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@
namespace libbitcoin {
namespace server {

DEFINE_EMBEDDED_PAGE(explore_pages, char, css, "")
// Simple test css for embedded page, links in font.
DEFINE_EMBEDDED_PAGE(explore_pages, char, css,
R"(@font-face
{
font-family: 'Boston';
src: url('boston.woff2');
})")

} // namespace server
} // namespace libbitcoin
7 changes: 6 additions & 1 deletion console/embedded/explore_ecma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
namespace libbitcoin {
namespace server {

DEFINE_EMBEDDED_PAGE(explore_pages, char, ecma, "")
// Simple test ecma script for embedded page.
DEFINE_EMBEDDED_PAGE(explore_pages, char, ecma,
R"(document.addEventListener('DOMContentLoaded', function()
{
console.log('pong');
});)")

} // namespace server
} // namespace libbitcoin
12 changes: 11 additions & 1 deletion console/embedded/explore_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@
namespace libbitcoin {
namespace server {

DEFINE_EMBEDDED_PAGE(explore_pages, char, font, "")
DEFINE_EMBEDDED_PAGE(explore_pages, uint8_t, font,
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
})

} // namespace server
} // namespace libbitcoin
18 changes: 16 additions & 2 deletions console/embedded/explore_html.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,22 @@
namespace libbitcoin {
namespace server {

// Empty page disabled embedded size.
DEFINE_EMBEDDED_PAGE(explore_pages, char, html, "")
// Simple test html for embedded page, links in css and page icon.
DEFINE_EMBEDDED_PAGE(explore_pages, char, html,
R"(<html>
<head>
<title>Libbitcoin Block Explorer</title>
<meta charset="utf-8">
<meta name="description" content="libbitcoin block explorer site">
<link rel="stylesheet" href="style.css"/>
<link rel="icon" href="icon.png" type="image/png"/>
<link rel="preload" href="boston.woff2" type="font/woff2" as="font">
<script src="script.js" defer></script>
</head>
<body>
<p>Hello world!</p>
</body>
</html>)")

} // namespace server
} // namespace libbitcoin
12 changes: 11 additions & 1 deletion console/embedded/explore_icon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@
namespace libbitcoin {
namespace server {

DEFINE_EMBEDDED_PAGE(explore_pages, char, icon, "")
DEFINE_EMBEDDED_PAGE(explore_pages, uint8_t, icon,
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
})

} // namespace server
} // namespace libbitcoin
11 changes: 5 additions & 6 deletions console/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ int bc::system::main(int argc, char* argv[])
std::ios_base::sync_with_stdio(false);
set_utf8_stdio();

// HACK: web_server used for both!
const server::web_pages web_server{};
const server::explore_pages block_explorer{};
parser metadata(chain::selection::mainnet, web_server, web_server);
parser metadata(chain::selection::mainnet, block_explorer, web_server);

const auto& args = const_cast<const char**>(argv);

Expand All @@ -100,11 +99,11 @@ int bc::system::main(int argc, char* argv[])
symbols_path = metadata.configured.log.symbols;
#endif

// requires _WIN32_WINNT set to 0x0602 (defaults 0x0602 in vc++ 2022).
#if defined(HAVE_MSC) && defined(MEMORY_PRIORITY_INFORMATION)
// Requires _WIN32_WINNT set to 0x0602 (defaults 0x0602 in vc++ 2022).
#if defined(HAVE_MSC) && (_WIN32_WINNT >= _WIN32_WINNT_WIN8)

// Set low memory priority on the current process.
const MEMORY_PRIORITY_INFORMATION priority{ MEMORY_PRIORITY_LOW };
// Set low memory priority on the current process (testing).
MEMORY_PRIORITY_INFORMATION priority{ MEMORY_PRIORITY_LOW };
SetProcessInformation(
GetCurrentProcess(),
ProcessMemoryPriority,
Expand Down
4 changes: 4 additions & 0 deletions include/bitcoin/node/protocols/protocol_explore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class BCN_API protocol_explore
/// Receivers.
void handle_receive_get(const code& ec,
const network::http::method::get& request) NOEXCEPT override;

/// Dispatch.
virtual bool dispatch_object(
const network::http::request& request) NOEXCEPT;
};

} // namespace node
Expand Down
6 changes: 6 additions & 0 deletions include/bitcoin/node/protocols/protocol_html.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class BCN_API protocol_html
void handle_receive_get(const code& ec,
const network::http::method::get& request) NOEXCEPT override;

/// Dispatch.
virtual bool dispatch_embedded(
const network::http::request& request) NOEXCEPT;

/// Senders.
virtual void send_json(const network::http::request& request,
boost::json::value&& model, size_t size_hint) NOEXCEPT;
Expand All @@ -67,6 +71,8 @@ class BCN_API protocol_html
/// Utilities.
bool is_allowed_origin(const network::http::fields& fields,
size_t version) const NOEXCEPT;
std::filesystem::path to_path(
const std::string& target = "/") const NOEXCEPT;
std::filesystem::path to_local_path(
const std::string& target = "/") const NOEXCEPT;

Expand Down
Loading
Loading