Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
defunctec
crown-core
Commits
9519a9a4
Commit
9519a9a4
authored
10 years ago
by
Pieter Wuille
Browse files
Options
Download
Email Patches
Plain Diff
Add correct bool combiner for net signals
parent
84a05b84
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/net.h
+17
-2
src/net.h
src/test/main_tests.cpp
+17
-0
src/test/main_tests.cpp
with
34 additions
and
2 deletions
+34
-2
src/net.h
View file @
9519a9a4
...
...
@@ -76,12 +76,27 @@ void SocketSendData(CNode *pnode);
typedef
int
NodeId
;
struct
CombinerAll
{
typedef
bool
result_type
;
template
<
typename
I
>
bool
operator
()(
I
first
,
I
last
)
const
{
while
(
first
!=
last
)
{
if
(
!
(
*
first
))
return
false
;
++
first
;
}
return
true
;
}
};
// Signals for message handling
struct
CNodeSignals
{
boost
::
signals2
::
signal
<
int
()
>
GetHeight
;
boost
::
signals2
::
signal
<
bool
(
CNode
*
)
>
ProcessMessages
;
boost
::
signals2
::
signal
<
bool
(
CNode
*
,
bool
)
>
SendMessages
;
boost
::
signals2
::
signal
<
bool
(
CNode
*
)
,
CombinerAll
>
ProcessMessages
;
boost
::
signals2
::
signal
<
bool
(
CNode
*
,
bool
)
,
CombinerAll
>
SendMessages
;
boost
::
signals2
::
signal
<
void
(
NodeId
,
const
CNode
*
)
>
InitializeNode
;
boost
::
signals2
::
signal
<
void
(
NodeId
)
>
FinalizeNode
;
};
...
...
This diff is collapsed.
Click to expand it.
src/test/main_tests.cpp
View file @
9519a9a4
...
...
@@ -21,4 +21,21 @@ BOOST_AUTO_TEST_CASE(subsidy_limit_test)
BOOST_CHECK
(
nSum
==
2099999997690000ULL
);
}
bool
ReturnFalse
()
{
return
false
;
}
bool
ReturnTrue
()
{
return
true
;
}
BOOST_AUTO_TEST_CASE
(
test_combiner_all
)
{
boost
::
signals2
::
signal
<
bool
(),
CombinerAll
>
Test
;
BOOST_CHECK
(
Test
());
Test
.
connect
(
&
ReturnFalse
);
BOOST_CHECK
(
!
Test
());
Test
.
connect
(
&
ReturnTrue
);
BOOST_CHECK
(
!
Test
());
Test
.
disconnect
(
&
ReturnFalse
);
BOOST_CHECK
(
Test
());
Test
.
disconnect
(
&
ReturnTrue
);
BOOST_CHECK
(
Test
());
}
BOOST_AUTO_TEST_SUITE_END
()
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help