Skip to content

Commit

Permalink
Merge branch 'develop' into feature/test-peer-serivce
Browse files Browse the repository at this point in the history
  • Loading branch information
satellitex committed Jun 20, 2017
2 parents b1f7150 + c1da013 commit 9a5f8f4
Show file tree
Hide file tree
Showing 33 changed files with 1,981 additions and 50 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ jobs:
environment:
IROHA_HOME: /opt/iroha
IROHA_BUILD: /tmp/build
- image: postgres:9.5
- image: redis:3.2.8
steps:
- checkout

Expand Down
19 changes: 19 additions & 0 deletions cmake/Modules/FindCPP_redis.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
find_path(CPP_redis_INCLUDE_DIR cpp_redis/cpp_redis)
mark_as_advanced(CPP_redis_INCLUDE_DIR)

find_library(CPP_redis_LIBRARY cpp_redis)
mark_as_advanced(CPP_redis_LIBRARY)

find_package(PackageHandleStandardArgs REQUIRED)
find_package_handle_standard_args(CPP_redis
REQUIRED_VARS CPP_redis_INCLUDE_DIR CPP_redis_LIBRARY
)

if (CPP_redis_FOUND)
add_library(cpp_redis UNKNOWN IMPORTED)
set_target_properties(cpp_redis PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CPP_redis_INCLUDE_DIR}
IMPORTED_LOCATION ${CPP_redis_LIBRARY}
INTERFACE_LINK_LIBRARIES "tacopie;pthread"
)
endif ()
19 changes: 19 additions & 0 deletions cmake/Modules/FindPQxx.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
find_path(PQxx_INCLUDE_DIR pqxx/pqxx)
mark_as_advanced(PQxx_INCLUDE_DIR)

find_library(PQxx_LIBRARY pqxx)
mark_as_advanced(PQxx_LIBRARY)

find_package(PackageHandleStandardArgs REQUIRED)
find_package_handle_standard_args(PQxx
REQUIRED_VARS PQxx_INCLUDE_DIR PQxx_LIBRARY
)

if (PQxx_FOUND)
add_library(pqxx UNKNOWN IMPORTED)
set_target_properties(pqxx PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${PQxx_INCLUDE_DIR}
IMPORTED_LOCATION ${PQxx_LIBRARY}
INTERFACE_LINK_LIBRARIES "pq"
)
endif ()
99 changes: 69 additions & 30 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ file(MAKE_DIRECTORY ${optional_INCLUDE_DIRS})

add_library(optional INTERFACE IMPORTED)
set_target_properties(optional PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${optional_INCLUDE_DIRS}
)
INTERFACE_INCLUDE_DIRECTORIES ${optional_INCLUDE_DIRS}
)

add_dependencies(optional martinmoene_optional)

Expand All @@ -331,35 +331,10 @@ file(MAKE_DIRECTORY ${any_INCLUDE_DIRS})

add_library(any INTERFACE IMPORTED)
set_target_properties(any PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${any_INCLUDE_DIRS}
)

add_dependencies(any martinmoene_any)

#########
# 天地 #
#########
ExternalProject_Add(hyperledger_iroha-ametsuchi
GIT_REPOSITORY "https://github.com/hyperledger/iroha-ametsuchi"
GIT_TAG "develop"
CMAKE_ARGS -DTESTING=OFF
INSTALL_COMMAND "" # remove install step
TEST_COMMAND "" # remove test step
UPDATE_COMMAND "" # remove update step
)
ExternalProject_Get_Property(hyperledger_iroha-ametsuchi source_dir binary_dir)
set(ametsuchi_INCLUDE_DIR ${source_dir}/include)
set(ametsuchi_LIBRARY ${binary_dir}/lib/libametsuchi.a)

add_library(ametsuchi STATIC IMPORTED)
file(MAKE_DIRECTORY ${ametsuchi_INCLUDE_DIR})

set_target_properties(ametsuchi PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${ametsuchi_INCLUDE_DIR}
IMPORTED_LOCATION ${ametsuchi_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${any_INCLUDE_DIRS}
)
add_dependencies(ametsuchi hyperledger_iroha-ametsuchi)

add_dependencies(any martinmoene_any)

################################
# libuv #
Expand Down Expand Up @@ -410,4 +385,68 @@ set_target_properties(uvw PROPERTIES
INTERFACE_LINK_LIBRARIES "${uv_LIBRARIES};pthread"
)

add_dependencies(uvw skypjack_uvw)
add_dependencies(uvw skypjack_uvw)

##########################
# cpp_redis #
##########################
find_package(CPP_redis)
if (NOT CPP_redis_FOUND)
ExternalProject_Add(cylix_cpp_redis
GIT_REPOSITORY "https://github.com/Cylix/cpp_redis.git"
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
INSTALL_COMMAND "" # remove install step
UPDATE_COMMAND "" # remove update step
TEST_COMMAND "" # remove test step
)
ExternalProject_Get_Property(cylix_cpp_redis source_dir binary_dir)
set(CPP_REDIS_INCLUDE_DIRS ${source_dir}/includes)
set(CPP_REDIS_LIBRARIES ${binary_dir}/lib/libcpp_redis.a)
set(TACOPIE_LIBRARIES ${binary_dir}/lib/libtacopie.a)
file(MAKE_DIRECTORY ${CPP_REDIS_INCLUDE_DIRS})

add_library(cpp_redis STATIC IMPORTED)
set_target_properties(cpp_redis PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CPP_REDIS_INCLUDE_DIRS}
IMPORTED_LOCATION ${CPP_REDIS_LIBRARIES}
IMPORTED_LINK_INTERFACE_LIBRARIES "${TACOPIE_LIBRARIES};pthread"
)

add_dependencies(cpp_redis cylix_cpp_redis)
endif ()

##########################
# pqxx #
##########################
find_package(PQxx)
if (NOT PQxx_FOUND)
find_package(PostgreSQL QUIET)
if (NOT PostgreSQL_LIBRARY)
message(FATAL_ERROR "libpq not found")
endif ()

ExternalProject_Add(jtv_libpqxx
GIT_REPOSITORY "https://github.com/jtv/libpqxx.git"
CONFIGURE_COMMAND ./configure --disable-documentation --with-pic
BUILD_IN_SOURCE 1
BUILD_COMMAND $(MAKE)
INSTALL_COMMAND "" # remove install step
TEST_COMMAND "" # remove test step
UPDATE_COMMAND "" # remove update step
)
ExternalProject_Get_Property(jtv_libpqxx source_dir)
set(pqxx_INCLUDE_DIRS ${source_dir}/include)
set(pqxx_LIBRARIES ${source_dir}/src/.libs/libpqxx.a)
file(MAKE_DIRECTORY ${pqxx_INCLUDE_DIRS})

add_library(pqxx STATIC IMPORTED)
set_target_properties(pqxx PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${pqxx_INCLUDE_DIRS}
IMPORTED_LOCATION ${pqxx_LIBRARIES}
INTERFACE_LINK_LIBRARIES "pq"
)

add_dependencies(pqxx jtv_libpqxx)
endif ()
18 changes: 18 additions & 0 deletions config/bootstrap_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

# this is temporal solution
export IROHA_PEER_PUBKEY_PATH=/home/bogdan/iroha/testbase.pub
export IROHA_PEER_PRIVKEY_PATH=/home/bogdan/iroha/testbase.priv
export IROHA_POSTGRES_HOST=localhost
export IROHA_POSTGRES_PORT=5432
export IROHA_POSTGRES_USER=kek
export IROHA_POSTGRES_PASSWORD=helloworld
export IROHA_REDIS_HOST=localhost
export IROHA_REDIS_PORT=6379
export IROHA_KAFKA_HOST=localhost
export IROHA_KAFKA_PORT=2181
export IROHA_PATH=/home/bogdan/iroha

# debug, info, warning, error, critical, debug, trace, off
export IROHA_VERBOSITY=debug

59 changes: 59 additions & 0 deletions docker/docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
version: '3'

# How to run:
# docker-compose -f docker-compose-dev.yml up
#
# This file creates persistent redis and postgres containers.
# Even after container removal stored data will be available.
#
# redis:
# - host: 192.168.9.2 or 127.0.0.1 or localhost
# - port: 6379
# postgres:
# - host: 192.168.9.3 or 127.0.0.1 or localhost
# - port: 5432
# - user: kek
# - password: helloworld

services:
redis:
image: redis:3.2.8
ports:
- 127.0.0.1:6379:6379
volumes:
- redis_data:/data
networks:
peernet:
ipv4_address: 192.168.9.2


postgres:
image: postgres:9.5
ports:
- 127.0.0.1:5432:5432
environment:
- POSTGRES_USER=kek
- POSTGRES_PASSWORD=helloworld
volumes:
- postgresql:/var/lib/postgresql
- postgresql_data:/var/lib/postgresql/data
networks:
peernet:
ipv4_address: 192.168.9.3


# network for single peer
networks:
peernet:
driver: bridge
ipam:
driver: default
config:
- subnet: 192.168.9.0/24


# make persistence for docker containers
volumes:
redis_data:
postgresql:
postgresql_data:
13 changes: 11 additions & 2 deletions irohad/ametsuchi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
# here will be the code, which is responsible for connection to ametsuchi
message(STATUS "Ametsuchi")

add_subdirectory(block_store)
add_subdirectory(index)
add_subdirectory(wsv)

add_library(storage
storage.cpp
impl/ametsuchi.cpp
index_mediator.cpp
)

target_link_libraries(storage PUBLIC
ametsuchi
schema
cpp_redis
pqxx
optional
block_store
index
wsv
)
3 changes: 3 additions & 0 deletions irohad/ametsuchi/block_store/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_library(block_store
backend/flat_file.cpp
)
Loading

0 comments on commit 9a5f8f4

Please sign in to comment.