Compare commits

...

6 commits

Author SHA1 Message Date
Srdjan Obucina
96aecc4870 Merge branch 'develop' into feature/GRPH-45 2020-05-12 18:21:41 +02:00
Srdjan Obucina
640bda75ee Cosmetic changes for cleaner diff 2019-09-04 15:11:43 +02:00
Srdjan Obucina
0524c0c216 Fix build error after merging with develop branch 2019-09-03 14:01:31 +02:00
Srdjan Obucina
6743860f42 Merge branch 'develop' into rng_api 2019-09-03 13:57:56 +02:00
Srdjan Obucina
fa5d3eccdf Merge branch 'qa_gpos_18.04_gcc7_fix' into rng_api 2019-08-22 17:08:00 +02:00
Srdjan Obucina
654e998d89 API endpoint for reading random numbers from the witness
Test cmd:
curl --data '{"method": "call", "params": ["database", "get_random_number", [1000]], "jsonrpc": "2.0", "id": 1}' http://127.0.0.1:8090/ws
curl --data '{"method": "call", "params": ["database", "get_random_number", [5000]], "jsonrpc": "2.0", "id": 1}' http://127.0.0.1:8090/ws
curl --data '{"method": "call", "params": ["database", "get_random_number", [1000000]], "jsonrpc": "2.0", "id": 1}' http://127.0.0.1:8090/ws
2019-08-19 19:55:26 +02:00
2 changed files with 32 additions and 2 deletions

View file

@ -184,6 +184,9 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
// gpos
gpos_info get_gpos_info(const account_id_type account) const;
// rng
int64_t get_random_number(uint64_t bound) const;
//private:
const account_object* get_account_from_string( const std::string& name_or_id,
bool throw_if_not_found = true ) const;
@ -2303,6 +2306,22 @@ graphene::app::gpos_info database_api_impl::get_gpos_info(const account_id_type
return result;
}
//////////////////////////////////////////////////////////////////////
// //
// Random numbers //
// //
//////////////////////////////////////////////////////////////////////
int64_t database_api::get_random_number(uint64_t bound) const
{
return my->get_random_number(bound);
}
int64_t database_api_impl::get_random_number(uint64_t bound) const {
int64_t result = _db.get_random_bits(bound);
return result;
}
//////////////////////////////////////////////////////////////////////
// //
// Private methods //

View file

@ -709,9 +709,17 @@ class database_api
*/
gpos_info get_gpos_info(const account_id_type account) const;
/////////////////////////////
// Random number generator //
/////////////////////////////
/**
* @brief Returns the random number
* @param bound Upper bound of segment containing random number
* @return Random number from segment [0, bound)
*/
int64_t get_random_number(uint64_t bound) const;
private:
private:
std::shared_ptr< database_api_impl > my;
};
@ -848,4 +856,7 @@ FC_API(graphene::app::database_api,
// gpos
(get_gpos_info)
// rngs
(get_random_number)
)