forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
multiprocess: Add echoipc RPC method and test
Add simple interfaces::Echo IPC interface with one method that just takes and returns a string, to test multiprocess framework and provide an example of how it can be used to spawn and call between processes.
- Loading branch information
Showing
11 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) 2021 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#include <interfaces/echo.h> | ||
|
||
#include <memory> | ||
|
||
namespace interfaces { | ||
namespace { | ||
class EchoImpl : public Echo | ||
{ | ||
public: | ||
std::string echo(const std::string& echo) override { return echo; } | ||
}; | ||
} // namespace | ||
std::unique_ptr<Echo> MakeEcho() { return std::make_unique<EchoImpl>(); } | ||
} // namespace interfaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2021 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef BITCOIN_INTERFACES_ECHO_H | ||
#define BITCOIN_INTERFACES_ECHO_H | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
namespace interfaces { | ||
//! Simple string echoing interface for testing. | ||
class Echo | ||
{ | ||
public: | ||
virtual ~Echo() {} | ||
|
||
//! Echo provided string. | ||
virtual std::string echo(const std::string& echo) = 0; | ||
}; | ||
|
||
//! Return implementation of Echo interface. | ||
std::unique_ptr<Echo> MakeEcho(); | ||
} // namespace interfaces | ||
|
||
#endif // BITCOIN_INTERFACES_ECHO_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright (c) 2021 The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
@0x888b4f7f51e691f7; | ||
|
||
using Cxx = import "/capnp/c++.capnp"; | ||
$Cxx.namespace("ipc::capnp::messages"); | ||
|
||
using Proxy = import "/mp/proxy.capnp"; | ||
$Proxy.include("interfaces/echo.h"); | ||
$Proxy.include("ipc/capnp/echo.capnp.h"); | ||
|
||
interface Echo $Proxy.wrap("interfaces::Echo") { | ||
destroy @0 (context :Proxy.Context) -> (); | ||
echo @1 (context :Proxy.Context, echo: Text) -> (result :Text); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters