Skip to content

Commit 6077157

Browse files
committed
ipc: drop BlockValidationState special handling
The Mining interface avoids using BlockValidationState.
1 parent 74690f4 commit 6077157

File tree

5 files changed

+2
-74
lines changed

5 files changed

+2
-74
lines changed

src/ipc/capnp/mining-types.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@
1414
#include <validation.h>
1515

1616
namespace mp {
17-
// Custom serialization for BlockValidationState.
18-
void CustomBuildMessage(InvokeContext& invoke_context,
19-
const BlockValidationState& src,
20-
ipc::capnp::messages::BlockValidationState::Builder&& builder);
21-
void CustomReadMessage(InvokeContext& invoke_context,
22-
const ipc::capnp::messages::BlockValidationState::Reader& reader,
23-
BlockValidationState& dest);
17+
// Custom serializations
2418
} // namespace mp
2519

2620
#endif // BITCOIN_IPC_CAPNP_MINING_TYPES_H

src/ipc/capnp/mining.capnp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,3 @@ struct BlockWaitOptions $Proxy.wrap("node::BlockWaitOptions") {
4444
timeout @0 : Float64 $Proxy.name("timeout");
4545
feeThreshold @1 : Int64 $Proxy.name("fee_threshold");
4646
}
47-
48-
# Note: serialization of the BlockValidationState C++ type is somewhat fragile
49-
# and using the struct can be awkward. It would be good if testBlockValidity
50-
# method were changed to return validity information in a simpler format.
51-
struct BlockValidationState {
52-
mode @0 :Int32;
53-
result @1 :Int32;
54-
rejectReason @2 :Text;
55-
debugMessage @3 :Text;
56-
}

src/ipc/capnp/mining.cpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,4 @@
88
#include <mp/proxy-types.h>
99

1010
namespace mp {
11-
void CustomBuildMessage(InvokeContext& invoke_context,
12-
const BlockValidationState& src,
13-
ipc::capnp::messages::BlockValidationState::Builder&& builder)
14-
{
15-
if (src.IsValid()) {
16-
builder.setMode(0);
17-
} else if (src.IsInvalid()) {
18-
builder.setMode(1);
19-
} else if (src.IsError()) {
20-
builder.setMode(2);
21-
} else {
22-
assert(false);
23-
}
24-
builder.setResult(static_cast<int>(src.GetResult()));
25-
builder.setRejectReason(src.GetRejectReason());
26-
builder.setDebugMessage(src.GetDebugMessage());
27-
}
28-
29-
void CustomReadMessage(InvokeContext& invoke_context,
30-
const ipc::capnp::messages::BlockValidationState::Reader& reader,
31-
BlockValidationState& dest)
32-
{
33-
if (reader.getMode() == 0) {
34-
assert(reader.getResult() == 0);
35-
assert(reader.getRejectReason().size() == 0);
36-
assert(reader.getDebugMessage().size() == 0);
37-
} else if (reader.getMode() == 1) {
38-
dest.Invalid(static_cast<BlockValidationResult>(reader.getResult()), reader.getRejectReason(), reader.getDebugMessage());
39-
} else if (reader.getMode() == 2) {
40-
assert(reader.getResult() == 0);
41-
dest.Error(reader.getRejectReason());
42-
assert(reader.getDebugMessage().size() == 0);
43-
} else {
44-
assert(false);
45-
}
46-
}
4711
} // namespace mp

src/test/ipc_test.capnp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,5 @@ interface FooInterface $Proxy.wrap("FooImplementation") {
1919
passUniValue @2 (arg :Text) -> (result :Text);
2020
passTransaction @3 (arg :Data) -> (result :Data);
2121
passVectorChar @4 (arg :Data) -> (result :Data);
22-
passBlockState @5 (arg :Mining.BlockValidationState) -> (result :Mining.BlockValidationState);
23-
passScript @6 (arg :Data) -> (result :Data);
22+
passScript @5 (arg :Data) -> (result :Data);
2423
}

src/test/ipc_test.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -102,25 +102,6 @@ void IpcPipeTest()
102102
std::vector<char> vec2{foo->passVectorChar(vec1)};
103103
BOOST_CHECK_EQUAL(std::string_view(vec1.begin(), vec1.end()), std::string_view(vec2.begin(), vec2.end()));
104104

105-
BlockValidationState bs1;
106-
bs1.Invalid(BlockValidationResult::BLOCK_MUTATED, "reject reason", "debug message");
107-
BlockValidationState bs2{foo->passBlockState(bs1)};
108-
BOOST_CHECK_EQUAL(bs1.IsValid(), bs2.IsValid());
109-
BOOST_CHECK_EQUAL(bs1.IsError(), bs2.IsError());
110-
BOOST_CHECK_EQUAL(bs1.IsInvalid(), bs2.IsInvalid());
111-
BOOST_CHECK_EQUAL(static_cast<int>(bs1.GetResult()), static_cast<int>(bs2.GetResult()));
112-
BOOST_CHECK_EQUAL(bs1.GetRejectReason(), bs2.GetRejectReason());
113-
BOOST_CHECK_EQUAL(bs1.GetDebugMessage(), bs2.GetDebugMessage());
114-
115-
BlockValidationState bs3;
116-
BlockValidationState bs4{foo->passBlockState(bs3)};
117-
BOOST_CHECK_EQUAL(bs3.IsValid(), bs4.IsValid());
118-
BOOST_CHECK_EQUAL(bs3.IsError(), bs4.IsError());
119-
BOOST_CHECK_EQUAL(bs3.IsInvalid(), bs4.IsInvalid());
120-
BOOST_CHECK_EQUAL(static_cast<int>(bs3.GetResult()), static_cast<int>(bs4.GetResult()));
121-
BOOST_CHECK_EQUAL(bs3.GetRejectReason(), bs4.GetRejectReason());
122-
BOOST_CHECK_EQUAL(bs3.GetDebugMessage(), bs4.GetDebugMessage());
123-
124105
auto script1{CScript() << OP_11};
125106
auto script2{foo->passScript(script1)};
126107
BOOST_CHECK_EQUAL(HexStr(script1), HexStr(script2));

0 commit comments

Comments
 (0)