mirror of
https://github.com/monero-project/monero.git
synced 2025-06-25 02:00:28 -04:00
tx_pool: avoid parsing a whole tx if only the prefix is needed
This commit is contained in:
parent
bb30a72367
commit
6844ae1b8d
5 changed files with 60 additions and 38 deletions
|
@ -318,7 +318,7 @@ namespace serialization {
|
|||
* \brief self explanatory
|
||||
*/
|
||||
template<class Stream>
|
||||
bool do_check_stream_state(Stream& s, boost::mpl::bool_<true>)
|
||||
bool do_check_stream_state(Stream& s, boost::mpl::bool_<true>, bool noeof)
|
||||
{
|
||||
return s.good();
|
||||
}
|
||||
|
@ -329,13 +329,13 @@ namespace serialization {
|
|||
* \detailed Also checks to make sure that the stream is not at EOF
|
||||
*/
|
||||
template<class Stream>
|
||||
bool do_check_stream_state(Stream& s, boost::mpl::bool_<false>)
|
||||
bool do_check_stream_state(Stream& s, boost::mpl::bool_<false>, bool noeof)
|
||||
{
|
||||
bool result = false;
|
||||
if (s.good())
|
||||
{
|
||||
std::ios_base::iostate state = s.rdstate();
|
||||
result = EOF == s.peek();
|
||||
result = noeof || EOF == s.peek();
|
||||
s.clear(state);
|
||||
}
|
||||
return result;
|
||||
|
@ -347,9 +347,9 @@ namespace serialization {
|
|||
* \brief calls detail::do_check_stream_state for ar
|
||||
*/
|
||||
template<class Archive>
|
||||
bool check_stream_state(Archive& ar)
|
||||
bool check_stream_state(Archive& ar, bool noeof = false)
|
||||
{
|
||||
return detail::do_check_stream_state(ar.stream(), typename Archive::is_saving());
|
||||
return detail::do_check_stream_state(ar.stream(), typename Archive::is_saving(), noeof);
|
||||
}
|
||||
|
||||
/*! \fn serialize
|
||||
|
@ -360,6 +360,17 @@ namespace serialization {
|
|||
inline bool serialize(Archive &ar, T &v)
|
||||
{
|
||||
bool r = do_serialize(ar, v);
|
||||
return r && check_stream_state(ar);
|
||||
return r && check_stream_state(ar, false);
|
||||
}
|
||||
|
||||
/*! \fn serialize
|
||||
*
|
||||
* \brief serializes \a v into \a ar
|
||||
*/
|
||||
template <class Archive, class T>
|
||||
inline bool serialize_noeof(Archive &ar, T &v)
|
||||
{
|
||||
bool r = do_serialize(ar, v);
|
||||
return r && check_stream_state(ar, true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue