Gav Wood
10 years ago
14 changed files with 984 additions and 4 deletions
@ -0,0 +1,117 @@ |
|||
cmake_policy(SET CMP0015 NEW) |
|||
|
|||
if ("${TARGET_PLATFORM}" STREQUAL "w64") |
|||
cmake_policy(SET CMP0020 NEW) |
|||
endif () |
|||
|
|||
|
|||
set(CMAKE_INCLUDE_CURRENT_DIR ON) |
|||
aux_source_directory(. SRC_LIST) |
|||
|
|||
include_directories(..) |
|||
link_directories(../libethcore) |
|||
link_directories(../libethereum) |
|||
link_directories(../libqethereum) |
|||
|
|||
# Find Qt5 for Apple and update src_list for windows |
|||
if (APPLE) |
|||
# homebrew defaults to qt4 and installs qt5 as 'keg-only' |
|||
# which places it into /usr/local/opt insteadof /usr/local. |
|||
|
|||
set(CMAKE_PREFIX_PATH /usr/local/opt/qt5) |
|||
include_directories(/usr/local/opt/qt5/include /usr/local/include) |
|||
elseif ("${TARGET_PLATFORM}" STREQUAL "w64") |
|||
set(SRC_LIST ${SRC_LIST} ../windows/qt_plugin_import.cpp) |
|||
elseif (UNIX) |
|||
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";$ENV{QTDIR}/lib/cmake") |
|||
endif () |
|||
|
|||
|
|||
find_package(Qt5Widgets REQUIRED) |
|||
find_package(Qt5Gui REQUIRED) |
|||
find_package(Qt5Quick REQUIRED) |
|||
find_package(Qt5Qml REQUIRED) |
|||
find_package(Qt5Network REQUIRED) |
|||
qt5_wrap_ui(ui_Main.h Main.ui) |
|||
qt5_add_resources(RESOURCE_ADDED Resources.qrc) |
|||
|
|||
# Set name of binary and add_executable() |
|||
if (APPLE) |
|||
set(EXECUTEABLE IEthXi) |
|||
set(CMAKE_INSTALL_PREFIX ./) |
|||
set(BIN_INSTALL_DIR ".") |
|||
set(DOC_INSTALL_DIR ".") |
|||
|
|||
set(PROJECT_VERSION "${ETH_VERSION}") |
|||
set(MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") |
|||
set(MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_NAME} ${PROJECT_VERSION}") |
|||
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") |
|||
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}") |
|||
set(MACOSX_BUNDLE_COPYRIGHT "${PROJECT_COPYRIGHT_YEAR} ${PROJECT_VENDOR}") |
|||
set(MACOSX_BUNDLE_GUI_IDENTIFIER "${PROJECT_DOMAIN_SECOND}.${PROJECT_DOMAIN_FIRST}") |
|||
set(MACOSX_BUNDLE_BUNDLE_NAME ${EXECUTEABLE}) |
|||
include(BundleUtilities) |
|||
|
|||
add_executable(${EXECUTEABLE} MACOSX_BUNDLE Main.ui ${RESOURCE_ADDED} ${SRC_LIST}) |
|||
else () |
|||
set(EXECUTEABLE iethxi) |
|||
add_executable(${EXECUTEABLE} Main.ui ${RESOURCE_ADDED} ${SRC_LIST}) |
|||
endif () |
|||
|
|||
qt5_use_modules(${EXECUTEABLE} Core Gui Widgets Network Quick Qml) |
|||
target_link_libraries(${EXECUTEABLE} qethereum ethereum secp256k1 ${CRYPTOPP_LS}) |
|||
|
|||
if (APPLE) |
|||
if (${ADDFRAMEWORKS}) |
|||
set_target_properties(${EXECUTEABLE} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/EthereumMacOSXBundleInfo.plist.in") |
|||
endif () |
|||
|
|||
SET_SOURCE_FILES_PROPERTIES(${EXECUTEABLE} PROPERTIES MACOSX_PACKAGE_LOCATION MacOS) |
|||
|
|||
# This is a workaround for when the build-type defaults to Debug, and when a multi-config generator like xcode is used, where the type |
|||
# will not be set but defaults to release. |
|||
set(generator_lowercase "${CMAKE_GENERATOR}") |
|||
string(TOLOWER "${CMAKE_GENERATOR}" generator_lowercase) |
|||
if ("${generator_lowercase}" STREQUAL "xcode") |
|||
# TODO: Not sure how to resolve this. Possibly \${TARGET_BUILD_DIR} |
|||
set(binary_build_dir "${CMAKE_CURRENT_BINARY_DIR}/Debug") |
|||
else () |
|||
set(binary_build_dir "${CMAKE_CURRENT_BINARY_DIR}") |
|||
endif () |
|||
|
|||
set(APPS ${binary_build_dir}/${EXECUTEABLE}.app) |
|||
|
|||
# This tool and the next will automatically looked at the linked libraries in order to determine what dependencies are required. Thus, target_link_libaries only needs to add ethereum and secp256k1 (above) |
|||
install(CODE " |
|||
include(BundleUtilities) |
|||
set(BU_CHMOD_BUNDLE_ITEMS 1) |
|||
fixup_bundle(\"${APPS}\" \"${BUNDLELIBS}\" \"../libqethereum ../libethereum ../secp256k1\") |
|||
" COMPONENT RUNTIME ) |
|||
|
|||
if (${ADDFRAMEWORKS}) |
|||
add_custom_target(addframeworks ALL |
|||
COMMAND /usr/local/opt/qt5/bin/macdeployqt ${binary_build_dir}/${EXECUTEABLE}.app |
|||
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} |
|||
DEPENDS ${PROJECT_NAME} |
|||
) |
|||
endif () |
|||
|
|||
elseif ("${TARGET_PLATFORM}" STREQUAL "w64") |
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-keep-inline-dllexport -static-libgcc -static-libstdc++ -static") |
|||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-s -Wl,-subsystem,windows -mthreads -L/usr/x86_64-w64-mingw32/plugins/platforms") |
|||
target_link_libraries(${EXECUTEABLE} gcc) |
|||
target_link_libraries(${EXECUTEABLE} mingw32 qtmain mswsock iphlpapi qwindows shlwapi Qt5PlatformSupport gdi32 comdlg32 oleaut32 imm32 winmm ole32 uuid ws2_32) |
|||
target_link_libraries(${EXECUTEABLE} boost_system-mt-s) |
|||
target_link_libraries(${EXECUTEABLE} boost_filesystem-mt-s) |
|||
target_link_libraries(${EXECUTEABLE} boost_thread_win32-mt-s) |
|||
target_link_libraries(${EXECUTEABLE} Qt5PlatformSupport) |
|||
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS) |
|||
elseif (UNIX) |
|||
else () |
|||
target_link_libraries(${EXECUTEABLE} boost_system) |
|||
target_link_libraries(${EXECUTEABLE} boost_filesystem) |
|||
find_package(Threads REQUIRED) |
|||
target_link_libraries(${EXECUTEABLE} ${CMAKE_THREAD_LIBS_INIT}) |
|||
install( TARGETS ${EXECUTEABLE} RUNTIME DESTINATION bin ) |
|||
endif () |
|||
|
@ -0,0 +1,168 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<ui version="4.0"> |
|||
<class>Main</class> |
|||
<widget class="QMainWindow" name="Main"> |
|||
<property name="geometry"> |
|||
<rect> |
|||
<x>0</x> |
|||
<y>0</y> |
|||
<width>562</width> |
|||
<height>488</height> |
|||
</rect> |
|||
</property> |
|||
<property name="windowTitle"> |
|||
<string>Walleth</string> |
|||
</property> |
|||
<property name="dockNestingEnabled"> |
|||
<bool>true</bool> |
|||
</property> |
|||
<property name="dockOptions"> |
|||
<set>QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::VerticalTabs</set> |
|||
</property> |
|||
<property name="sizeGripEnabled" stdset="0"> |
|||
<bool>true</bool> |
|||
</property> |
|||
<widget class="QWidget" name="centralwidget"> |
|||
<layout class="QVBoxLayout" name="verticalLayout"> |
|||
<property name="leftMargin"> |
|||
<number>0</number> |
|||
</property> |
|||
<property name="topMargin"> |
|||
<number>0</number> |
|||
</property> |
|||
<property name="rightMargin"> |
|||
<number>0</number> |
|||
</property> |
|||
<property name="bottomMargin"> |
|||
<number>0</number> |
|||
</property> |
|||
<item> |
|||
<layout class="QHBoxLayout" name="fullDisplay"> |
|||
<item> |
|||
<widget class="QLabel" name="balance"> |
|||
<property name="text"> |
|||
<string>0 wei</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<widget class="QLabel" name="peerCount"> |
|||
<property name="text"> |
|||
<string>0 peers</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<widget class="QLabel" name="blockCount"> |
|||
<property name="text"> |
|||
<string>1 block</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
</layout> |
|||
</item> |
|||
</layout> |
|||
</widget> |
|||
<widget class="QMenuBar" name="menubar"> |
|||
<property name="geometry"> |
|||
<rect> |
|||
<x>0</x> |
|||
<y>0</y> |
|||
<width>562</width> |
|||
<height>25</height> |
|||
</rect> |
|||
</property> |
|||
<widget class="QMenu" name="menu_File"> |
|||
<property name="title"> |
|||
<string>&File</string> |
|||
</property> |
|||
<addaction name="quit"/> |
|||
</widget> |
|||
<widget class="QMenu" name="menu_Network"> |
|||
<property name="title"> |
|||
<string>&Network</string> |
|||
</property> |
|||
<addaction name="upnp"/> |
|||
<addaction name="net"/> |
|||
<addaction name="connect"/> |
|||
</widget> |
|||
<widget class="QMenu" name="menu_Tools"> |
|||
<property name="title"> |
|||
<string>T&ools</string> |
|||
</property> |
|||
<addaction name="mine"/> |
|||
<addaction name="create"/> |
|||
<addaction name="preview"/> |
|||
</widget> |
|||
<widget class="QMenu" name="menu_Help"> |
|||
<property name="title"> |
|||
<string>&Help</string> |
|||
</property> |
|||
<addaction name="about"/> |
|||
</widget> |
|||
<addaction name="menu_File"/> |
|||
<addaction name="menu_Network"/> |
|||
<addaction name="menu_Tools"/> |
|||
<addaction name="menu_Help"/> |
|||
</widget> |
|||
<widget class="QStatusBar" name="statusbar"/> |
|||
<action name="quit"> |
|||
<property name="text"> |
|||
<string>&Quit</string> |
|||
</property> |
|||
</action> |
|||
<action name="upnp"> |
|||
<property name="checkable"> |
|||
<bool>true</bool> |
|||
</property> |
|||
<property name="checked"> |
|||
<bool>true</bool> |
|||
</property> |
|||
<property name="text"> |
|||
<string>Use &UPnP</string> |
|||
</property> |
|||
</action> |
|||
<action name="connect"> |
|||
<property name="text"> |
|||
<string>&Connect to Peer...</string> |
|||
</property> |
|||
</action> |
|||
<action name="net"> |
|||
<property name="checkable"> |
|||
<bool>true</bool> |
|||
</property> |
|||
<property name="text"> |
|||
<string>Enable &Network</string> |
|||
</property> |
|||
</action> |
|||
<action name="mine"> |
|||
<property name="checkable"> |
|||
<bool>true</bool> |
|||
</property> |
|||
<property name="text"> |
|||
<string>&Mine</string> |
|||
</property> |
|||
</action> |
|||
<action name="create"> |
|||
<property name="text"> |
|||
<string>&New Address</string> |
|||
</property> |
|||
</action> |
|||
<action name="about"> |
|||
<property name="text"> |
|||
<string>&About...</string> |
|||
</property> |
|||
</action> |
|||
<action name="preview"> |
|||
<property name="checkable"> |
|||
<bool>true</bool> |
|||
</property> |
|||
<property name="text"> |
|||
<string>&Preview</string> |
|||
</property> |
|||
</action> |
|||
</widget> |
|||
<layoutdefault spacing="6" margin="11"/> |
|||
<resources/> |
|||
<connections/> |
|||
</ui> |
@ -0,0 +1,59 @@ |
|||
#include <QtNetwork/QNetworkReply> |
|||
#include <QtQuick/QQuickView> |
|||
#include <QtQml/QQmlContext> |
|||
#include <QtQml/QQmlEngine> |
|||
#include <QtQml/QtQml> |
|||
#include <QtWidgets/QMessageBox> |
|||
#include <QtWidgets/QInputDialog> |
|||
#include <QtGui/QClipboard> |
|||
#include <QtCore/QtCore> |
|||
#include <libethcore/FileSystem.h> |
|||
#include <libethcore/Dagger.h> |
|||
#include <libevmface/Instruction.h> |
|||
#include <libethereum/Client.h> |
|||
#include <libethereum/PeerServer.h> |
|||
#include "BuildInfo.h" |
|||
#include "MainWin.h" |
|||
#include "ui_Main.h" |
|||
using namespace std; |
|||
using namespace eth; |
|||
|
|||
Main::Main(QWidget *parent) : |
|||
QObject(parent) |
|||
{ |
|||
/* qRegisterMetaType<eth::u256>("eth::u256");
|
|||
qRegisterMetaType<eth::KeyPair>("eth::KeyPair"); |
|||
qRegisterMetaType<eth::Secret>("eth::Secret"); |
|||
qRegisterMetaType<eth::Address>("eth::Address"); |
|||
qRegisterMetaType<QmlAccount*>("QmlAccount*"); |
|||
qRegisterMetaType<QmlEthereum*>("QmlEthereum*"); |
|||
|
|||
qmlRegisterType<QmlEthereum>("org.ethereum", 1, 0, "Ethereum"); |
|||
qmlRegisterType<QmlAccount>("org.ethereum", 1, 0, "Account"); |
|||
qmlRegisterSingletonType<QmlU256Helper>("org.ethereum", 1, 0, "Balance", QmlEthereum::constructU256Helper); |
|||
qmlRegisterSingletonType<QmlKeyHelper>("org.ethereum", 1, 0, "Key", QmlEthereum::constructKeyHelper); |
|||
*/ |
|||
/*
|
|||
ui->librariesView->setModel(m_libraryMan); |
|||
ui->graphsView->setModel(m_graphMan); |
|||
*/ |
|||
|
|||
|
|||
|
|||
|
|||
// QQmlContext* context = m_view->rootContext();
|
|||
// context->setContextProperty("u256", new U256Helper(this));
|
|||
} |
|||
|
|||
Main::~Main() |
|||
{ |
|||
} |
|||
|
|||
// extra bits needed to link on VS
|
|||
#ifdef _MSC_VER |
|||
|
|||
// include moc file, ofuscated to hide from automoc
|
|||
#include\ |
|||
"moc_MainWin.cpp" |
|||
|
|||
#endif |
@ -0,0 +1,18 @@ |
|||
#ifndef MAIN_H |
|||
#define MAIN_H |
|||
|
|||
#include <QtQml/QQmlApplicationEngine> |
|||
|
|||
class Main: public QObject |
|||
{ |
|||
Q_OBJECT |
|||
|
|||
public: |
|||
explicit Main(QWidget *parent = 0); |
|||
~Main(); |
|||
|
|||
private: |
|||
QQmlApplicationEngine* m_view; |
|||
}; |
|||
|
|||
#endif // MAIN_H
|
@ -0,0 +1,5 @@ |
|||
<RCC> |
|||
<qresource prefix="/"> |
|||
<file>Simple.qml</file> |
|||
</qresource> |
|||
</RCC> |
@ -0,0 +1,9 @@ |
|||
#include <QtQml/QQmlApplicationEngine> |
|||
#include <QtWidgets/QApplication> |
|||
|
|||
int main(int argc, char *argv[]) |
|||
{ |
|||
QApplication a(argc, argv); |
|||
QQmlApplicationEngine app(QUrl("qrc:/Simple.qml")); |
|||
return a.exec(); |
|||
} |
@ -0,0 +1,66 @@ |
|||
cmake_policy(SET CMP0015 NEW) |
|||
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTATICLIB") |
|||
|
|||
aux_source_directory(. SRC_LIST) |
|||
|
|||
set(EXECUTABLE ethereumx) |
|||
|
|||
# set(CMAKE_INSTALL_PREFIX ../lib) |
|||
if(ETH_STATIC) |
|||
add_library(${EXECUTABLE} STATIC ${SRC_LIST}) |
|||
else() |
|||
add_library(${EXECUTABLE} SHARED ${SRC_LIST}) |
|||
endif() |
|||
|
|||
file(GLOB HEADERS "*.h") |
|||
|
|||
include_directories(..) |
|||
|
|||
target_link_libraries(${EXECUTABLE} evm) |
|||
target_link_libraries(${EXECUTABLE} lll) |
|||
target_link_libraries(${EXECUTABLE} ethcore) |
|||
target_link_libraries(${EXECUTABLE} secp256k1) |
|||
if(MINIUPNPC_LS) |
|||
target_link_libraries(${EXECUTABLE} ${MINIUPNPC_LS}) |
|||
endif() |
|||
target_link_libraries(${EXECUTABLE} ${LEVELDB_LS}) |
|||
target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LS}) |
|||
target_link_libraries(${EXECUTABLE} gmp) |
|||
|
|||
if("${TARGET_PLATFORM}" STREQUAL "w64") |
|||
target_link_libraries(${EXECUTABLE} boost_system-mt-s) |
|||
target_link_libraries(${EXECUTABLE} boost_regex-mt-s) |
|||
target_link_libraries(${EXECUTABLE} boost_filesystem-mt-s) |
|||
target_link_libraries(${EXECUTABLE} boost_thread_win32-mt-s) |
|||
target_link_libraries(${EXECUTABLE} iphlpapi) |
|||
target_link_libraries(${EXECUTABLE} ws2_32) |
|||
target_link_libraries(${EXECUTABLE} mswsock) |
|||
target_link_libraries(${EXECUTABLE} shlwapi) |
|||
elseif (APPLE) |
|||
# Latest mavericks boost libraries only come with -mt |
|||
target_link_libraries(${EXECUTABLE} boost_system-mt) |
|||
target_link_libraries(${EXECUTABLE} boost_regex-mt) |
|||
target_link_libraries(${EXECUTABLE} boost_filesystem-mt) |
|||
target_link_libraries(${EXECUTABLE} boost_thread-mt) |
|||
find_package(Threads REQUIRED) |
|||
target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT}) |
|||
elseif (UNIX) |
|||
target_link_libraries(${EXECUTABLE} ${Boost_SYSTEM_LIBRARY}) |
|||
target_link_libraries(${EXECUTABLE} ${Boost_REGEX_LIBRARY}) |
|||
target_link_libraries(${EXECUTABLE} ${Boost_FILESYSTEM_LIBRARY}) |
|||
target_link_libraries(${EXECUTABLE} ${Boost_THREAD_LIBRARY}) |
|||
target_link_libraries(${EXECUTABLE} ${Boost_DATE_TIME_LIBRARY}) |
|||
target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT}) |
|||
else () |
|||
target_link_libraries(${EXECUTABLE} boost_system) |
|||
target_link_libraries(${EXECUTABLE} boost_regex) |
|||
target_link_libraries(${EXECUTABLE} boost_filesystem) |
|||
target_link_libraries(${EXECUTABLE} boost_thread) |
|||
find_package(Threads REQUIRED) |
|||
target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT}) |
|||
endif () |
|||
|
|||
install( TARGETS ${EXECUTABLE} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) |
|||
install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) |
|||
|
@ -0,0 +1,125 @@ |
|||
/*
|
|||
This file is part of cpp-ethereum. |
|||
|
|||
cpp-ethereum is free software: you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation, either version 3 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
cpp-ethereum is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
/** @file Ethereum.cpp
|
|||
* @author Gav Wood <i@gavwood.com> |
|||
* @date 2014 |
|||
*/ |
|||
|
|||
#include "Ethereum.h" |
|||
|
|||
#include <libethential/Log.h> |
|||
#include <libethereum/Client.h> |
|||
using namespace std; |
|||
using namespace eth; |
|||
|
|||
Ethereum::Ethereum() |
|||
{ |
|||
ensureReady(); |
|||
} |
|||
|
|||
void Ethereum::ensureReady() |
|||
{ |
|||
while (!m_client && connectionOpen()) |
|||
try |
|||
{ |
|||
m_client = unique_ptr<Client>(new Client("+ethereum+")); |
|||
if (m_client) |
|||
startServer(); |
|||
} |
|||
catch (DatabaseAlreadyOpen) |
|||
{ |
|||
startClient(); |
|||
} |
|||
} |
|||
|
|||
Ethereum::~Ethereum() |
|||
{ |
|||
} |
|||
|
|||
bool Ethereum::connectionOpen() const |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
void Ethereum::startClient() |
|||
{ |
|||
} |
|||
|
|||
void Ethereum::startServer() |
|||
{ |
|||
} |
|||
|
|||
void Client::flushTransactions() |
|||
{ |
|||
} |
|||
|
|||
std::vector<PeerInfo> Client::peers() |
|||
{ |
|||
return std::vector<PeerInfo>(); |
|||
} |
|||
|
|||
size_t Client::peerCount() const |
|||
{ |
|||
return 0; |
|||
} |
|||
|
|||
void Client::connect(std::string const& _seedHost, unsigned short _port) |
|||
{ |
|||
} |
|||
|
|||
void Client::transact(Secret _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice) |
|||
{ |
|||
} |
|||
|
|||
bytes Client::call(Secret _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice) |
|||
{ |
|||
return bytes(); |
|||
} |
|||
|
|||
Address Client::transact(Secret _secret, u256 _endowment, bytes const& _init, u256 _gas, u256 _gasPrice) |
|||
{ |
|||
return Address(); |
|||
} |
|||
|
|||
void Client::inject(bytesConstRef _rlp) |
|||
{ |
|||
} |
|||
|
|||
u256 Client::balanceAt(Address _a, int _block) const |
|||
{ |
|||
return u256(); |
|||
} |
|||
|
|||
std::map<u256, u256> Client::storageAt(Address _a, int _block) const |
|||
{ |
|||
return std::map<u256, u256>(); |
|||
} |
|||
|
|||
u256 Client::countAt(Address _a, int _block) const |
|||
{ |
|||
return u256(); |
|||
} |
|||
|
|||
u256 Client::stateAt(Address _a, u256 _l, int _block) const |
|||
{ |
|||
return u256(); |
|||
} |
|||
|
|||
bytes Client::codeAt(Address _a, int _block) const |
|||
{ |
|||
return bytes(); |
|||
} |
@ -0,0 +1,144 @@ |
|||
/*
|
|||
This file is part of cpp-ethereum. |
|||
|
|||
cpp-ethereum is free software: you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation, either version 3 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
cpp-ethereum is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
/** @file Ethereum.h
|
|||
* @author Gav Wood <i@gavwood.com> |
|||
* @date 2014 |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include <thread> |
|||
#include <mutex> |
|||
#include <list> |
|||
#include <atomic> |
|||
#include <boost/utility.hpp> |
|||
#include <libethential/Common.h> |
|||
#include <libethential/CommonIO.h> |
|||
#include <libevm/FeeStructure.h> |
|||
#include <libethcore/Dagger.h> |
|||
#include <libethereum/Guards.h> |
|||
#include <libethereum/PastMessage.h> |
|||
#include <libethereum/MessageFilter.h> |
|||
#include <libethereum/PeerNetwork.h> |
|||
|
|||
namespace eth |
|||
{ |
|||
|
|||
class Client; |
|||
|
|||
/**
|
|||
* @brief Main API hub for interfacing with Ethereum. |
|||
* This class is automatically able to share a single machine-wide Client instance with other |
|||
* instances, cross-process. |
|||
* |
|||
* Other than that, it provides much the same subset of functionality as Client. |
|||
*/ |
|||
class Ethereum |
|||
{ |
|||
friend class Miner; |
|||
|
|||
public: |
|||
/// Constructor. After this, everything should be set up to go.
|
|||
Ethereum(); |
|||
|
|||
/// Destructor.
|
|||
~Ethereum(); |
|||
|
|||
/// Submits the given message-call transaction.
|
|||
void transact(Secret _secret, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 10 * szabo); |
|||
|
|||
/// Submits a new contract-creation transaction.
|
|||
/// @returns the new contract's address (assuming it all goes through).
|
|||
Address transact(Secret _secret, u256 _endowment, bytes const& _init, u256 _gas = 10000, u256 _gasPrice = 10 * szabo); |
|||
|
|||
/// Injects the RLP-encoded transaction given by the _rlp into the transaction queue directly.
|
|||
void inject(bytesConstRef _rlp); |
|||
|
|||
/// Blocks until all pending transactions have been processed.
|
|||
void flushTransactions(); |
|||
|
|||
/// Makes the given call. Nothing is recorded into the state.
|
|||
bytes call(Secret _secret, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 10 * szabo); |
|||
|
|||
// Informational stuff
|
|||
|
|||
// [NEW API]
|
|||
|
|||
int getDefault() const { return m_default; } |
|||
void setDefault(int _block) { m_default = _block; } |
|||
|
|||
u256 balanceAt(Address _a) const { return balanceAt(_a, m_default); } |
|||
u256 countAt(Address _a) const { return countAt(_a, m_default); } |
|||
u256 stateAt(Address _a, u256 _l) const { return stateAt(_a, _l, m_default); } |
|||
bytes codeAt(Address _a) const { return codeAt(_a, m_default); } |
|||
std::map<u256, u256> storageAt(Address _a) const { return storageAt(_a, m_default); } |
|||
|
|||
u256 balanceAt(Address _a, int _block) const; |
|||
u256 countAt(Address _a, int _block) const; |
|||
u256 stateAt(Address _a, u256 _l, int _block) const; |
|||
bytes codeAt(Address _a, int _block) const; |
|||
std::map<u256, u256> storageAt(Address _a, int _block) const; |
|||
|
|||
PastMessages messages(MessageFilter const& _filter) const; |
|||
|
|||
// [EXTRA API]:
|
|||
#if 0 |
|||
/// Get a map containing each of the pending transactions.
|
|||
/// @TODO: Remove in favour of transactions().
|
|||
Transactions pending() const { return m_postMine.pending(); } |
|||
|
|||
/// Differences between transactions.
|
|||
StateDiff diff(unsigned _txi) const { return diff(_txi, m_default); } |
|||
StateDiff diff(unsigned _txi, h256 _block) const; |
|||
StateDiff diff(unsigned _txi, int _block) const; |
|||
|
|||
/// Get a list of all active addresses.
|
|||
std::vector<Address> addresses() const { return addresses(m_default); } |
|||
std::vector<Address> addresses(int _block) const; |
|||
|
|||
/// Get the fee associated for a transaction with the given data.
|
|||
static u256 txGas(uint _dataCount, u256 _gas = 0) { return c_txDataGas * _dataCount + c_txGas + _gas; } |
|||
|
|||
/// Get the remaining gas limit in this block.
|
|||
u256 gasLimitRemaining() const { return m_postMine.gasLimitRemaining(); } |
|||
#endif |
|||
// Network stuff:
|
|||
|
|||
/// Get information on the current peer set.
|
|||
std::vector<PeerInfo> peers(); |
|||
/// Same as peers().size(), but more efficient.
|
|||
size_t peerCount() const; |
|||
|
|||
/// Connect to a particular peer.
|
|||
void connect(std::string const& _seedHost, unsigned short _port = 30303); |
|||
|
|||
private: |
|||
/// Ensure that through either the client or the
|
|||
void ensureReady(); |
|||
/// Check to see if the client/server connection is open.
|
|||
bool connectionOpen() const; |
|||
/// Start the API client.
|
|||
void startClient(); |
|||
/// Start the API server.
|
|||
void startServer(); |
|||
|
|||
std::unique_ptr<Client> m_client; |
|||
|
|||
int m_default = -1; |
|||
}; |
|||
|
|||
} |
Loading…
Reference in new issue