Skip to content

Commit

Permalink
Merge pull request #174 from boscore/release/3.0.x
Browse files Browse the repository at this point in the history
Release/3.0.x
  • Loading branch information
Thaipanda authored Jun 15, 2020
2 parents 323586e + b3e2280 commit 02a237a
Show file tree
Hide file tree
Showing 13 changed files with 722 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ set( CXX_STANDARD_REQUIRED ON)

set(VERSION_MAJOR 3)
set(VERSION_MINOR 0)
set(VERSION_PATCH 8)
set(VERSION_PATCH 9)

if(VERSION_SUFFIX)
set(VERSION_FULL "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_SUFFIX}")
Expand Down
5 changes: 2 additions & 3 deletions Docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ cd bos/Docker
docker build . -t boscore/bos -s BOS
```

The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v3.0.8 tag, you could do the following:
The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v3.0.9 tag, you could do the following:

```bash
docker build -t boscore/bos:v3.0.8 --build-arg branch=v3.0.8 .

docker build -t boscore/bos:v3.0.9 --build-arg branch=v3.0.9 .
```

By default, the symbol in eosio.system is set to SYS. You can override this using the symbol argument while building the docker image.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BOSCore - Blockchain financial center building a trusted business ecosystem.

## BOSCore Version: v3.0.8
## BOSCore Version: v3.0.9
### Basic EOSIO Version: v2.0 (support REX & EOSVM, llvm v90)

# Background
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BOSCore - 区块链自由港,构建可信商业生态。

## BOSCore Version: v3.0.8
## BOSCore Version: v3.0.9
### Basic EOSIO Version: v2.0 (support REX & EOSVM, llvm v90)

# 背景
Expand Down
43 changes: 41 additions & 2 deletions plugins/chain_api_plugin/chain_api_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ struct async_result_visitor : public fc::visitor<fc::variant> {
}
};

namespace {
template<typename T>
T parse_params(const std::string& body) {
if (body.empty()) {
EOS_THROW(chain::invalid_http_request, "A Request body is required");
}

try {
try {
return fc::json::from_string(body).as<T>();
} catch (const chain::chain_exception& e) { // EOS_RETHROW_EXCEPTIONS does not re-type these so, re-code it
throw fc::exception(e);
}
} EOS_RETHROW_EXCEPTIONS(chain::invalid_http_request, "Unable to parse valid input from POST body");
}
}

#define CALL(api_name, api_handle, api_namespace, call_name, http_response_code) \
{std::string("/v1/" #api_name "/" #call_name), \
[api_handle](string, string body, url_response_callback cb) mutable { \
Expand All @@ -48,6 +65,19 @@ struct async_result_visitor : public fc::visitor<fc::variant> {
} \
}}

#define CALL_WITH_400(api_name, api_handle, api_namespace, call_name, http_response_code) \
{std::string("/v1/" #api_name "/" #call_name), \
[api_handle](string, string body, url_response_callback cb) mutable { \
api_handle.validate(); \
try { \
auto params = parse_params<api_namespace::call_name ## _params>(body);\
fc::variant result( api_handle.call_name( std::move(params) ) ); \
cb(http_response_code, std::move(result)); \
} catch (...) { \
http_plugin::handle_exception(#api_name, #call_name, body, cb); \
} \
}}

#define CALL_ASYNC(api_name, api_handle, api_namespace, call_name, call_result, http_response_code) \
{std::string("/v1/" #api_name "/" #call_name), \
[api_handle](string, string body, url_response_callback cb) mutable { \
Expand All @@ -73,11 +103,14 @@ struct async_result_visitor : public fc::visitor<fc::variant> {
#define CHAIN_RO_CALL_ASYNC(call_name, call_result, http_response_code) CALL_ASYNC(chain, ro_api, chain_apis::read_only, call_name, call_result, http_response_code)
#define CHAIN_RW_CALL_ASYNC(call_name, call_result, http_response_code) CALL_ASYNC(chain, rw_api, chain_apis::read_write, call_name, call_result, http_response_code)

#define CHAIN_RO_CALL_WITH_400(call_name, http_response_code) CALL_WITH_400(chain, ro_api, chain_apis::read_only, call_name, http_response_code)

void chain_api_plugin::plugin_startup() {
ilog( "starting chain_api_plugin" );
my.reset(new chain_api_plugin_impl(app().get_plugin<chain_plugin>().chain()));
auto ro_api = app().get_plugin<chain_plugin>().get_read_only_api();
auto rw_api = app().get_plugin<chain_plugin>().get_read_write_api();
auto& chain = app().get_plugin<chain_plugin>();
auto ro_api = chain.get_read_only_api();
auto rw_api = chain.get_read_write_api();

auto& _http_plugin = app().get_plugin<http_plugin>();
ro_api.set_shorten_abi_errors( !_http_plugin.verbose_errors() );
Expand Down Expand Up @@ -107,6 +140,12 @@ void chain_api_plugin::plugin_startup() {
CHAIN_RW_CALL_ASYNC(push_transaction, chain_apis::read_write::push_transaction_results, 202),
CHAIN_RW_CALL_ASYNC(push_transactions, chain_apis::read_write::push_transactions_results, 202)
});

if (chain.account_queries_enabled()) {
_http_plugin.add_async_api({
CHAIN_RO_CALL_WITH_400(get_accounts_by_authorizers, 200),
});
}
}

void chain_api_plugin::plugin_shutdown() {}
Expand Down
1 change: 1 addition & 0 deletions plugins/chain_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
file(GLOB HEADERS "include/eosio/chain_plugin/*.hpp")
add_library( chain_plugin
account_query_db.cpp
chain_plugin.cpp
${HEADERS} )

Expand Down
Loading

0 comments on commit 02a237a

Please sign in to comment.