-
Notifications
You must be signed in to change notification settings - Fork 36.5k
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
15 changed files
with
156 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Copyright (c) 2020 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_CAPNP_ECHO_TYPES_H | ||
#define BITCOIN_INTERFACES_CAPNP_ECHO_TYPES_H | ||
#endif // BITCOIN_INTERFACES_CAPNP_ECHO_TYPES_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright (c) 2020 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("interfaces::capnp::messages"); | ||
|
||
using Proxy = import "/mp/proxy.capnp"; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (c) 2020 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_CAPNP_ECHO_H | ||
#define BITCOIN_INTERFACES_CAPNP_ECHO_H | ||
|
||
#include <interfaces/capnp/echo.capnp.h> | ||
#include <interfaces/echo.h> | ||
|
||
#endif // BITCOIN_INTERFACES_CAPNP_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
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,23 @@ | ||
// Copyright (c) 2020 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 <util/memory.h> | ||
|
||
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 MakeUnique<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,29 @@ | ||
// Copyright (c) 2020 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 <interfaces/base.h> | ||
|
||
#include <string> | ||
|
||
namespace interfaces { | ||
|
||
//! Simple string echoing interface for testing. | ||
class Echo : public Base | ||
{ | ||
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
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