Skip to content

Commit

Permalink
Merge branch 'mira' into mira-options
Browse files Browse the repository at this point in the history
  • Loading branch information
sgerbino authored Mar 26, 2019
2 parents e705514 + cda8b6f commit 2b816c8
Show file tree
Hide file tree
Showing 30 changed files with 725 additions and 343 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ If there is an existing feature that is not working correctly, or a glitch in th

## Enhancement Suggestions

Do **not** use the issue tracker to suggest enhancements or improvements to the platform. The best place for these discussions is on Steemit.com. If there is a well vetted idea that has the support of the community that you feel should be considered by the development team, please email it to [sneak@steemit.com](mailto:sneak@steemit.com) for review.
Do **not** use the issue tracker to suggest enhancements or improvements to the platform. The best place for these discussions is on Steemit.com. If there is a well vetted idea that has the support of the community that you feel should be considered by the development team, please email it to [suggestions@steemit.com](mailto:suggestions@steemit.com) for review.

## Implementation Discussion

Expand Down
11 changes: 7 additions & 4 deletions doc/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,15 @@ Install Homebrew by following the instructions here: http://brew.sh/
openssl \
snappy \
zlib \
bzip2 \
python3
pip3 install --user jinja2

Note: brew recently updated to boost 1.61.0, which is not yet supported by
steem. Until then, this will allow you to install boost 1.60.0.
You may also need to install zlib and bzip2 libraries manually.
In that case, change the directories for `export` accordingly.

*Optional.* To use TCMalloc in LevelDB:

Expand All @@ -208,11 +211,11 @@ steem. Until then, this will allow you to install boost 1.60.0.

### Compile

