Skip to content
This repository was archived by the owner on Oct 4, 2019. It is now read-only.

Commit 9ee5f5f

Browse files
authored
Merge pull request #937 from GolosChain/golos-v0.18.4
Golos v0.18.4
2 parents f1122e7 + a3913e9 commit 9ee5f5f

4 files changed

Lines changed: 43 additions & 5 deletions

File tree

libraries/chain/database.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ namespace golos { namespace chain {
11451145

11461146
signed_block pending_block;
11471147

1148-
with_strong_write_lock([&]() {
1148+
with_strong_write_lock([&]() { detail::with_generating(*this, [&]() {
11491149
//
11501150
// The following code throws away existing pending_tx_session and
11511151
// rebuilds it by re-applying pending transactions.
@@ -1198,7 +1198,7 @@ namespace golos { namespace chain {
11981198
}
11991199

12001200
_pending_tx_session.reset();
1201-
});
1201+
}); });
12021202

12031203
// We have temporarily broken the invariant that
12041204
// _pending_tx_session is the result of applying _pending_tx, as

libraries/chain/include/golos/chain/database.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,16 @@ namespace golos { namespace chain {
4848
_is_producing = p;
4949
}
5050

51+
bool is_generating() const {
52+
return _is_generating;
53+
}
54+
55+
void set_generating(bool p) {
56+
_is_generating = p;
57+
}
58+
5159
bool _is_producing = false;
60+
bool _is_generating = false;
5261
bool _is_testing = false; ///< set for tests to avoid low free memory spam
5362
bool _log_hardforks = true;
5463

libraries/chain/include/golos/chain/db_with.hpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ namespace golos {
8282
database &_db;
8383
};
8484

85+
/**
86+
* Class is used to help the with_generating implementation
87+
*/
88+
struct generating_helper final {
89+
generating_helper(database& db): _db(db) {
90+
_db.set_generating(true);
91+
}
92+
93+
~generating_helper() {
94+
_db.set_generating(false);
95+
}
96+
97+
database &_db;
98+
};
99+
85100
/**
86101
* Empty pending_transactions, call callback,
87102
* then reset pending_transactions after callback is done.
@@ -111,6 +126,19 @@ namespace golos {
111126
producing_helper restorer(db);
112127
callback();
113128
}
129+
130+
/**
131+
* Set generating flag to true, call callback, then set generating flag to false
132+
*/
133+
template <typename Lambda>
134+
void with_generating(
135+
database& db,
136+
Lambda callback
137+
) {
138+
generating_helper restorer(db);
139+
callback();
140+
}
141+
114142
}
115143
}
116144
} // golos::chain::detail

plugins/private_message/private_message_plugin.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ namespace golos { namespace plugins { namespace private_message {
286286
}
287287

288288
bool private_message_plugin::private_message_plugin_impl::can_call_callbacks() const {
289-
return !db_.is_producing() && !callbacks_.empty();
289+
return !db_.is_producing() && !db_.is_generating() && !callbacks_.empty();
290290
}
291291

292292
void private_message_plugin::private_message_plugin_impl::call_callbacks(
@@ -300,8 +300,9 @@ namespace golos { namespace plugins { namespace private_message {
300300
(!info.query.select_events.empty() && !info.query.select_events.count(event)) ||
301301
info.query.filter_accounts.count(from) ||
302302
info.query.filter_accounts.count(to) ||
303-
(to.size() && !info.query.select_accounts.empty() && !info.query.select_accounts.count(to)) ||
304-
(from.size() && !info.query.select_accounts.empty() && !info.query.select_accounts.count(from))
303+
(!info.query.select_accounts.empty() &&
304+
!info.query.select_accounts.count(to) &&
305+
!info.query.select_accounts.count(from))
305306
) {
306307
++itr;
307308
continue;

0 commit comments

Comments
 (0)