File tree Expand file tree Collapse file tree 4 files changed +40
-0
lines changed Expand file tree Collapse file tree 4 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,18 @@ std::string Blocks::get(const char* blockId) {
1919
2020/* */
2121
22+ std::string Blocks::first () {
23+ return http_->get (paths::Blocks::first (this ->host_ ).c_str ());
24+ }
25+
26+ /* */
27+
28+ std::string Blocks::last () {
29+ return http_->get (paths::Blocks::last (this ->host_ ).c_str ());
30+ }
31+
32+ /* */
33+
2234std::string Blocks::all (const char * const query) {
2335 return http_->get (paths::Blocks::all (this ->host_ , query).c_str ());
2436}
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ class IBlocks : public Base {
2424 public:
2525 virtual ~IBlocks () {}
2626 virtual std::string get (const char * const blockId) = 0;
27+ virtual std::string first () = 0;
28+ virtual std::string last () = 0;
2729 virtual std::string all (const char * const query) = 0;
2830 virtual std::string transactions (const char * const blockId) = 0;
2931 virtual std::string search (const std::map<std::string, std::string>& bodyParameters, const char * const query) = 0;
@@ -39,6 +41,8 @@ class Blocks : public IBlocks {
3941 Blocks (Host& host, IHTTP& http) : IBlocks(host, http) {}
4042
4143 std::string get (const char * const blockId) override ;
44+ std::string first () override ;
45+ std::string last () override ;
4246 std::string all (const char * const query) override ;
4347 std::string transactions (const char * const blockId) override ;
4448 std::string search (const std::map<std::string, std::string>& bodyParameters, const char * const query) override ;
Original file line number Diff line number Diff line change @@ -59,6 +59,28 @@ std::string Blocks::get(Host& newHost, const char* blockId) {
5959
6060// //////////////////////////////////////////////////////////////////////////////
6161
62+ std::string Blocks::first (Host& newHost) {
63+ std::string url;
64+ url.reserve (URL_MAX_LEN);
65+ url += newHost.toString ().c_str ();
66+ url += Blocks::base ();
67+ url += " /first" ;
68+ return url;
69+ }
70+
71+ // //////////////////////////////////////////////////////////////////////////////
72+
73+ std::string Blocks::last (Host& newHost) {
74+ std::string url;
75+ url.reserve (URL_MAX_LEN);
76+ url += newHost.toString ().c_str ();
77+ url += Blocks::base ();
78+ url += " /last" ;
79+ return url;
80+ }
81+
82+ // //////////////////////////////////////////////////////////////////////////////
83+
6284std::string Blocks::all (Host& newHost, const char * const query) {
6385 std::string url;
6486 url.reserve (URL_MAX_LEN);
Original file line number Diff line number Diff line change @@ -38,6 +38,8 @@ struct Blockchain {
3838struct Blocks { // NOLINT
3939 static std::string base ();
4040 static std::string get (Host& newHost, const char * const blockId);
41+ static std::string first (Host& newHost);
42+ static std::string last (Host& newHost);
4143 static std::string all (Host& newHost, const char * const query = DEFAULT_QUERY);
4244 static std::string transactions (Host& newHost, const char * const blockId);
4345 static std::pair<std::string, std::string> search (Host& newHost,
You can’t perform that action at this time.
0 commit comments