export OPENSSL_ROOT_DIR=$(brew --prefix)/Cellar/openssl/1.0.2h_1/
export BOOST_ROOT=$(brew --prefix)/Cellar/[email protected]/1.60.0/
export SNAPPY_LIBRARIES=$(brew --prefix)/Cellar/snappy/1.1.7_1/lib/
export SNAPPY_INCLUDE_DIR=$(brew --prefix)/Cellar/snappy/1.1.7_1/include/
export ZLIB_LIBRARIES=$(brew --prefix)/Cellar/zlib/1.2.11/lib/
export OPENSSL_ROOT_DIR=$(brew --prefix)/Cellar/openssl/1.0.2q/
export SNAPPY_ROOT_DIR=$(brew --prefix)/Cellar/snappy/1.1.7_1
export ZLIB_ROOT_DIR=$(brew --prefix)/Cellar/zlib/1.2.11
export BZIP2_ROOT_DIR=$(brew --prefix)/Cellar/bzip2/1.0.6_1
git checkout stable
git submodule update --init --recursive
mkdir build && cd build
Expand Down
10 changes: 6 additions & 4 deletions libraries/chain/include/steem/chain/steem_fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,24 @@ namespace raw {
template<typename Stream, typename T>
inline void pack( Stream& s, const chainbase::oid<T>& id );
template<typename Stream, typename T>
inline void unpack( Stream& s, chainbase::oid<T>& id );
inline void unpack( Stream& s, chainbase::oid<T>& id, uint32_t depth = 0 );

#ifndef ENABLE_STD_ALLOCATOR
template<typename Stream>
inline void pack( Stream& s, const chainbase::shared_string& ss );
template<typename Stream>
inline void unpack( Stream& s, chainbase::shared_string& ss );
inline void unpack( Stream& s, chainbase::shared_string& ss, uint32_t depth = 0 );
#endif

template<typename Stream, typename E, typename A>
void pack( Stream& s, const boost::interprocess::deque< E, A >& value );
template<typename Stream, typename E, typename A>
void unpack( Stream& s, boost::interprocess::deque< E, A >& value );
void unpack( Stream& s, boost::interprocess::deque< E, A >& value, uint32_t depth = 0 );

template<typename Stream, typename K, typename V, typename C, typename A>
void pack( Stream& s, const boost::interprocess::flat_map< K, V, C, A >& value );
template<typename Stream, typename K, typename V, typename C, typename A>
void unpack( Stream& s, boost::interprocess::flat_map< K, V, C, A >& value );
void unpack( Stream& s, boost::interprocess::flat_map< K, V, C, A >& value, uint32_t depth = 0 );

/*
inline void pack_to_slice
Expand Down
23 changes: 14 additions & 9 deletions libraries/chain/include/steem/chain/steem_object_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ void pack( Stream& s, const chainbase::oid<T>& id )
}

template<typename Stream, typename T>
void unpack( Stream& s, chainbase::oid<T>& id )
void unpack( Stream& s, chainbase::oid<T>& id, uint32_t )
{
s.read( (char*)&id._id, sizeof(id._id));
}
Expand All @@ -264,10 +264,11 @@ void pack( Stream& s, const chainbase::shared_string& ss )
}

template< typename Stream >
void unpack( Stream& s, chainbase::shared_string& ss )
void unpack( Stream& s, chainbase::shared_string& ss, uint32_t depth )
{
depth++;
std::string str;
fc::raw::unpack( s, str );
fc::raw::unpack( s, str, depth );
steem::chain::from_string( ss, str );
}
#endif
Expand All @@ -282,11 +283,14 @@ void pack( Stream& s, const boost::interprocess::deque<E, A>& dq )
}

template< typename Stream, typename E, typename A >
void unpack( Stream& s, boost::interprocess::deque<E, A>& dq )
void unpack( Stream& s, boost::interprocess::deque<E, A>& dq, uint32_t depth )
{
depth++;
FC_ASSERT( depth <= MAX_RECURSION_DEPTH );
// This could be optimized
std::vector<E> temp;
unpack( s, temp );
unpack( s, temp, depth );
dq.clear();
std::copy( temp.begin(), temp.end(), std::back_inserter(dq) );
}

Expand All @@ -304,17 +308,18 @@ void pack( Stream& s, const boost::interprocess::flat_map< K, V, C, A >& value )
}

template< typename Stream, typename K, typename V, typename C, typename A >
void unpack( Stream& s, boost::interprocess::flat_map< K, V, C, A >& value )
void unpack( Stream& s, boost::interprocess::flat_map< K, V, C, A >& value, uint32_t depth )
{
depth++;
FC_ASSERT( depth <= MAX_RECURSION_DEPTH );
unsigned_int size;
unpack( s, size );
unpack( s, size, depth );
value.clear();
FC_ASSERT( size.value*(sizeof(K)+sizeof(V)) < MAX_ARRAY_ALLOC_SIZE );
value.reserve(size.value);
for( uint32_t i = 0; i < size.value; ++i )
{
std::pair<K,V> tmp;
fc::raw::unpack( s, tmp );
fc::raw::unpack( s, tmp, depth );
value.insert( std::move(tmp) );
}
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/fc/include/fc/container/deque_fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ namespace fc {
template<typename Stream, typename T>
void pack( Stream& s, const std::deque<T>& value );
template<typename Stream, typename T>
void unpack( Stream& s, std::deque<T>& value );
void unpack( Stream& s, std::deque<T>& value, uint32_t depth = 0 );
}
} // namespace fc
34 changes: 21 additions & 13 deletions libraries/fc/include/fc/container/flat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ namespace fc {
}
}
template<typename Stream, typename T>
inline void unpack( Stream& s, flat_set<T>& value ) {
unsigned_int size; unpack( s, size );
inline void unpack( Stream& s, flat_set<T>& value, uint32_t depth ) {
depth++;
FC_ASSERT( depth <= MAX_RECURSION_DEPTH );
unsigned_int size; unpack( s, size, depth );
value.clear();
FC_ASSERT( size.value*sizeof(T) < MAX_ARRAY_ALLOC_SIZE );
value.reserve(size.value);
for( uint32_t i = 0; i < size.value; ++i )
{
T tmp;
fc::raw::unpack( s, tmp );
fc::raw::unpack( s, tmp, depth );
value.insert( std::move(tmp) );
}
}
Expand All @@ -41,16 +42,17 @@ namespace fc {
}
}
template<typename Stream, typename K, typename V, typename... A>
inline void unpack( Stream& s, flat_map<K,V,A...>& value )
inline void unpack( Stream& s, flat_map<K,V,A...>& value, uint32_t depth )
{
unsigned_int size; unpack( s, size );
depth++;
FC_ASSERT( depth <= MAX_RECURSION_DEPTH );
unsigned_int size; unpack( s, size, depth );
value.clear();
FC_ASSERT( size.value*(sizeof(K)+sizeof(V)) < MAX_ARRAY_ALLOC_SIZE );
value.reserve(size.value);
for( uint32_t i = 0; i < size.value; ++i )
{
std::pair<K,V> tmp;
fc::raw::unpack( s, tmp );
fc::raw::unpack( s, tmp, depth );
value.insert( std::move(tmp) );
}
}
Expand All @@ -71,13 +73,19 @@ namespace fc {
}

template<typename Stream, typename T, typename A>
void unpack( Stream& s, bip::vector<T,A>& value ) {
void unpack( Stream& s, bip::vector<T,A>& value, uint32_t depth ) {
depth++;
FC_ASSERT( depth <= MAX_RECURSION_DEPTH );
unsigned_int size;
unpack( s, size );
value.resize( size );
unpack( s, size, depth );
value.clear();
if( !std::is_fundamental<T>::value ) {
for( auto& item : value )
unpack( s, item );
for ( size_t i = 0; i < size.value; i++ )
{
T tmp;
unpack( s, tmp, depth );
value.emplace_back( std::move( tmp ) );
}
} else {
s.read( (char*)value.data(), value.size() );
}
Expand Down
10 changes: 7 additions & 3 deletions libraries/fc/include/fc/container/flat_fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@ namespace fc {
template<typename Stream, typename T>
void pack( Stream& s, const flat_set<T>& value );
template<typename Stream, typename T>
void unpack( Stream& s, flat_set<T>& value );
void unpack( Stream& s, flat_set<T>& value, uint32_t depth = 0 );
template<typename Stream, typename K, typename... V>
void pack( Stream& s, const flat_map<K,V...>& value );
template<typename Stream, typename K, typename... V>
void unpack( Stream& s, flat_map<K,V...>& value ) ;
void unpack( Stream& s, flat_map<K,V...>& value, uint32_t depth = 0 ) ;
template<typename Stream, typename K, typename... V>
void pack( Stream& s, const flat_map<K,V...>& value );
template<typename Stream, typename K, typename V, typename... A>
void unpack( Stream& s, flat_map<K,V,A...>& value, uint32_t depth = 0 );


template<typename Stream, typename T, typename A>
void pack( Stream& s, const bip::vector<T,A>& value );
template<typename Stream, typename T, typename A>
void unpack( Stream& s, bip::vector<T,A>& value );
void unpack( Stream& s, bip::vector<T,A>& value, uint32_t depth = 0 );
} // namespace raw

} // fc
5 changes: 3 additions & 2 deletions libraries/fc/include/fc/fixed_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ namespace fc {
}

template<typename Stream, typename Storage>
inline void unpack( Stream& s, fc::fixed_string<Storage>& u ) {
inline void unpack( Stream& s, fc::fixed_string<Storage>& u, uint32_t depth ) {
depth++;
unsigned_int size;
fc::raw::unpack( s, size );
fc::raw::unpack( s, size, depth );
if( size.value > 0 ) {
if( size.value > sizeof(Storage) ) {
s.read( (char*)&u.data, sizeof(Storage) );
Expand Down
16 changes: 11 additions & 5 deletions libraries/fc/include/fc/interprocess/container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,18 @@ namespace fc {
}
}
template<typename Stream, typename T, typename... A>
inline void unpack( Stream& s, bip::vector<T,A...>& value ) {
inline void unpack( Stream& s, bip::vector<T,A...>& value, uint32_t depth = 0 ) {
depth++;
FC_ASSERT( depth <= MAX_RECURSION_DEPTH );
unsigned_int size;
unpack( s, size );
value.clear(); value.resize(size);
for( auto& item : value )
fc::raw::unpack( s, item );
unpack( s, size, depth );
value.clear();
for ( size_t i = 0; i < size.value; i++ )
{
T tmp;
fc::raw::unpack( s, tmp, depth );
value.emplace_back( std::move( tmp ) );
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions libraries/fc/include/fc/io/enum_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ namespace fc
}

template<typename Stream, typename IntType, typename EnumType>
inline void unpack( Stream& s, fc::enum_type<IntType,EnumType>& tp )
inline void unpack( Stream& s, fc::enum_type<IntType,EnumType>& tp, uint32_t depth )
{
depth++;
FC_ASSERT( depth <= MAX_RECURSION_DEPTH );
IntType t;
fc::raw::unpack( s, t );
fc::raw::unpack( s, t, depth );
tp = t;
}
}
Expand Down
25 changes: 14 additions & 11 deletions libraries/fc/include/fc/io/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include <fc/variant.hpp>
#include <fc/filesystem.hpp>

#define JSON_MAX_RECURSION_DEPTH (200)

namespace fc
{
class ostream;
Expand All @@ -28,19 +30,19 @@ namespace fc
legacy_generator = 1
};

static ostream& to_stream( ostream& out, const fc::string&);
static ostream& to_stream( ostream& out, const fc::string& );
static ostream& to_stream( ostream& out, const variant& v, output_formatting format = stringify_large_ints_and_doubles );
static ostream& to_stream( ostream& out, const variants& v, output_formatting format = stringify_large_ints_and_doubles );
static ostream& to_stream( ostream& out, const variant_object& v, output_formatting format = stringify_large_ints_and_doubles );

static variant from_stream( buffered_istream& in, parse_type ptype = legacy_parser );
static variant from_stream( buffered_istream& in, parse_type ptype = legacy_parser, uint32_t depth = 0 );

static variant from_string( const string& utf8_str, parse_type ptype = legacy_parser );
static variants variants_from_string( const string& utf8_str, parse_type ptype = legacy_parser );
static variant from_string( const string& utf8_str, parse_type ptype = legacy_parser, uint32_t depth = 0 );
static variants variants_from_string( const string& utf8_str, parse_type ptype = legacy_parser, uint32_t depth = 0 );
static string to_string( const variant& v, output_formatting format = stringify_large_ints_and_doubles );
static string to_pretty_string( const variant& v, output_formatting format = stringify_large_ints_and_doubles );

static bool is_valid( const std::string& json_str, parse_type ptype = legacy_parser );
static bool is_valid( const std::string& json_str, parse_type ptype = legacy_parser, uint32_t depth = 0 );

template<typename T>
static void save_to_file( const T& v, const fc::path& fi, bool pretty = true, output_formatting format = stringify_large_ints_and_doubles )
Expand All @@ -49,28 +51,29 @@ namespace fc
}

static void save_to_file( const variant& v, const fc::path& fi, bool pretty = true, output_formatting format = stringify_large_ints_and_doubles );
static variant from_file( const fc::path& p, parse_type ptype = legacy_parser );
static variant from_file( const fc::path& p, parse_type ptype = legacy_parser, uint32_t depth = 0 );

template<typename T>
static T from_file( const fc::path& p, parse_type ptype = legacy_parser )
static T from_file( const fc::path& p, parse_type ptype = legacy_parser, uint32_t depth = 0 )
{
return json::from_file(p, ptype).as<T>();
depth++;
return json::from_file( p, ptype, depth ).as<T>();
}

template<typename T>
static string to_string( const T& v, output_formatting format = stringify_large_ints_and_doubles )
static string to_string( const T& v, output_formatting format = stringify_large_ints_and_doubles )
{
return to_string( variant(v), format );
}

template<typename T>
static string to_pretty_string( const T& v, output_formatting format = stringify_large_ints_and_doubles )
static string to_pretty_string( const T& v, output_formatting format = stringify_large_ints_and_doubles )
{
return to_pretty_string( variant(v), format );
}

template<typename T>
static void save_to_file( const T& v, const std::string& p, bool pretty = true, output_formatting format = stringify_large_ints_and_doubles )
static void save_to_file( const T& v, const std::string& p, bool pretty = true, output_formatting format = stringify_large_ints_and_doubles )
{
save_to_file( variant(v), fc::path(p), pretty );
}
Expand Down
Loading

0 comments on commit 2b816c8

Please sign in to comment.