├── .github └── workflows │ ├── docker-main.yml │ └── docker-pr-build.yml ├── .gitignore ├── .gitmodules ├── .travis.yml ├── CMakeLists.txt ├── Doxyfile ├── LICENSE.md ├── README.md ├── documentation ├── api_notes.md ├── building.md ├── debug_node_plugin.md ├── doxygen │ ├── DoxygenLayout.xml │ ├── customdoxygen.css │ ├── footer.html │ ├── header.html │ └── images │ │ └── viz.png ├── git_guildelines.md ├── plugin.md ├── testing.md └── testnet.md ├── libraries ├── CMakeLists.txt ├── api │ ├── CMakeLists.txt │ ├── account_api_object.cpp │ ├── chain_api_properties.cpp │ ├── committee_api_object.cpp │ ├── content_api_object.cpp │ ├── discussion_helper.cpp │ ├── include │ │ └── graphene │ │ │ └── api │ │ │ ├── account_api_object.hpp │ │ │ ├── account_vote.hpp │ │ │ ├── chain_api_properties.hpp │ │ │ ├── committee_api_object.hpp │ │ │ ├── content_api_object.hpp │ │ │ ├── discussion.hpp │ │ │ ├── discussion_helper.hpp │ │ │ ├── invite_api_object.hpp │ │ │ ├── paid_subscription_api_object.hpp │ │ │ ├── vote_state.hpp │ │ │ └── witness_api_object.hpp │ ├── invite_api_object.cpp │ ├── paid_subscription_api_object.cpp │ └── witness_api_object.cpp ├── chain │ ├── CMakeLists.txt │ ├── block_log.cpp │ ├── chain_evaluator.cpp │ ├── chain_objects.cpp │ ├── chain_properties_evaluators.cpp │ ├── committee_evaluator.cpp │ ├── database.cpp │ ├── database_proposal_object.cpp │ ├── fork_database.cpp │ ├── hardfork.d │ │ ├── 0-preamble.hf │ │ ├── 1.hf │ │ ├── 10.hf │ │ ├── 11.hf │ │ ├── 2.hf │ │ ├── 3.hf │ │ ├── 4.hf │ │ ├── 5.hf │ │ ├── 6.hf │ │ ├── 7.hf │ │ ├── 8.hf │ │ └── 9.hf │ ├── include │ │ └── graphene │ │ │ └── chain │ │ │ ├── account_object.hpp │ │ │ ├── block_log.hpp │ │ │ ├── block_summary_object.hpp │ │ │ ├── chain_evaluator.hpp │ │ │ ├── chain_object_types.hpp │ │ │ ├── chain_objects.hpp │ │ │ ├── committee_objects.hpp │ │ │ ├── compound.hpp │ │ │ ├── content_object.hpp │ │ │ ├── custom_operation_interpreter.hpp │ │ │ ├── database.hpp │ │ │ ├── database_exceptions.hpp │ │ │ ├── db_with.hpp │ │ │ ├── evaluator.hpp │ │ │ ├── evaluator_registry.hpp │ │ │ ├── fork_database.hpp │ │ │ ├── generic_custom_operation_interpreter.hpp │ │ │ ├── global_property_object.hpp │ │ │ ├── immutable_chain_parameters.hpp │ │ │ ├── index.hpp │ │ │ ├── invite_objects.hpp │ │ │ ├── node_property_object.hpp │ │ │ ├── operation_notification.hpp │ │ │ ├── paid_subscription_objects.hpp │ │ │ ├── proposal_object.hpp │ │ │ ├── shared_authority.hpp │ │ │ ├── shared_db_merkle.hpp │ │ │ ├── transaction_object.hpp │ │ │ └── witness_objects.hpp │ ├── invite_evaluator.cpp │ ├── paid_subscription_evaluator.cpp │ ├── proposal_evaluator.cpp │ ├── proposal_object.cpp │ ├── shared_authority.cpp │ └── transaction_object.cpp ├── network │ ├── CMakeLists.txt │ ├── core_messages.cpp │ ├── include │ │ └── graphene │ │ │ └── network │ │ │ ├── config.hpp │ │ │ ├── core_messages.hpp │ │ │ ├── exceptions.hpp │ │ │ ├── message.hpp │ │ │ ├── message_oriented_connection.hpp │ │ │ ├── node.hpp │ │ │ ├── peer_connection.hpp │ │ │ ├── peer_database.hpp │ │ │ └── stcp_socket.hpp │ ├── message_oriented_connection.cpp │ ├── node.cpp │ ├── peer_connection.cpp │ ├── peer_database.cpp │ └── stcp_socket.cpp ├── protocol │ ├── CMakeLists.txt │ ├── asset.cpp │ ├── authority.cpp │ ├── block.cpp │ ├── chain_operations.cpp │ ├── get_config.cpp │ ├── include │ │ └── graphene │ │ │ └── protocol │ │ │ ├── README.md │ │ │ ├── asset.hpp │ │ │ ├── authority.hpp │ │ │ ├── base.hpp │ │ │ ├── block.hpp │ │ │ ├── block_header.hpp │ │ │ ├── chain_operations.hpp │ │ │ ├── chain_virtual_operations.hpp │ │ │ ├── config.hpp │ │ │ ├── config_testnet.hpp │ │ │ ├── exceptions.hpp │ │ │ ├── get_config.hpp │ │ │ ├── operation_util.hpp │ │ │ ├── operation_util_impl.hpp │ │ │ ├── operations.hpp │ │ │ ├── proposal_operations.hpp │ │ │ ├── protocol.hpp │ │ │ ├── sign_state.hpp │ │ │ ├── transaction.hpp │ │ │ ├── types.hpp │ │ │ └── version.hpp │ ├── operation_util_impl.cpp │ ├── operations.cpp │ ├── proposal_operations.cpp │ ├── sign_state.cpp │ ├── transaction.cpp │ ├── types.cpp │ └── version.cpp ├── time │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── time │ │ │ └── time.hpp │ └── time.cpp ├── utilities │ ├── CMakeLists.txt │ ├── git_revision.cpp.in │ ├── include │ │ └── graphene │ │ │ └── utilities │ │ │ ├── git_revision.hpp │ │ │ ├── key_conversion.hpp │ │ │ ├── padding_ostream.hpp │ │ │ ├── string_escape.hpp │ │ │ ├── tempdir.hpp │ │ │ └── words.hpp │ ├── key_conversion.cpp │ ├── string_escape.cpp │ ├── tempdir.cpp │ └── words.cpp └── wallet │ ├── CMakeLists.txt │ ├── Doxyfile.in │ ├── api_documentation_standin.cpp │ ├── generate_api_documentation.pl │ ├── include │ └── graphene │ │ └── wallet │ │ ├── api_documentation.hpp │ │ ├── reflect_util.hpp │ │ ├── remote_node_api.hpp │ │ └── wallet.hpp │ └── wallet.cpp ├── plugins ├── CMakeLists.txt ├── account_by_key │ ├── CMakeLists.txt │ ├── account_by_key_plugin.cpp │ └── include │ │ └── graphene │ │ └── plugins │ │ └── account_by_key │ │ ├── account_by_key_objects.hpp │ │ └── account_by_key_plugin.hpp ├── account_history │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── account_history │ │ │ ├── history_object.hpp │ │ │ └── plugin.hpp │ └── plugin.cpp ├── auth_util │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── auth_util │ │ │ └── plugin.hpp │ └── plugin.cpp ├── block_info │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── block_info │ │ │ ├── block_info.hpp │ │ │ └── plugin.hpp │ └── plugin.cpp ├── chain │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── chain │ │ │ └── plugin.hpp │ └── plugin.cpp ├── committee_api │ ├── CMakeLists.txt │ ├── committee_api.cpp │ └── include │ │ └── graphene │ │ └── plugins │ │ └── committee_api │ │ └── committee_api.hpp ├── custom_protocol_api │ ├── CMakeLists.txt │ ├── custom_protocol_api.cpp │ ├── custom_protocol_api_visitor.cpp │ └── include │ │ └── graphene │ │ └── plugins │ │ └── custom_protocol_api │ │ ├── custom_protocol_api.hpp │ │ ├── custom_protocol_api_object.hpp │ │ └── custom_protocol_api_visitor.hpp ├── database_api │ ├── CMakeLists.txt │ ├── api.cpp │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── database_api │ │ │ ├── api_objects │ │ │ ├── account_recovery_request_api_object.hpp │ │ │ ├── master_authority_history_api_object.hpp │ │ │ └── proposal_api_object.hpp │ │ │ ├── forward.hpp │ │ │ ├── plugin.hpp │ │ │ └── state.hpp │ └── proposal_api_object.cpp ├── debug_node │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── debug_node │ │ │ ├── api_helper.hpp │ │ │ └── plugin.hpp │ └── plugin.cpp ├── follow │ ├── CMakeLists.txt │ ├── follow_evaluators.cpp │ ├── follow_operations.cpp │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── follow │ │ │ ├── follow_api_object.hpp │ │ │ ├── follow_evaluators.hpp │ │ │ ├── follow_forward.hpp │ │ │ ├── follow_objects.hpp │ │ │ ├── follow_operations.hpp │ │ │ └── plugin.hpp │ └── plugin.cpp ├── invite_api │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── invite_api │ │ │ └── invite_api.hpp │ └── invite_api.cpp ├── json_rpc │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── json_rpc │ │ │ ├── plugin.hpp │ │ │ └── utility.hpp │ └── plugin.cpp ├── mongo_db │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── mongo_db │ │ │ ├── mongo_db_operations.hpp │ │ │ ├── mongo_db_plugin.hpp │ │ │ ├── mongo_db_state.hpp │ │ │ ├── mongo_db_types.hpp │ │ │ └── mongo_db_writer.hpp │ ├── mongo_db_operations.cpp │ ├── mongo_db_plugin.cpp │ ├── mongo_db_state.cpp │ ├── mongo_db_types.cpp │ └── mongo_db_writer.cpp ├── network_broadcast_api │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── network_broadcast_api │ │ │ └── network_broadcast_api_plugin.hpp │ └── network_broadcast_api.cpp ├── operation_history │ ├── CMakeLists.txt │ ├── applied_operation.cpp │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── operation_history │ │ │ ├── applied_operation.hpp │ │ │ ├── history_object.hpp │ │ │ └── plugin.hpp │ └── plugin.cpp ├── p2p │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── p2p │ │ │ └── p2p_plugin.hpp │ └── p2p_plugin.cpp ├── paid_subscription_api │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── paid_subscription_api │ │ │ └── paid_subscription_api.hpp │ └── paid_subscription_api.cpp ├── private_message │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── private_message │ │ │ ├── private_message_evaluators.hpp │ │ │ ├── private_message_objects.hpp │ │ │ └── private_message_plugin.hpp │ ├── private_message_objects.cpp │ └── private_message_plugin.cpp ├── raw_block │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── raw_block │ │ │ └── plugin.hpp │ └── plugin.cpp ├── social_network │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── social_network │ │ │ └── social_network.hpp │ └── social_network.cpp ├── tags │ ├── CMakeLists.txt │ ├── discussion_query.cpp │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── tags │ │ │ ├── discussion_query.hpp │ │ │ ├── plugin.hpp │ │ │ ├── tag_api_object.hpp │ │ │ ├── tag_visitor.hpp │ │ │ ├── tags_object.hpp │ │ │ └── tags_sort.hpp │ ├── plugin.cpp │ └── tag_visitor.cpp ├── test_api │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── test_api │ │ │ └── test_api_plugin.hpp │ └── test_api_plugin.cpp ├── webserver │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── webserver │ │ │ └── webserver_plugin.hpp │ └── webserver_plugin.cpp ├── witness │ ├── CMakeLists.txt │ ├── include │ │ └── graphene │ │ │ └── plugins │ │ │ └── witness │ │ │ └── witness.hpp │ └── witness.cpp └── witness_api │ ├── CMakeLists.txt │ ├── include │ └── graphene │ │ └── plugins │ │ └── witness_api │ │ ├── api_objects │ │ ├── feed_history_api_object.hpp │ │ └── witness_api_object.hpp │ │ └── plugin.hpp │ └── plugin.cpp ├── programs ├── CMakeLists.txt ├── build_helpers │ ├── CMakeLists.txt │ ├── cat-parts.cpp │ ├── cat_parts.py │ ├── check_reflect.py │ └── configure_build.py ├── cli_wallet │ ├── CMakeLists.txt │ └── main.cpp ├── js_operation_serializer │ ├── CMakeLists.txt │ └── main.cpp ├── size_checker │ ├── CMakeLists.txt │ └── main.cpp ├── util │ ├── CMakeLists.txt │ ├── get_dev_key.cpp │ ├── inflation_plot.py │ ├── newplugin.py │ ├── pretty_schema.py │ ├── saltpass.py │ ├── schema_test.cpp │ ├── sign_digest.cpp │ ├── sign_transaction.cpp │ ├── test_block_log.cpp │ └── test_shared_mem.cpp └── vizd │ ├── CMakeLists.txt │ └── main.cpp ├── share └── vizd │ ├── config │ ├── config.ini │ ├── config_debug.ini │ ├── config_debug_mongo.ini │ ├── config_mongo.ini │ ├── config_stock_exchange.ini │ ├── config_testnet.ini │ └── config_witness.ini │ ├── docker │ ├── Dockerfile-lowmem │ ├── Dockerfile-mongo │ ├── Dockerfile-production │ └── Dockerfile-testnet │ ├── seednodes │ ├── seednodes_empty │ ├── snapshot-testnet.json │ ├── snapshot.json │ └── vizd.sh └── thirdparty └── CMakeLists.txt /.github/workflows/docker-main.yml: -------------------------------------------------------------------------------- 1 | name: Build docker images 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | paths-ignore: 8 | - 'documentation/**' 9 | - '**.md' 10 | 11 | jobs: 12 | build_testnet: 13 | name: Build testnet image 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | 19 | - uses: docker/build-push-action@v1 20 | with: 21 | username: ${{ secrets.DOCKER_USERNAME }} 22 | password: ${{ secrets.DOCKER_PASSWORD }} 23 | repository: vizblockchain/vizd 24 | dockerfile: ./share/vizd/docker/Dockerfile-testnet 25 | tags: testnet 26 | 27 | build_prod: 28 | name: Build production image 29 | runs-on: ubuntu-latest 30 | 31 | steps: 32 | - uses: actions/checkout@v2 33 | 34 | - uses: docker/build-push-action@v1 35 | with: 36 | username: ${{ secrets.DOCKER_USERNAME }} 37 | password: ${{ secrets.DOCKER_PASSWORD }} 38 | repository: vizblockchain/vizd 39 | dockerfile: ./share/vizd/docker/Dockerfile-production 40 | tags: latest 41 | -------------------------------------------------------------------------------- /.github/workflows/docker-pr-build.yml: -------------------------------------------------------------------------------- 1 | name: Build testnet docker image for a PR 2 | 3 | on: 4 | pull_request: 5 | paths-ignore: 6 | - 'documentation/**' 7 | - '**.md' 8 | 9 | jobs: 10 | build_testnet: 11 | name: Build and push Docker image to Docker Hub 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | 17 | - uses: docker/build-push-action@v1 18 | with: 19 | username: ${{ secrets.DOCKER_USERNAME }} 20 | password: ${{ secrets.DOCKER_PASSWORD }} 21 | repository: vizblockchain/vizd 22 | dockerfile: ./share/vizd/docker/Dockerfile-testnet 23 | tag_with_ref: true 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.a 2 | *.so 3 | *.dylib 4 | *.sw* 5 | 6 | *.cmake 7 | CMakeCache.txt 8 | CMakeFiles 9 | Makefile 10 | compile_commands.json 11 | moc_* 12 | *.moc 13 | hardfork.hpp 14 | 15 | lcov 16 | 17 | libraries/utilities/git_revision.cpp 18 | 19 | libraries/wallet/Doxyfile 20 | libraries/wallet/api_documentation.cpp 21 | libraries/wallet/doxygen 22 | 23 | programs/cli_wallet/cli_wallet 24 | programs/js_operation_serializer/js_operation_serializer 25 | programs/vizd/vizd 26 | programs/vizd/test 27 | programs/delayed_node 28 | programs/build_helpers/cat-parts 29 | programs/size_checker/size_checker 30 | programs/util/get_dev_key 31 | programs/util/inflation_model 32 | 33 | tests/app_test 34 | tests/chain_bench 35 | tests/chain_test 36 | tests/plugin_test 37 | tests/intense_test 38 | tests/performance_test 39 | 40 | wallet.json 41 | witness_node_data_dir 42 | 43 | *.wallet 44 | 45 | documentation/doxygen/html 46 | documentation/doxygen/xml 47 | documentation/doxygen/latex 48 | 49 | *.pyc 50 | *.pyo 51 | *.egg-info/ 52 | build -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "thirdparty/fc"] 2 | path = thirdparty/fc 3 | url = https://github.com/VIZ-Blockchain/fc.git 4 | branch = update 5 | [submodule "thirdparty/chainbase"] 6 | path = thirdparty/chainbase 7 | url = https://github.com/VIZ-Blockchain/chainbase.git 8 | [submodule "thirdparty/appbase"] 9 | path = thirdparty/appbase 10 | url = https://github.com/VIZ-Blockchain/appbase.git 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | 3 | language: cpp 4 | 5 | services: 6 | - docker 7 | 8 | before_install: 9 | - echo "$TRAVIS_TAG" 10 | - echo "$TRAVIS_BRANCH" 11 | 12 | env: 13 | - DOCKERFILE=Dockerfile DOCKERNAME="" 14 | - DOCKERFILE=share/vizd/docker/Dockerfile-test DOCKERNAME="-test" 15 | - DOCKERFILE=share/vizd/docker/Dockerfile-testnet DOCKERNAME="-testnet" 16 | - DOCKERFILE=share/vizd/docker/Dockerfile-lowmem DOCKERNAME="-lowmem" 17 | - DOCKERFILE=share/vizd/docker/Dockerfile-mongo DOCKERNAME="-mongo" 18 | 19 | matrix: 20 | fast_finish: true 21 | 22 | script: 23 | - if [ "$TRAVIS_BRANCH" == "master" ]; then 24 | export DOCKERNAME="latest""$DOCKERNAME"; 25 | export EXPORTNAME="$DOCKERNAME"; 26 | elif [ -n "$TRAVIS_TAG" ]; then 27 | export DOCKERNAME="$TRAVIS_TAG""$DOCKERNAME"; 28 | export EXPORTNAME="$DOCKERNAME"; 29 | else 30 | export DOCKERNAME=develop"$DOCKERNAME"; 31 | fi 32 | - echo "$DOCKERFILE" 33 | - echo "$DOCKERNAME" 34 | - docker build -t viz-world/viz-world:"$DOCKERNAME" -f "$DOCKERFILE" . 35 | 36 | after_success: 37 | - echo "$EXPORTNAME" 38 | - docker images 39 | - if [ -n "$EXPORTNAME" ]; then 40 | docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"; 41 | docker push viz-world/viz-world:"$EXPORTNAME"; 42 | fi 43 | - if [ "$TRAVIS_BRANCH" == "master" -a "$EXPORTNAME" == "latest" ]; then 44 | bash deploy/deploy.sh; 45 | fi 46 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 VIZ-Blockchain, and contributors. 2 | 3 | The following license applies to code contained within this repository that 4 | is created by VIZ-Blockchain. Other copyright holders have licensed dependencies 5 | such as Graphene, FC, and Boost under their own individual licenses. 6 | 7 | The MIT License 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Introducing VIZ 2 | 3 | ![Build docker images](https://github.com/VIZ-Blockchain/viz-cpp-node/workflows/Build%20docker%20images/badge.svg) 4 | 5 | VIZ is a Graphene blockchain with a Fair-DPOS consensus algorithm (vote weight splitted to selected witnesses, witness gets a penalty for missing a block). 6 | 7 | ## Building 8 | 9 | See [documentation/building.md](documentation/building.md) for detailed build instructions, including 10 | compile-time options, and specific commands for Linux (Ubuntu LTS) or macOS X. 11 | 12 | ## Running in docker 13 | 14 | Auto-built image [vizblockchain/vizd](https://hub.docker.com/r/vizblockchain/vizd) is available at docker hub. 15 | 16 | Docker image tags: 17 | 18 | * **latest** - built from master branch, used to run production VIZ network 19 | * **testnet** - built from master branch, could be used to run [local test network](documentation/testnet.md) 20 | 21 | Example run: 22 | 23 | ``` 24 | docker run \ 25 | -d -p 2001:2001 -p 8090:8090 -p 8091:8091 --name vizd \ 26 | vizblockchain/vizd:latest 27 | 28 | docker logs -f vizd 29 | ``` 30 | 31 | ## Seed Nodes 32 | 33 | A list of some seed nodes to get you started can be found in 34 | [share/vizd/seednodes](share/vizd/seednodes). 35 | 36 | This same file is baked into the docker images and can be overridden by 37 | setting `VIZD_SEED_NODES` in the container environment at `docker run` 38 | time to a whitespace delimited list of seed nodes (with port). 39 | 40 | ## Building docker images manually 41 | 42 | Production: 43 | 44 | ``` 45 | docker build -t viz:latest -f share/vizd/docker/Dockerfile-production . 46 | ``` 47 | 48 | Testnet + keep intermediate build containers for debugging: 49 | 50 | ``` 51 | docker build --rm=false -t viz:testnet -f share/vizd/docker/Dockerfile-testnet . 52 | ``` 53 | -------------------------------------------------------------------------------- /documentation/doxygen/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | 16 | 17 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /documentation/doxygen/images/viz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIZ-Blockchain/viz-cpp-node/786afa351fb24bfa7353578bdf6a88e5687ee8ca/documentation/doxygen/images/viz.png -------------------------------------------------------------------------------- /documentation/plugin.md: -------------------------------------------------------------------------------- 1 | 2 | How plugins work 3 | ---------------- 4 | 5 | All plugins in the `libraries/plugins` directory are iterated over by `CMakeLists.txt` and placed in a CMake environment variable `CHAIN_INTERNAL_PLUGINS`, which is used to create a runtime-accessible list of available plugins used by the argument parsing. 6 | 7 | Similarly, `external_plugins` is set aside for third-party plugins. Just drop plugin code into `external_plugins` directory, `make vizd`, and the new plugin will be available. 8 | 9 | There is a plugin in `example_plugins` called `hello_api` which is a working example of adding a custom API call. 10 | 11 | Registering plugins 12 | ------------------- 13 | 14 | - Plugins are enabled with the `enable-plugin` config file option. 15 | - When specifying plugins, you should specify `witness` and `account_history` in addition to the new plugins. 16 | - Some plugins may keep records in the database (currently only `account_history` does). If you change whether such a plugin is disabled/enabled, you should also replay the chain. Detecting this situation and automatically replaying when needed will be implemented in a future release. 17 | - If you want to make API's available publicly, you must use the `public-api` option. 18 | - When specifying public API's, you should specify `database_api` and `login_api` in addition to the new plugins. 19 | - The `api-user` option allows for password protected access to an API. 20 | 21 | Autogenerating code 22 | ------------------- 23 | 24 | A skeleton structure containing much of the boilerplate of creating a new plugin with an API can be autogenerated by running `programs/util/newplugin.py`. 25 | 26 | - Register signal handlers in `plugin_startup()` (if needed) 27 | - Add methods to `myplugin_api` class and reflect them in `FC_API` declaration 28 | -------------------------------------------------------------------------------- /documentation/testing.md: -------------------------------------------------------------------------------- 1 | # Testing 2 | 3 | The unit test target is `make chain_test` 4 | This creates an executable `./tests/chain_test` that will run all unit tests. 5 | 6 | Tests are broken in several categories: 7 | ``` 8 | basic_tests // Tests of "basic" functionality 9 | block_tests // Tests of the block chain 10 | live_tests // Tests on live chain data (currently only past hardfork testing) 11 | operation_tests // Unit Tests of operations 12 | operation_time_tests // Tests of operations that include a time based component (ex. vesting withdrawals) 13 | serialization_tests // Tests related of serialization 14 | ``` 15 | 16 | ## Configuration (draft) 17 | 18 | Some config options: 19 | * `log_level` — allows setting the log level. Available values: `all`, `success`, `test_suite`, `message`, `warning`, . `error`, `cpp_exception`, `system_error`, `fatal_error`, `nothing`. Sample usage: `--log-level=test_suite` 20 | * `report_level` — allows setting the level of detailization for the testing results report. Available values: `no`, `confirm`, `short`, `detailed`. Sample usage: `--report_level=detailed` 21 | * `run_test` — specifies which test units to run. You can specify individual test (separated with comma) or test cases. Sample usage: `--run_test=operation_tests/delegation` 22 | 23 | For more info about runtime config check [Boost.Tests documentation](https://www.boost.org/doc/libs/1_58_0/libs/test/doc/html/utf/user-guide/runtime-config/reference.html). 24 | 25 | 26 | # Code Coverage Testing 27 | 28 | If you have not done so, install lcov `brew install lcov` 29 | 30 | ``` 31 | cmake -D ENABLE_COVERAGE_TESTING=true -D CMAKE_BUILD_TYPE=Debug . 32 | make 33 | lcov --capture --initial --directory . --output-file base.info --no-external 34 | tests/chain_test 35 | lcov --capture --directory . --output-file test.info --no-external 36 | lcov --add-tracefile base.info --add-tracefile test.info --output-file total.info 37 | lcov -o interesting.info -r total.info tests/\* 38 | mkdir -p lcov 39 | genhtml interesting.info --output-directory lcov --prefix `pwd` 40 | ``` 41 | 42 | Now open `lcov/index.html` in a browser 43 | -------------------------------------------------------------------------------- /documentation/testnet.md: -------------------------------------------------------------------------------- 1 | # How to run a test network 2 | 3 | When viz node starts without seed nodes, it tries to open a *snapshot.json* file which holds data on initial users and their balances. 4 | If found, liquid tokens are transferred from `CHAIN_INITIATOR_NAME` account to users accounts into vesting (shares). 5 | 6 | Initial users and their keys are defined inside *libraries/protocol/include/graphene/protocol/config.hpp* 7 | 8 | * `CHAIN_INITIATOR_NAME` ("viz") is a user which holds initial balance. 9 | * `CHAIN_COMMITTEE_ACCOUNT` is an initial active witness. 10 | 11 | *viz* keys: 12 | 13 | * private: 5JabcrvaLnBTCkCVFX5r4rmeGGfuJuVp4NAKRNLTey6pxhRQmf4 14 | * public: VIZ6MyX5QiXAXRZk7SYCiqpi6Mtm8UbHWDFSV8HPpt7FJyahCnc2T 15 | 16 | *committee* keys: 17 | 18 | * private: 5Hw9YPABaFxa2LooiANLrhUK5TPryy8f7v9Y1rk923PuYqbYdfC 19 | * public: VIZ6Yt7d6LsngBoXQr47aLv97bJVs7jyr7esZTM4UUSpLUf3nbRKS 20 | 21 | ## Launch 22 | 23 | To run a testnet node, please use [Docker](https://docs.docker.com/engine/install/). 24 | 25 | To build image locally, use Dockerfile-testnet: 26 | 27 | ``` 28 | docker build -t viz:testnet -f share/vizd/docker/Dockerfile-testnet . 29 | docker run -d --name vizd viz:testnet 30 | docker logs --tail 100 -f vizd 31 | ``` 32 | 33 | To use pre-built image, run node with 34 | 35 | ``` 36 | docker run -d --name vizd vizblockchain/vizd:testnet 37 | ``` 38 | 39 | ## Additional users 40 | 41 | To ease testing, several additional users are immediately available: 42 | 43 | * alice 44 | * bob 45 | * charlie 46 | * chuck 47 | * dan 48 | * frank 49 | 50 | All users have the same keys: 51 | 52 | * private: 5J9DBCRX5D2ZUUuy9qV2ef9p5sfA3ydHsDs2G531bob7wbEigDJ 53 | * public: VIZ5zTAE2hiGcqYaDTQeEBqTtPeoWtSNjpznwmbvqJXesrK1Qn3e8 54 | -------------------------------------------------------------------------------- /libraries/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(api) 2 | add_subdirectory(chain) 3 | add_subdirectory(protocol) 4 | add_subdirectory(network) 5 | add_subdirectory(time) 6 | add_subdirectory(utilities) 7 | add_subdirectory(wallet) 8 | -------------------------------------------------------------------------------- /libraries/api/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET api) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/api/account_api_object.hpp 5 | include/graphene/api/content_api_object.hpp 6 | include/graphene/api/chain_api_properties.hpp 7 | include/graphene/api/witness_api_object.hpp 8 | include/graphene/api/discussion.hpp 9 | include/graphene/api/vote_state.hpp 10 | include/graphene/api/account_vote.hpp 11 | include/graphene/api/discussion_helper.hpp 12 | include/graphene/api/committee_api_object.hpp 13 | include/graphene/api/invite_api_object.hpp 14 | include/graphene/api/paid_subscription_api_object.hpp 15 | ) 16 | 17 | list(APPEND CURRENT_TARGET_SOURCES 18 | account_api_object.cpp 19 | discussion_helper.cpp 20 | content_api_object.cpp 21 | chain_api_properties.cpp 22 | witness_api_object.cpp 23 | committee_api_object.cpp 24 | invite_api_object.cpp 25 | paid_subscription_api_object.cpp 26 | ) 27 | 28 | if(BUILD_SHARED_LIBRARIES) 29 | add_library(graphene_${CURRENT_TARGET} SHARED 30 | ${CURRENT_TARGET_HEADERS} 31 | ${CURRENT_TARGET_SOURCES} 32 | ) 33 | else() 34 | add_library(graphene_${CURRENT_TARGET} STATIC 35 | ${CURRENT_TARGET_HEADERS} 36 | ${CURRENT_TARGET_SOURCES} 37 | ) 38 | endif() 39 | 40 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 41 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 42 | 43 | target_link_libraries( 44 | graphene_${CURRENT_TARGET} 45 | graphene_chain 46 | graphene_protocol 47 | graphene_utilities 48 | fc 49 | ) 50 | 51 | target_include_directories(graphene_${CURRENT_TARGET} 52 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") 53 | 54 | install(TARGETS 55 | graphene_${CURRENT_TARGET} 56 | 57 | RUNTIME DESTINATION bin 58 | LIBRARY DESTINATION lib 59 | ARCHIVE DESTINATION lib 60 | ) -------------------------------------------------------------------------------- /libraries/api/chain_api_properties.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace graphene { namespace api { 4 | 5 | chain_api_properties::chain_api_properties( 6 | const chain_properties& src, 7 | const database& db 8 | ) : account_creation_fee(src.account_creation_fee), 9 | maximum_block_size(src.maximum_block_size), 10 | create_account_delegation_ratio(src.create_account_delegation_ratio), 11 | create_account_delegation_time(src.create_account_delegation_time), 12 | min_delegation(src.min_delegation), 13 | min_curation_percent(src.min_curation_percent), 14 | max_curation_percent(src.max_curation_percent), 15 | bandwidth_reserve_percent(src.bandwidth_reserve_percent), 16 | bandwidth_reserve_below(src.bandwidth_reserve_below), 17 | flag_energy_additional_cost(src.flag_energy_additional_cost), 18 | vote_accounting_min_rshares(src.vote_accounting_min_rshares), 19 | committee_request_approve_min_percent(src.committee_request_approve_min_percent) 20 | { 21 | if (db.has_hardfork(CHAIN_HARDFORK_4)) { 22 | inflation_witness_percent=src.inflation_witness_percent; 23 | inflation_ratio_committee_vs_reward_fund=src.inflation_ratio_committee_vs_reward_fund; 24 | inflation_recalc_period=src.inflation_recalc_period; 25 | } 26 | if (db.has_hardfork(CHAIN_HARDFORK_6)) { 27 | data_operations_cost_additional_bandwidth=src.data_operations_cost_additional_bandwidth; 28 | witness_miss_penalty_percent=src.witness_miss_penalty_percent; 29 | witness_miss_penalty_duration=src.witness_miss_penalty_duration; 30 | } 31 | if (db.has_hardfork(CHAIN_HARDFORK_9)) { 32 | create_invite_min_balance=src.create_invite_min_balance; 33 | committee_create_request_fee=src.committee_create_request_fee; 34 | create_paid_subscription_fee=src.create_paid_subscription_fee; 35 | account_on_sale_fee=src.account_on_sale_fee; 36 | subaccount_on_sale_fee=src.subaccount_on_sale_fee; 37 | witness_declaration_fee=src.witness_declaration_fee; 38 | withdraw_intervals=src.withdraw_intervals; 39 | } 40 | } 41 | 42 | } } // graphene::api 43 | -------------------------------------------------------------------------------- /libraries/api/committee_api_object.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace graphene { namespace api { 4 | 5 | using namespace graphene::chain; 6 | using graphene::chain::committee_request_object; 7 | using graphene::chain::committee_vote_object; 8 | 9 | committee_vote_state::committee_vote_state(const graphene::chain::committee_vote_object &o) 10 | : voter(o.voter), 11 | vote_percent(o.vote_percent), 12 | last_update(o.last_update) { 13 | } 14 | 15 | committee_vote_state::committee_vote_state() = default; 16 | 17 | committee_api_object::committee_api_object(const graphene::chain::committee_request_object &o/*, const graphene::chain::database &db*/) 18 | : id(o.id), 19 | request_id(o.request_id), 20 | url(to_string(o.url)), 21 | creator(o.creator), 22 | worker(o.worker), 23 | required_amount_min(o.required_amount_min), 24 | required_amount_max(o.required_amount_max), 25 | start_time(o.start_time), 26 | duration(o.duration), 27 | end_time(o.end_time), 28 | status(o.status), 29 | votes_count(o.votes_count), 30 | conclusion_time(o.conclusion_time), 31 | conclusion_payout_amount(o.conclusion_payout_amount), 32 | payout_amount(o.payout_amount), 33 | remain_payout_amount(o.remain_payout_amount), 34 | last_payout_time(o.last_payout_time), 35 | payout_time(o.payout_time) { 36 | } 37 | 38 | committee_api_object::committee_api_object() = default; 39 | 40 | } } // graphene::api -------------------------------------------------------------------------------- /libraries/api/content_api_object.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace graphene { namespace api { 4 | 5 | using namespace graphene::chain; 6 | 7 | content_api_object::content_api_object(const graphene::chain::content_object &o, const graphene::chain::database &db) 8 | : id(o.id), 9 | parent_author(o.parent_author), 10 | parent_permlink(to_string(o.parent_permlink)), 11 | author(o.author), 12 | permlink(to_string(o.permlink)), 13 | last_update(o.last_update), 14 | created(o.created), 15 | active(o.active), 16 | last_payout(o.last_payout), 17 | depth(o.depth), 18 | children(o.children), 19 | children_rshares(o.children_rshares), 20 | net_rshares(o.net_rshares), 21 | abs_rshares(o.abs_rshares), 22 | vote_rshares(o.vote_rshares), 23 | cashout_time(o.cashout_time), 24 | total_vote_weight(o.total_vote_weight), 25 | curation_percent(o.curation_percent), 26 | consensus_curation_percent(o.consensus_curation_percent), 27 | payout_value(o.payout_value), 28 | shares_payout_value(o.shares_payout_value), 29 | curator_payout_value(o.curator_payout_value), 30 | beneficiary_payout_value(o.beneficiary_payout_value), 31 | author_rewards(o.author_rewards), 32 | net_votes(o.net_votes), 33 | root_content(o.root_content) { 34 | 35 | for (auto& route : o.beneficiaries) { 36 | beneficiaries.push_back(route); 37 | } 38 | #ifndef IS_LOW_MEM 39 | auto& content = db.get_content_type(o.id); 40 | 41 | title = to_string(content.title); 42 | body = to_string(content.body); 43 | json_metadata = to_string(content.json_metadata); 44 | #endif 45 | } 46 | 47 | content_api_object::content_api_object() = default; 48 | 49 | } } // graphene::api -------------------------------------------------------------------------------- /libraries/api/include/graphene/api/account_vote.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace graphene { namespace api { 7 | 8 | struct account_vote { 9 | std::string authorperm; 10 | uint64_t weight = 0; 11 | int64_t rshares = 0; 12 | int16_t percent = 0; 13 | fc::time_point_sec time; 14 | }; 15 | 16 | } } // graphene::api 17 | 18 | 19 | 20 | FC_REFLECT((graphene::api::account_vote), (authorperm)(weight)(rshares)(percent)(time)); -------------------------------------------------------------------------------- /libraries/api/include/graphene/api/chain_api_properties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace graphene { namespace api { 7 | using graphene::protocol::asset; 8 | using graphene::chain::chain_properties; 9 | using graphene::chain::database; 10 | 11 | struct chain_api_properties { 12 | chain_api_properties(const chain_properties&, const database&); 13 | chain_api_properties() = default; 14 | 15 | asset account_creation_fee; 16 | uint32_t maximum_block_size; 17 | 18 | uint32_t create_account_delegation_ratio; 19 | uint32_t create_account_delegation_time; 20 | asset min_delegation; 21 | int16_t min_curation_percent; 22 | int16_t max_curation_percent; 23 | int16_t bandwidth_reserve_percent; 24 | asset bandwidth_reserve_below; 25 | int16_t flag_energy_additional_cost; 26 | uint32_t vote_accounting_min_rshares; 27 | int16_t committee_request_approve_min_percent; 28 | 29 | fc::optional inflation_witness_percent; 30 | fc::optional inflation_ratio_committee_vs_reward_fund; 31 | fc::optional inflation_recalc_period; 32 | 33 | fc::optional data_operations_cost_additional_bandwidth; 34 | fc::optional witness_miss_penalty_percent; 35 | fc::optional witness_miss_penalty_duration; 36 | 37 | fc::optional create_invite_min_balance; 38 | fc::optional committee_create_request_fee; 39 | fc::optional create_paid_subscription_fee; 40 | fc::optional account_on_sale_fee; 41 | fc::optional subaccount_on_sale_fee; 42 | fc::optional witness_declaration_fee; 43 | fc::optional withdraw_intervals; 44 | }; 45 | 46 | } } // graphene::api 47 | 48 | FC_REFLECT( 49 | (graphene::api::chain_api_properties), 50 | (account_creation_fee)(maximum_block_size)(maximum_block_size) 51 | (create_account_delegation_ratio)(create_account_delegation_time)(min_delegation) 52 | (min_curation_percent)(max_curation_percent)(bandwidth_reserve_percent)(bandwidth_reserve_below) 53 | (flag_energy_additional_cost)(vote_accounting_min_rshares)(committee_request_approve_min_percent) 54 | (inflation_witness_percent)(inflation_ratio_committee_vs_reward_fund)(inflation_recalc_period) 55 | (data_operations_cost_additional_bandwidth)(witness_miss_penalty_percent)(witness_miss_penalty_duration) 56 | (create_invite_min_balance)(committee_create_request_fee)(create_paid_subscription_fee) 57 | (account_on_sale_fee)(subaccount_on_sale_fee)(witness_declaration_fee)(withdraw_intervals)) -------------------------------------------------------------------------------- /libraries/api/include/graphene/api/committee_api_object.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CHAIN_COMMITTEE_API_OBJ_H 2 | #define CHAIN_COMMITTEE_API_OBJ_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace graphene { namespace api { 9 | 10 | using namespace graphene::chain; 11 | using graphene::chain::committee_request_object; 12 | using graphene::chain::committee_vote_object; 13 | 14 | struct committee_vote_state { 15 | committee_vote_state(const committee_vote_object &o); 16 | committee_vote_state(); 17 | 18 | account_name_type voter; 19 | int16_t vote_percent = 0; 20 | time_point_sec last_update; 21 | }; 22 | 23 | struct committee_api_object { 24 | committee_api_object(const committee_request_object &o/*, const database &db*/); 25 | committee_api_object(); 26 | 27 | committee_request_object::id_type id; 28 | 29 | uint32_t request_id; 30 | 31 | std::string url; 32 | account_name_type creator; 33 | account_name_type worker; 34 | 35 | protocol::asset required_amount_min; 36 | protocol::asset required_amount_max; 37 | 38 | time_point_sec start_time; 39 | uint32_t duration; 40 | time_point_sec end_time; 41 | uint16_t status; 42 | uint32_t votes_count; 43 | time_point_sec conclusion_time; 44 | protocol::asset conclusion_payout_amount; 45 | protocol::asset payout_amount; 46 | protocol::asset remain_payout_amount; 47 | time_point_sec last_payout_time; 48 | time_point_sec payout_time; 49 | 50 | std::vector votes; 51 | }; 52 | } } // graphene::api 53 | 54 | FC_REFLECT((graphene::api::committee_vote_state),(voter)(vote_percent)(last_update)); 55 | 56 | FC_REFLECT( 57 | (graphene::api::committee_api_object), 58 | (id)(request_id)(url)(creator)(worker)(required_amount_min)(required_amount_max) 59 | (start_time)(duration)(end_time)(status)(votes_count)(conclusion_time)(conclusion_payout_amount) 60 | (payout_amount)(remain_payout_amount)(last_payout_time)(payout_time)(votes)) 61 | 62 | #endif //CHAIN_COMMITTEE_API_OBJ_H 63 | -------------------------------------------------------------------------------- /libraries/api/include/graphene/api/content_api_object.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CHAIN_COMMENT_API_OBJ_H 2 | #define CHAIN_COMMENT_API_OBJ_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace graphene { namespace api { 9 | 10 | using namespace graphene::chain; 11 | 12 | struct content_api_object { 13 | content_api_object(const content_object &o, const database &db); 14 | content_api_object(); 15 | 16 | content_object::id_type id; 17 | 18 | std::string title; 19 | std::string body; 20 | std::string json_metadata; 21 | 22 | account_name_type parent_author; 23 | std::string parent_permlink; 24 | account_name_type author; 25 | std::string permlink; 26 | 27 | time_point_sec last_update; 28 | time_point_sec created; 29 | time_point_sec active; 30 | time_point_sec last_payout; 31 | 32 | uint8_t depth; 33 | uint32_t children; 34 | 35 | uint128_t children_rshares; 36 | 37 | share_type net_rshares; 38 | share_type abs_rshares; 39 | share_type vote_rshares; 40 | 41 | time_point_sec cashout_time; 42 | uint64_t total_vote_weight; 43 | int16_t curation_percent; 44 | int16_t consensus_curation_percent; 45 | 46 | protocol::asset payout_value; 47 | protocol::asset shares_payout_value; 48 | protocol::asset curator_payout_value; 49 | protocol::asset beneficiary_payout_value; 50 | 51 | share_type author_rewards; 52 | 53 | int32_t net_votes; 54 | 55 | content_object::id_type root_content; 56 | 57 | vector< protocol::beneficiary_route_type > beneficiaries; 58 | }; 59 | 60 | } } // graphene::api 61 | 62 | FC_REFLECT( 63 | (graphene::api::content_api_object), 64 | (id)(author)(permlink)(parent_author)(parent_permlink)(title)(body)(json_metadata)(last_update) 65 | (created)(active)(last_payout)(depth)(children)(children_rshares)(net_rshares)(abs_rshares) 66 | (vote_rshares)(cashout_time)(total_vote_weight)(curation_percent)(consensus_curation_percent) 67 | (payout_value)(shares_payout_value)(curator_payout_value)(beneficiary_payout_value)(author_rewards)(net_votes) 68 | (root_content)(beneficiaries)) 69 | 70 | #endif //CHAIN_COMMENT_API_OBJ_H 71 | -------------------------------------------------------------------------------- /libraries/api/include/graphene/api/discussion.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | 7 | namespace graphene { namespace api { 8 | 9 | struct discussion : public content_api_object { 10 | discussion(const content_object& o, const graphene::chain::database &db) 11 | : content_api_object(o, db) { 12 | } 13 | 14 | discussion() { 15 | } 16 | 17 | string url; /// /@rootauthor/root_permlink#author/permlink 18 | string root_title; 19 | asset pending_payout_value = asset(0, TOKEN_SYMBOL); 20 | asset total_pending_payout_value = asset(0, TOKEN_SYMBOL); /// including replies 21 | std::vector active_votes; 22 | uint32_t active_votes_count = 0; 23 | std::vector replies; ///< author/slug mapping 24 | double hot = 0; 25 | double trending = 0; 26 | std::vector reblogged_by; 27 | optional first_reblogged_by; 28 | optional first_reblogged_on; 29 | }; 30 | 31 | } } // graphene::api 32 | 33 | FC_REFLECT_DERIVED( (graphene::api::discussion), ((graphene::api::content_api_object)), 34 | (url)(root_title)(pending_payout_value)(total_pending_payout_value)(active_votes)(active_votes_count)(replies) 35 | (reblogged_by)(first_reblogged_by)(first_reblogged_on)) 36 | -------------------------------------------------------------------------------- /libraries/api/include/graphene/api/discussion_helper.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace graphene { namespace api { 7 | struct content_metadata { 8 | std::set tags; 9 | std::string language; 10 | }; 11 | 12 | content_metadata get_metadata(const content_api_object &c); 13 | 14 | class discussion_helper { 15 | public: 16 | discussion_helper() = delete; 17 | discussion_helper(graphene::chain::database& db); 18 | ~discussion_helper(); 19 | 20 | 21 | void set_pending_payout(discussion& d) const; 22 | 23 | void set_url(discussion& d) const; 24 | 25 | void select_active_votes( 26 | std::vector& result, uint32_t& total_count, 27 | const std::string& author, const std::string& permlink, uint32_t limit 28 | ) const; 29 | 30 | discussion create_discussion(const content_object& o) const; 31 | 32 | discussion get_discussion(const content_object& c, uint32_t vote_limit) const; 33 | 34 | private: 35 | struct impl; 36 | std::unique_ptr pimpl; 37 | }; 38 | 39 | } } // graphene::api 40 | 41 | FC_REFLECT((graphene::api::content_metadata), (tags)(language)) 42 | -------------------------------------------------------------------------------- /libraries/api/include/graphene/api/invite_api_object.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CHAIN_INVITE_API_OBJ_H 2 | #define CHAIN_INVITE_API_OBJ_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace graphene { namespace api { 9 | 10 | using namespace graphene::chain; 11 | using graphene::chain::invite_object; 12 | 13 | struct invite_api_object { 14 | invite_api_object(const invite_object &o); 15 | invite_api_object(); 16 | 17 | invite_object::id_type id; 18 | 19 | account_name_type creator; 20 | account_name_type receiver; 21 | public_key_type invite_key; 22 | std::string invite_secret; 23 | 24 | protocol::asset balance; 25 | protocol::asset claimed_balance; 26 | 27 | time_point_sec create_time; 28 | time_point_sec claim_time; 29 | uint16_t status; 30 | }; 31 | } } // graphene::api 32 | 33 | FC_REFLECT( 34 | (graphene::api::invite_api_object), 35 | (id)(creator)(receiver)(invite_key)(invite_secret)(balance)(claimed_balance) 36 | (create_time)(claim_time)(status)) 37 | 38 | #endif //CHAIN_INVITE_API_OBJ_H 39 | -------------------------------------------------------------------------------- /libraries/api/include/graphene/api/paid_subscription_api_object.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CHAIN_PAID_SUBSCRIPTION_API_OBJ_H 2 | #define CHAIN_PAID_SUBSCRIPTION_API_OBJ_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace graphene { namespace api { 9 | 10 | using namespace graphene::chain; 11 | using graphene::chain::paid_subscription_object; 12 | using graphene::chain::paid_subscribe_object; 13 | 14 | struct paid_subscribe_state { 15 | paid_subscribe_state(const paid_subscribe_object &o); 16 | paid_subscribe_state(); 17 | 18 | paid_subscribe_object::id_type id; 19 | 20 | account_name_type subscriber; 21 | account_name_type creator; 22 | uint16_t level; 23 | share_type amount; 24 | uint16_t period; 25 | time_point_sec start_time; 26 | time_point_sec next_time; 27 | time_point_sec end_time; 28 | bool active = false; 29 | bool auto_renewal = false; 30 | }; 31 | 32 | struct paid_subscription_state { 33 | paid_subscription_state(const paid_subscription_object &o, const database &db); 34 | paid_subscription_state(); 35 | 36 | paid_subscription_object::id_type id; 37 | 38 | account_name_type creator; 39 | std::string url; 40 | uint16_t levels; 41 | share_type amount; 42 | uint16_t period; 43 | time_point_sec update_time; 44 | 45 | std::vector active_subscribers; 46 | uint32_t active_subscribers_count = 0; 47 | share_type active_subscribers_summary_amount = 0; 48 | std::vector active_subscribers_with_auto_renewal; 49 | uint32_t active_subscribers_with_auto_renewal_count = 0; 50 | share_type active_subscribers_with_auto_renewal_summary_amount = 0; 51 | }; 52 | } } // graphene::api 53 | 54 | FC_REFLECT((graphene::api::paid_subscribe_state),(subscriber)(creator)(level)(amount)(period)(start_time)(next_time)(end_time)(active)(auto_renewal)); 55 | 56 | FC_REFLECT( 57 | (graphene::api::paid_subscription_state), 58 | (creator)(url)(levels)(amount)(period)(update_time) 59 | (active_subscribers)(active_subscribers_count)(active_subscribers_summary_amount) 60 | (active_subscribers_with_auto_renewal)(active_subscribers_with_auto_renewal_count)(active_subscribers_with_auto_renewal_summary_amount)) 61 | 62 | #endif //CHAIN_PAID_SUBSCRIPTION_API_OBJ_H 63 | -------------------------------------------------------------------------------- /libraries/api/include/graphene/api/vote_state.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace graphene { namespace api { 6 | using graphene::protocol::share_type; 7 | struct vote_state { 8 | string voter; 9 | uint64_t weight = 0; 10 | int64_t rshares = 0; 11 | int16_t percent = 0; 12 | time_point_sec time; 13 | }; 14 | 15 | } } // graphene::api 16 | 17 | 18 | FC_REFLECT((graphene::api::vote_state), (voter)(weight)(rshares)(percent)(time)); -------------------------------------------------------------------------------- /libraries/api/include/graphene/api/witness_api_object.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace graphene { namespace api { 8 | using namespace graphene::chain; 9 | 10 | struct witness_api_object { 11 | witness_api_object(const witness_object &w, const database& db); 12 | 13 | witness_api_object() = default; 14 | 15 | witness_object::id_type id; 16 | account_name_type owner; 17 | time_point_sec created; 18 | std::string url; 19 | uint32_t total_missed; 20 | uint64_t last_aslot; 21 | uint64_t last_confirmed_block_num; 22 | public_key_type signing_key; 23 | api::chain_api_properties props; 24 | share_type votes; 25 | uint32_t penalty_percent; 26 | share_type counted_votes; 27 | fc::uint128_t virtual_last_update; 28 | fc::uint128_t virtual_position; 29 | fc::uint128_t virtual_scheduled_time; 30 | digest_type last_work; 31 | version running_version; 32 | hardfork_version hardfork_version_vote; 33 | time_point_sec hardfork_time_vote; 34 | }; 35 | 36 | } } // graphene::api 37 | 38 | 39 | FC_REFLECT( 40 | (graphene::api::witness_api_object), 41 | (id)(owner)(created)(url)(votes)(penalty_percent)(counted_votes)(virtual_last_update)(virtual_position)(virtual_scheduled_time) 42 | (total_missed)(last_aslot)(last_confirmed_block_num)(signing_key)(props) 43 | (last_work)(running_version)(hardfork_version_vote)(hardfork_time_vote)) 44 | -------------------------------------------------------------------------------- /libraries/api/invite_api_object.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace graphene { namespace api { 4 | 5 | using namespace graphene::chain; 6 | using graphene::chain::invite_object; 7 | 8 | invite_api_object::invite_api_object(const graphene::chain::invite_object &o) 9 | : id(o.id), 10 | creator(o.creator), 11 | receiver(o.receiver), 12 | invite_key(o.invite_key), 13 | invite_secret(to_string(o.invite_secret)), 14 | balance(o.balance), 15 | claimed_balance(o.claimed_balance), 16 | create_time(o.create_time), 17 | claim_time(o.claim_time), 18 | status(o.status) { 19 | } 20 | 21 | invite_api_object::invite_api_object() = default; 22 | 23 | } } // graphene::api -------------------------------------------------------------------------------- /libraries/api/paid_subscription_api_object.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace graphene { namespace api { 4 | 5 | using namespace graphene::chain; 6 | using graphene::chain::paid_subscription_object; 7 | using graphene::chain::paid_subscribe_object; 8 | 9 | paid_subscribe_state::paid_subscribe_state(const graphene::chain::paid_subscribe_object &o) 10 | : subscriber(o.subscriber), 11 | creator(o.creator), 12 | level(o.level), 13 | amount(o.amount), 14 | period(o.period), 15 | start_time(o.start_time), 16 | next_time(o.next_time), 17 | end_time(o.end_time), 18 | active(o.active), 19 | auto_renewal(o.auto_renewal) { 20 | } 21 | 22 | paid_subscribe_state::paid_subscribe_state() = default; 23 | 24 | paid_subscription_state::paid_subscription_state(const graphene::chain::paid_subscription_object &o, const graphene::chain::database &db) 25 | : creator(o.creator), 26 | url(to_string(o.url)), 27 | levels(o.levels), 28 | amount(o.amount), 29 | period(o.period), 30 | update_time(o.update_time) { 31 | const auto &idx = db.get_index().indices().get(); 32 | for (auto itr = idx.lower_bound(creator); 33 | itr != idx.end() && (itr->creator == creator); 34 | ++itr) { 35 | if(itr->active){ 36 | active_subscribers.push_back(itr->subscriber); 37 | active_subscribers_count++; 38 | active_subscribers_summary_amount+=itr->amount * itr->level; 39 | if(itr->auto_renewal){ 40 | active_subscribers_with_auto_renewal.push_back(itr->subscriber); 41 | active_subscribers_with_auto_renewal_count++; 42 | active_subscribers_with_auto_renewal_summary_amount+=itr->amount * itr->level; 43 | } 44 | } 45 | } 46 | } 47 | 48 | paid_subscription_state::paid_subscription_state() = default; 49 | 50 | } } // graphene::api -------------------------------------------------------------------------------- /libraries/api/witness_api_object.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace graphene { namespace api { 4 | witness_api_object::witness_api_object(const witness_object &w, const database& db) 5 | : id(w.id), owner(w.owner), created(w.created), 6 | url(to_string(w.url)), total_missed(w.total_missed), last_aslot(w.last_aslot), 7 | last_confirmed_block_num(w.last_confirmed_block_num), 8 | signing_key(w.signing_key), props(w.props, db), votes(w.votes), 9 | penalty_percent(w.penalty_percent),counted_votes(w.counted_votes), 10 | virtual_last_update(w.virtual_last_update), virtual_position(w.virtual_position), 11 | virtual_scheduled_time(w.virtual_scheduled_time), last_work(w.last_work), 12 | running_version(w.running_version), hardfork_version_vote(w.hardfork_version_vote), 13 | hardfork_time_vote(w.hardfork_time_vote) { 14 | } 15 | } } // graphene::api -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/0-preamble.hf: -------------------------------------------------------------------------------- 1 | /***************************************** 2 | * * 3 | * This file is automatically generated. * 4 | * To create new hardfork, please modify * 5 | * the .hf files in hardfork.d instead * 6 | * of modifying this file. * 7 | * * 8 | *****************************************/ 9 | 10 | #pragma once 11 | 12 | #include 13 | #include 14 | 15 | namespace graphene { 16 | namespace chain { 17 | 18 | class hardfork_property_object 19 | : public object { 20 | public: 21 | template 22 | hardfork_property_object(Constructor &&c, allocator a) 23 | :processed_hardforks(a.get_segment_manager()) { 24 | c(*this); 25 | } 26 | 27 | id_type id; 28 | 29 | boost::interprocess::vector > processed_hardforks; 30 | uint32_t last_hardfork = 0; 31 | protocol::hardfork_version current_hardfork_version; 32 | protocol::hardfork_version next_hardfork; 33 | fc::time_point_sec next_hardfork_time; 34 | }; 35 | 36 | typedef multi_index_container < 37 | hardfork_property_object, 38 | indexed_by< 39 | ordered_unique < member < 40 | hardfork_property_object, hardfork_property_object::id_type, &hardfork_property_object::id>> 41 | >, 42 | allocator 43 | > 44 | hardfork_property_index; 45 | 46 | } 47 | } // namespace graphene::chain 48 | 49 | FC_REFLECT((graphene::chain::hardfork_property_object), 50 | (id)(processed_hardforks)(last_hardfork)(current_hardfork_version) 51 | (next_hardfork)(next_hardfork_time)) 52 | CHAINBASE_SET_INDEX_TYPE( graphene::chain::hardfork_property_object, graphene::chain::hardfork_property_index) 53 | 54 | #define CHAIN_STARTUP_HARDFORKS 0 55 | #define CHAIN_NUM_HARDFORKS 11 56 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/1.hf: -------------------------------------------------------------------------------- 1 | // 1 Hardfork on VIZ mainnet, fix missed calc_median max_curator_percent 2 | #ifndef CHAIN_HARDFORK_1 3 | #define CHAIN_HARDFORK_1 1 4 | #define CHAIN_HARDFORK_1_TIME 1538647200 // 04 Oct 2018 10:00:00 GMT 5 | #define CHAIN_HARDFORK_1_VERSION hardfork_version( version(1, 1, 0) ) 6 | #endif 7 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/10.hf: -------------------------------------------------------------------------------- 1 | // 10 Hardfork on VIZ mainnet 2 | #ifndef CHAIN_HARDFORK_10 3 | #define CHAIN_HARDFORK_10 10 4 | #define CHAIN_HARDFORK_10_TIME 1638162000 // 29 Nov 2021 05:00:00 GMT 5 | #define CHAIN_HARDFORK_10_VERSION hardfork_version( version(2, 6, 0) ) 6 | #endif 7 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/11.hf: -------------------------------------------------------------------------------- 1 | // 11 Hardfork on VIZ mainnet 2 | #ifndef CHAIN_HARDFORK_11 3 | #define CHAIN_HARDFORK_11 11 4 | #define CHAIN_HARDFORK_11_TIME 1691643600 // 10 Aug 2023 05:00:00 GMT 5 | #define CHAIN_HARDFORK_11_VERSION hardfork_version( version(3, 0, 0) ) 6 | #endif 7 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/2.hf: -------------------------------------------------------------------------------- 1 | // 2 Hardfork on VIZ mainnet, fix committee check for approve_min_shares 2 | #ifndef CHAIN_HARDFORK_2 3 | #define CHAIN_HARDFORK_2 2 4 | #define CHAIN_HARDFORK_2_TIME 1538906400 // 07 Oct 2018 10:00:00 GMT 5 | #define CHAIN_HARDFORK_2_VERSION hardfork_version( version(1, 2, 0) ) 6 | #endif 7 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/3.hf: -------------------------------------------------------------------------------- 1 | // 3 Hardfork on VIZ mainnet, fix vote evaluator with awarded_rshares 2 | #ifndef CHAIN_HARDFORK_3 3 | #define CHAIN_HARDFORK_3 3 4 | #define CHAIN_HARDFORK_3_TIME 1540497600 // 25 Oct 2018 20:00:00 GMT 5 | #define CHAIN_HARDFORK_3_VERSION hardfork_version( version(1, 3, 0) ) 6 | #endif 7 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/4.hf: -------------------------------------------------------------------------------- 1 | // 4 Hardfork on VIZ mainnet, close awarded_rshares, close comment and vote operations, add custom sequence for account object, add award operation with beneficiaries support 2 | #ifndef CHAIN_HARDFORK_4 3 | #define CHAIN_HARDFORK_4 4 4 | #define CHAIN_HARDFORK_4_TIME 1547460000 // 14 Jan 2019 10:00:00 GMT 5 | #define CHAIN_HARDFORK_4_VERSION hardfork_version( version(2, 0, 0) ) 6 | #endif 7 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/5.hf: -------------------------------------------------------------------------------- 1 | // 5 Hardfork on VIZ mainnet, fix witnesses votes 2 | #ifndef CHAIN_HARDFORK_5 3 | #define CHAIN_HARDFORK_5 5 4 | #define CHAIN_HARDFORK_5_TIME 1550656800 // 20 Feb 2019 10:00:00 GMT 5 | #define CHAIN_HARDFORK_5_VERSION hardfork_version( version(2, 1, 0) ) 6 | #endif 7 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/6.hf: -------------------------------------------------------------------------------- 1 | // 6 Hardfork on VIZ mainnet 2 | #ifndef CHAIN_HARDFORK_6 3 | #define CHAIN_HARDFORK_6 6 4 | #define CHAIN_HARDFORK_6_TIME 1555236000 // 14 Apr 2019 10:00:00 GMT 5 | #define CHAIN_HARDFORK_6_VERSION hardfork_version( version(2, 2, 0) ) 6 | #endif 7 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/7.hf: -------------------------------------------------------------------------------- 1 | // 7 Hardfork on VIZ mainnet 2 | #ifndef CHAIN_HARDFORK_7 3 | #define CHAIN_HARDFORK_7 7 4 | #define CHAIN_HARDFORK_7_TIME 1556359200 // 27 Apr 2019 10:00:00 GMT 5 | #define CHAIN_HARDFORK_7_VERSION hardfork_version( version(2, 3, 0) ) 6 | #endif 7 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/8.hf: -------------------------------------------------------------------------------- 1 | // 8 Hardfork on VIZ mainnet 2 | #ifndef CHAIN_HARDFORK_8 3 | #define CHAIN_HARDFORK_8 8 4 | #define CHAIN_HARDFORK_8_TIME 1556600400 // 30 Apr 2019 05:00:00 GMT 5 | #define CHAIN_HARDFORK_8_VERSION hardfork_version( version(2, 4, 0) ) 6 | #endif 7 | -------------------------------------------------------------------------------- /libraries/chain/hardfork.d/9.hf: -------------------------------------------------------------------------------- 1 | // 9 Hardfork on VIZ mainnet 2 | #ifndef CHAIN_HARDFORK_9 3 | #define CHAIN_HARDFORK_9 9 4 | #define CHAIN_HARDFORK_9_TIME 1589173200 // 11 May 2020 05:00:00 GMT 5 | #define CHAIN_HARDFORK_9_VERSION hardfork_version( version(2, 5, 0) ) 6 | #endif 7 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/block_summary_object.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace graphene { 6 | namespace chain { 7 | 8 | using graphene::protocol::block_id_type; 9 | 10 | /** 11 | * @brief tracks minimal information about past blocks to implement TaPOS 12 | * @ingroup object 13 | * 14 | * When attempting to calculate the validity of a transaction we need to 15 | * lookup a past block and check its block hash and the time it occurred 16 | * so we can calculate whether the current transaction is valid and at 17 | * what time it should expire. 18 | */ 19 | class block_summary_object 20 | : public object { 21 | public: 22 | template 23 | block_summary_object(Constructor &&c, allocator a) { 24 | c(*this); 25 | } 26 | 27 | block_summary_object() { 28 | }; 29 | 30 | id_type id; 31 | block_id_type block_id; 32 | }; 33 | 34 | typedef multi_index_container < 35 | block_summary_object, 36 | indexed_by< 37 | ordered_unique < tag < by_id>, 38 | member> 39 | >, 40 | allocator 41 | > 42 | block_summary_index; 43 | 44 | } 45 | } // graphene::chain 46 | 47 | FC_REFLECT((graphene::chain::block_summary_object), (id)(block_id)) 48 | CHAINBASE_SET_INDEX_TYPE(graphene::chain::block_summary_object, graphene::chain::block_summary_index) 49 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/compound.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef BUILD_TESTNET 6 | #include 7 | #else 8 | #include 9 | #endif 10 | #include 11 | 12 | #include 13 | 14 | namespace graphene { 15 | namespace protocol { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/custom_operation_interpreter.hpp: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | namespace graphene { 7 | namespace schema { 8 | struct abstract_schema; 9 | } 10 | } 11 | 12 | namespace graphene { 13 | namespace protocol { 14 | struct custom_operation; 15 | } 16 | } 17 | 18 | namespace graphene { 19 | namespace chain { 20 | 21 | class custom_operation_interpreter { 22 | public: 23 | virtual void apply(const protocol::custom_operation &op) = 0; 24 | }; 25 | 26 | } 27 | } // graphene::chain 28 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/evaluator.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace graphene { 7 | namespace chain { 8 | 9 | class database; 10 | 11 | template 12 | class evaluator { 13 | public: 14 | virtual void apply(const OperationType &op) = 0; 15 | 16 | virtual int get_type() const = 0; 17 | }; 18 | 19 | template 20 | class evaluator_impl : public evaluator { 21 | public: 22 | typedef OperationType operation_sv_type; 23 | // typedef typename EvaluatorType::operation_type op_type; 24 | 25 | evaluator_impl(database &d) 26 | : _db(d) { 27 | } 28 | 29 | virtual void apply(const OperationType &o) final override { 30 | auto *eval = static_cast< EvaluatorType * >(this); 31 | const auto &op = o.template get(); 32 | eval->do_apply(op); 33 | } 34 | 35 | virtual int get_type() const override { 36 | return OperationType::template tag::value; 37 | } 38 | 39 | database &db() { 40 | return _db; 41 | } 42 | 43 | protected: 44 | database &_db; 45 | }; 46 | 47 | } 48 | } 49 | 50 | #define DEFINE_EVALUATOR(X) \ 51 | class X ## _evaluator : public graphene::chain::evaluator_impl< X ## _evaluator > \ 52 | { \ 53 | public: \ 54 | typedef X ## _operation operation_type; \ 55 | \ 56 | X ## _evaluator( database& db ) \ 57 | : graphene::chain::evaluator_impl< X ## _evaluator >( db ) \ 58 | {} \ 59 | \ 60 | void do_apply( const X ## _operation& o ); \ 61 | }; 62 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/evaluator_registry.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace graphene { 6 | namespace chain { 7 | 8 | template 9 | class evaluator_registry { 10 | public: 11 | evaluator_registry(database &d) 12 | : _db(d) { 13 | for (int i = 0; i < OperationType::count(); i++) { 14 | _op_evaluators.emplace_back(); 15 | } 16 | } 17 | 18 | template 19 | void register_evaluator(Args... args) { 20 | _op_evaluators[OperationType::template tag::value].reset(new EvaluatorType(_db, args...)); 21 | } 22 | 23 | evaluator &get_evaluator(const OperationType &op) { 24 | int i_which = op.which(); 25 | uint64_t u_which = uint64_t(i_which); 26 | if (i_which < 0) 27 | assert("Negative operation tag" && false); 28 | if (u_which >= _op_evaluators.size()) 29 | assert("No registered evaluator for this operation" && 30 | false); 31 | unique_ptr> &eval = _op_evaluators[u_which]; 32 | if (!eval) 33 | assert("No registered evaluator for this operation" && 34 | false); 35 | return *eval; 36 | } 37 | 38 | std::vector>> _op_evaluators; 39 | database &_db; 40 | }; 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #ifdef BUILD_TESTNET 8 | #include 9 | #else 10 | #include 11 | #endif 12 | 13 | namespace graphene { 14 | namespace chain { 15 | 16 | struct immutable_chain_parameters { 17 | uint16_t min_committee_member_count = CHAIN_DEFAULT_MIN_COMMITTEE_MEMBER_COUNT; 18 | uint16_t min_witness_count = CHAIN_DEFAULT_MIN_WITNESS_COUNT; 19 | uint32_t num_special_accounts = 0; 20 | uint32_t num_special_assets = 0; 21 | }; 22 | 23 | } 24 | } // graphene::chain 25 | 26 | FC_REFLECT((graphene::chain::immutable_chain_parameters), 27 | (min_committee_member_count) 28 | (min_witness_count) 29 | (num_special_accounts) 30 | (num_special_assets) 31 | ) 32 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/index.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace graphene { 6 | namespace chain { 7 | 8 | template 9 | void _add_index_impl(database &db) { 10 | db.add_index(); 11 | } 12 | 13 | template 14 | void add_core_index(database &db) { 15 | _add_index_impl(db); 16 | } 17 | 18 | template 19 | void add_plugin_index(database &db) { 20 | db._plugin_index_signal.connect([&db]() { _add_index_impl(db); }); 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/node_property_object.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace graphene { 4 | namespace chain { 5 | 6 | /** 7 | * @brief Contains per-node database configuration. 8 | * 9 | * Transactions are evaluated differently based on per-node state. 10 | * Settings here may change based on whether the node is syncing or up-to-date. 11 | * Or whether the node is a witness node. Or if we're processing a 12 | * transaction in a witness-signed block vs. a fresh transaction 13 | * from the p2p network. Or configuration-specified tradeoffs of 14 | * performance/hardfork resilience vs. paranoia. 15 | */ 16 | class node_property_object { 17 | public: 18 | node_property_object() { 19 | } 20 | 21 | ~node_property_object() { 22 | } 23 | 24 | uint32_t skip_flags = 0; 25 | }; 26 | } 27 | } // graphene::chain 28 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/operation_notification.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace graphene { 8 | using protocol::operation; 9 | namespace chain { 10 | 11 | struct operation_notification { 12 | operation_notification(const operation &o) : op(o) { 13 | } 14 | 15 | bool stored_in_db = false; 16 | int64_t db_id = 0; 17 | transaction_id_type trx_id; 18 | uint32_t block = 0; 19 | uint32_t trx_in_block = 0; 20 | uint16_t op_in_trx = 0; 21 | uint32_t virtual_op = 0; 22 | const operation &op; 23 | }; 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/shared_db_merkle.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace graphene { 4 | namespace chain { 5 | 6 | inline static const map &get_shared_db_merkle() { 7 | static const map shared_db_merkle 8 | { 9 | {3705111, checksum_type("0a8f0fd5450c3706ec8b8cbad795cd0b3679bf35")}, 10 | {3705120, checksum_type("2027edb72b671f7011c8cc4c7a8b59c39b305093")}, 11 | {3713940, checksum_type("bf8a1d516927c506ebdbb7b38bef2e992435435f")}, 12 | {3714132, checksum_type("e8b77773d268b72c8d650337b8cce360bbe64779")}, 13 | {3714567, checksum_type("45af59a8c2d7d4a606151ef5dae03d2dfe13fbdd")}, 14 | {3714588, checksum_type("e64275443bdc82f104ac936486d367af8f6d1584")}, 15 | {4138790, checksum_type("f65a3a788a2ef52406d8ba5705d7288be228403f")}, 16 | {5435426, checksum_type("0b32538b2d22bd3146d54b6e3cb5ae8b9780e8a5")} 17 | }; 18 | 19 | return shared_db_merkle; 20 | } 21 | 22 | } 23 | } //graphene::chain 24 | -------------------------------------------------------------------------------- /libraries/chain/include/graphene/chain/transaction_object.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | namespace graphene { 10 | namespace chain { 11 | 12 | using graphene::protocol::signed_transaction; 13 | 14 | /** 15 | * The purpose of this object is to enable the detection of duplicate transactions. When a transaction is included 16 | * in a block a transaction_object is added. At the end of block processing all transaction_objects that have 17 | * expired can be removed from the index. 18 | */ 19 | class transaction_object 20 | : public object { 21 | transaction_object() = delete; 22 | 23 | public: 24 | template 25 | transaction_object(Constructor &&c, allocator a) 26 | : packed_trx(a) { 27 | c(*this); 28 | } 29 | 30 | id_type id; 31 | 32 | bip::vector> packed_trx; 33 | transaction_id_type trx_id; 34 | time_point_sec expiration; 35 | }; 36 | 37 | struct by_expiration; 38 | struct by_trx_id; 39 | typedef multi_index_container < 40 | transaction_object, 41 | indexed_by< 42 | ordered_unique < tag < 43 | by_id>, member>, 44 | hashed_unique, BOOST_MULTI_INDEX_MEMBER(transaction_object, transaction_id_type, trx_id), std::hash>, 45 | ordered_non_unique , member> 46 | >, 47 | allocator 48 | > 49 | transaction_index; 50 | 51 | } 52 | } // graphene::chain 53 | 54 | FC_REFLECT((graphene::chain::transaction_object), (id)(packed_trx)(trx_id)(expiration)) 55 | CHAINBASE_SET_INDEX_TYPE(graphene::chain::transaction_object, graphene::chain::transaction_index) 56 | -------------------------------------------------------------------------------- /libraries/network/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET network) 2 | 3 | list(APPEND ${CURRENT_TARGET}_HEADERS 4 | include/graphene/network/config.hpp 5 | include/graphene/network/core_messages.hpp 6 | include/graphene/network/exceptions.hpp 7 | include/graphene/network/message.hpp 8 | include/graphene/network/message_oriented_connection.hpp 9 | include/graphene/network/node.hpp 10 | include/graphene/network/peer_connection.hpp 11 | include/graphene/network/peer_database.hpp 12 | include/graphene/network/stcp_socket.hpp 13 | ) 14 | 15 | list(APPEND ${CURRENT_TARGET}_SOURCES 16 | core_messages.cpp 17 | message_oriented_connection.cpp 18 | node.cpp 19 | peer_connection.cpp 20 | peer_database.cpp 21 | stcp_socket.cpp 22 | ) 23 | 24 | if(BUILD_SHARED_LIBRARIES) 25 | add_library(graphene_${CURRENT_TARGET} SHARED 26 | ${${CURRENT_TARGET}_HEADERS} 27 | ${${CURRENT_TARGET}_SOURCES} 28 | ) 29 | else() 30 | add_library(graphene_${CURRENT_TARGET} STATIC 31 | ${${CURRENT_TARGET}_HEADERS} 32 | ${${CURRENT_TARGET}_SOURCES} 33 | ) 34 | endif() 35 | 36 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 37 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 38 | 39 | target_link_libraries(graphene_${CURRENT_TARGET} PUBLIC fc graphene_protocol) 40 | target_include_directories(graphene_${CURRENT_TARGET} 41 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 42 | PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../protocol/include" 43 | #PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../version/include" 44 | ) 45 | 46 | if(MSVC) 47 | set_source_files_properties(node.cpp PROPERTIES COMPILE_FLAGS "/bigobj") 48 | endif(MSVC) 49 | 50 | if(USE_PCH) 51 | set_target_properties(graphene_${CURRENT_TARGET} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) 52 | cotire(graphene::network) 53 | endif(USE_PCH) 54 | 55 | install(TARGETS 56 | graphene_${CURRENT_TARGET} 57 | 58 | RUNTIME DESTINATION bin 59 | LIBRARY DESTINATION lib 60 | ARCHIVE DESTINATION lib 61 | ) 62 | install(FILES ${${CURRENT_TARGET}_HEADERS} DESTINATION "include/graphene/${CURRENT_TARGET}") 63 | 64 | -------------------------------------------------------------------------------- /libraries/network/include/graphene/network/exceptions.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | #include 28 | 29 | namespace graphene { 30 | namespace network { 31 | // registered in node.cpp 32 | 33 | FC_DECLARE_EXCEPTION(net_exception, 90000, "P2P Networking Exception"); 34 | 35 | FC_DECLARE_DERIVED_EXCEPTION(send_queue_overflow, graphene::network::net_exception, 90001, "send queue for this peer exceeded maximum size"); 36 | 37 | FC_DECLARE_DERIVED_EXCEPTION(insufficient_relay_fee, graphene::network::net_exception, 90002, "insufficient relay fee"); 38 | 39 | FC_DECLARE_DERIVED_EXCEPTION(already_connected_to_requested_peer, graphene::network::net_exception, 90003, "already connected to requested peer"); 40 | 41 | FC_DECLARE_DERIVED_EXCEPTION(block_older_than_undo_history, graphene::network::net_exception, 90004, "block is older than our undo history allows us to process"); 42 | 43 | FC_DECLARE_DERIVED_EXCEPTION(peer_is_on_an_unreachable_fork, graphene::network::net_exception, 90005, "peer is on another fork"); 44 | 45 | FC_DECLARE_DERIVED_EXCEPTION(unlinkable_block_exception, graphene::network::net_exception, 90006, "unlinkable block") 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /libraries/protocol/include/graphene/protocol/README.md: -------------------------------------------------------------------------------- 1 | Protocol Definition 2 | -------------------- 3 | 4 | The classes declared in these headers provide the complete definition of the 5 | Vaporware protocol and are organized according to feature. Nothing in this 6 | directory should depend upon anything other than fc or other types defined 7 | in the protocol directory. 8 | 9 | To be more specific, implementation details such as the objects defined in 10 | the object database should not be required here. 11 | -------------------------------------------------------------------------------- /libraries/protocol/include/graphene/protocol/base.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | namespace graphene { 10 | namespace protocol { 11 | 12 | struct base_operation { 13 | void get_required_authorities(vector &) const { 14 | } 15 | 16 | void get_required_active_authorities(flat_set &) const { 17 | } 18 | 19 | void get_required_regular_authorities(flat_set &) const { 20 | } 21 | 22 | void get_required_master_authorities(flat_set &) const { 23 | } 24 | 25 | bool is_virtual() const { 26 | return false; 27 | } 28 | 29 | void validate() const { 30 | } 31 | }; 32 | 33 | struct virtual_operation : public base_operation { 34 | bool is_virtual() const { 35 | return true; 36 | } 37 | 38 | void validate() const { 39 | FC_ASSERT(false, "This is a virtual operation"); 40 | } 41 | }; 42 | 43 | typedef static_variant< 44 | void_t, 45 | version, // Normal witness version reporting, for diagnostics and voting 46 | hardfork_version_vote // Voting for the next hardfork to trigger 47 | > block_header_extensions; 48 | 49 | typedef static_variant< 50 | void_t 51 | > future_extensions; 52 | 53 | typedef flat_set block_header_extensions_type; 54 | typedef flat_set extensions_type; 55 | 56 | 57 | } 58 | } // graphene::protocol 59 | 60 | FC_REFLECT_TYPENAME((graphene::protocol::block_header_extensions)) 61 | FC_REFLECT_TYPENAME((graphene::protocol::future_extensions)) 62 | -------------------------------------------------------------------------------- /libraries/protocol/include/graphene/protocol/block.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace graphene { 7 | namespace protocol { 8 | 9 | struct signed_block : public signed_block_header { 10 | checksum_type calculate_merkle_root() const; 11 | 12 | vector transactions; 13 | }; 14 | 15 | } 16 | } // graphene::protocol 17 | 18 | FC_REFLECT_DERIVED((graphene::protocol::signed_block), ((graphene::protocol::signed_block_header)), (transactions)) 19 | -------------------------------------------------------------------------------- /libraries/protocol/include/graphene/protocol/block_header.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace graphene { 6 | namespace protocol { 7 | 8 | struct block_header { 9 | digest_type digest() const; 10 | 11 | block_id_type previous; 12 | 13 | uint32_t block_num() const { 14 | return num_from_id(previous) + 1; 15 | } 16 | 17 | fc::time_point_sec timestamp; 18 | string witness; 19 | checksum_type transaction_merkle_root; 20 | block_header_extensions_type extensions; 21 | 22 | static uint32_t num_from_id(const block_id_type &id); 23 | }; 24 | 25 | struct signed_block_header : public block_header { 26 | block_id_type id() const; 27 | 28 | fc::ecc::public_key signee() const; 29 | 30 | void sign(const fc::ecc::private_key &signer); 31 | 32 | bool validate_signee(const fc::ecc::public_key &expected_signee) const; 33 | 34 | signature_type witness_signature; 35 | }; 36 | 37 | 38 | } 39 | } // graphene::protocol 40 | 41 | FC_REFLECT((graphene::protocol::block_header), (previous)(timestamp)(witness)(transaction_merkle_root)(extensions)) 42 | FC_REFLECT_DERIVED((graphene::protocol::signed_block_header), ((graphene::protocol::block_header)), (witness_signature)) 43 | -------------------------------------------------------------------------------- /libraries/protocol/include/graphene/protocol/get_config.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace graphene { 6 | namespace protocol { 7 | 8 | fc::variant_object get_config(); 9 | 10 | } 11 | } // graphene::protocol 12 | -------------------------------------------------------------------------------- /libraries/protocol/include/graphene/protocol/operation_util.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | // 13 | // Place DECLARE_OPERATION_TYPE in a .hpp file to declare 14 | // functions related to your operation type 15 | // 16 | #define DECLARE_OPERATION_TYPE(OperationType) \ 17 | namespace fc { \ 18 | \ 19 | void to_variant(const OperationType&, fc::variant&); \ 20 | void from_variant(const fc::variant&, OperationType&); \ 21 | \ 22 | } /* fc */ \ 23 | \ 24 | namespace graphene { namespace protocol { \ 25 | \ 26 | void operation_validate(const OperationType&); \ 27 | void operation_get_required_authorities( \ 28 | const OperationType& op, \ 29 | flat_set& active, \ 30 | flat_set& master, \ 31 | flat_set& regular, \ 32 | vector& other); \ 33 | \ 34 | } } /* graphene::protocol */ 35 | -------------------------------------------------------------------------------- /libraries/protocol/include/graphene/protocol/protocol.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /libraries/protocol/include/graphene/protocol/sign_state.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace graphene { namespace protocol { 7 | 8 | using authority_getter = std::function< authority (const account_name_type&) > ; 9 | 10 | struct sign_state { 11 | /** returns true if we have a signature for this key or can 12 | * produce a signature for this key, else returns false. 13 | */ 14 | bool signed_by(const public_key_type& k); 15 | 16 | bool check_authority(const account_name_type& id); 17 | 18 | /** 19 | * Checks to see if we have signatures of the active authorites of 20 | * the accounts specified in authority or the keys specified. 21 | */ 22 | bool check_authority(const authority& au, uint32_t depth = 0); 23 | 24 | bool remove_unused_signatures(); 25 | 26 | bool filter_unused_approvals(); 27 | 28 | sign_state( 29 | const flat_set& sigs, 30 | const authority_getter& a, 31 | const flat_set& keys); 32 | 33 | const authority_getter& get_active; 34 | const fc::flat_set& available_keys; 35 | 36 | fc::flat_map provided_signatures; 37 | std::vector unused_signatures; 38 | std::vector used_signatures; 39 | fc::flat_map approved_by; 40 | std::vector unused_approvals; 41 | uint32_t max_recursion = CHAIN_MAX_SIG_CHECK_DEPTH; 42 | }; 43 | 44 | } } // graphene::protocol 45 | -------------------------------------------------------------------------------- /libraries/protocol/operation_util_impl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace fc { 4 | 5 | std::string name_from_type(const std::string &type_name) { 6 | auto start = type_name.find_last_of(':') + 1; 7 | auto end = type_name.find_last_of('_'); 8 | return type_name.substr(start, end - start); 9 | } 10 | 11 | } // fc 12 | -------------------------------------------------------------------------------- /libraries/protocol/operations.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace graphene { 6 | namespace protocol { 7 | 8 | struct is_vop_visitor { 9 | typedef bool result_type; 10 | 11 | template 12 | bool operator()(const T &v) const { 13 | return v.is_virtual(); 14 | } 15 | }; 16 | 17 | bool is_virtual_operation(const operation &op) { 18 | return op.visit(is_vop_visitor()); 19 | } 20 | 21 | struct is_dop_visitor { 22 | typedef bool result_type; 23 | 24 | template 25 | bool operator()(const T &v) const { 26 | return false; 27 | } 28 | 29 | bool operator()(const custom_operation&) const { 30 | return true; 31 | } 32 | 33 | bool operator()(const account_create_operation&) const { 34 | return true; 35 | } 36 | 37 | bool operator()(const account_update_operation&) const { 38 | return true; 39 | } 40 | 41 | bool operator()(const account_metadata_operation&) const { 42 | return true; 43 | } 44 | 45 | bool operator()(const escrow_transfer_operation&) const { 46 | return true; 47 | } 48 | }; 49 | 50 | bool is_data_operation(const operation &op) { 51 | return op.visit(is_dop_visitor()); 52 | } 53 | 54 | } 55 | } // graphene::protocol 56 | 57 | DEFINE_OPERATION_TYPE(graphene::protocol::operation) 58 | -------------------------------------------------------------------------------- /libraries/time/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB HEADERS "include/graphene/time/*.hpp") 2 | 3 | if(BUILD_SHARED_LIBRARIES) 4 | add_library(graphene_time SHARED 5 | time.cpp 6 | ) 7 | else() 8 | add_library(graphene_time STATIC 9 | time.cpp 10 | ) 11 | endif() 12 | 13 | target_link_libraries(graphene_time fc) 14 | target_include_directories(graphene_time 15 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") 16 | 17 | install(TARGETS 18 | graphene_time 19 | 20 | RUNTIME DESTINATION bin 21 | LIBRARY DESTINATION lib 22 | ARCHIVE DESTINATION lib 23 | ) 24 | install(FILES ${HEADERS} DESTINATION "include/graphene/time") 25 | -------------------------------------------------------------------------------- /libraries/time/include/graphene/time/time.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace graphene { 8 | namespace time { 9 | 10 | typedef fc::signal time_discontinuity_signal_type; 11 | extern time_discontinuity_signal_type time_discontinuity_signal; 12 | 13 | fc::optional ntp_time(); 14 | 15 | fc::time_point now(); 16 | 17 | fc::time_point nonblocking_now(); // identical to now() but guaranteed not to block 18 | void update_ntp_time(); 19 | 20 | fc::microseconds ntp_error(); 21 | 22 | void shutdown_ntp_time(); 23 | 24 | void start_simulated_time(const fc::time_point sim_time); 25 | 26 | void advance_simulated_time_to(const fc::time_point sim_time); 27 | 28 | void advance_time(int32_t delta_seconds); 29 | 30 | } 31 | } // graphene::time 32 | -------------------------------------------------------------------------------- /libraries/utilities/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/libraries/fc/GitVersionGen") 2 | include(GetGitRevisionDescription) 3 | get_git_head_revision(GIT_REFSPEC GRAPHENE_GIT_REVISION_SHA) 4 | get_git_unix_timestamp(GRAPHENE_GIT_REVISION_UNIX_TIMESTAMP) 5 | git_describe(GRAPHENE_GIT_REVISION_DESCRIPTION --tags) 6 | if(NOT GRAPHENE_GIT_REVISION_DESCRIPTION) 7 | set(GRAPHENE_GIT_REVISION_DESCRIPTION "unknown") 8 | endif(NOT GRAPHENE_GIT_REVISION_DESCRIPTION) 9 | 10 | file(GLOB HEADERS "include/graphene/utilities/*.hpp") 11 | 12 | set(sources 13 | key_conversion.cpp 14 | string_escape.cpp 15 | tempdir.cpp 16 | words.cpp 17 | ${HEADERS}) 18 | 19 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/git_revision.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp" @ONLY) 20 | list(APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp") 21 | 22 | if(BUILD_SHARED_LIBRARIES) 23 | add_library(graphene_utilities SHARED 24 | ${sources} 25 | ${HEADERS}) 26 | else() 27 | add_library(graphene_utilities STATIC 28 | ${sources} 29 | ${HEADERS}) 30 | endif() 31 | target_link_libraries(graphene_utilities fc) 32 | target_include_directories(graphene_utilities 33 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") 34 | if(USE_PCH) 35 | set_target_properties(graphene_utilities PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) 36 | cotire(graphene_utilities) 37 | endif(USE_PCH) 38 | 39 | install(TARGETS 40 | graphene_utilities 41 | 42 | RUNTIME DESTINATION bin 43 | LIBRARY DESTINATION lib 44 | ARCHIVE DESTINATION lib 45 | ) 46 | install(FILES ${HEADERS} DESTINATION "include/graphene/utilities") 47 | -------------------------------------------------------------------------------- /libraries/utilities/git_revision.cpp.in: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define GRAPHENE_GIT_REVISION_SHA "@GRAPHENE_GIT_REVISION_SHA@" 5 | #define GRAPHENE_GIT_REVISION_UNIX_TIMESTAMP @GRAPHENE_GIT_REVISION_UNIX_TIMESTAMP@ 6 | #define GRAPHENE_GIT_REVISION_DESCRIPTION "@GRAPHENE_GIT_REVISION_DESCRIPTION@" 7 | 8 | namespace graphene { 9 | namespace utilities { 10 | 11 | const char *const git_revision_sha = GRAPHENE_GIT_REVISION_SHA; 12 | const uint32_t git_revision_unix_timestamp = GRAPHENE_GIT_REVISION_UNIX_TIMESTAMP; 13 | const char *const git_revision_description = GRAPHENE_GIT_REVISION_DESCRIPTION; 14 | 15 | } 16 | } // end namespace graphene::utilities 17 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/git_revision.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | namespace graphene { 29 | namespace utilities { 30 | 31 | extern const char *const git_revision_sha; 32 | extern const uint32_t git_revision_unix_timestamp; 33 | extern const char *const git_revision_description; 34 | 35 | } 36 | } // end namespace graphene::utilities 37 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/key_conversion.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | namespace graphene { 31 | namespace utilities { 32 | 33 | std::string key_to_wif(const fc::sha256 &private_secret); 34 | 35 | std::string key_to_wif(const fc::ecc::private_key &key); 36 | 37 | fc::optional wif_to_key(const std::string &wif_key); 38 | 39 | } 40 | } // end namespace graphene::utilities 41 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/string_escape.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | namespace graphene { 29 | namespace utilities { 30 | 31 | std::string escape_string_for_c_source_code(const std::string &input); 32 | 33 | } 34 | } // end namespace graphene::utilities 35 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/tempdir.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | #pragma once 25 | 26 | #include 27 | 28 | #include 29 | 30 | namespace graphene { 31 | namespace utilities { 32 | 33 | fc::path temp_directory_path(); 34 | 35 | } 36 | } // graphene::utilities 37 | -------------------------------------------------------------------------------- /libraries/utilities/include/graphene/utilities/words.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace graphene { 4 | namespace words { 5 | 6 | typedef const char *const_char_ptr; 7 | extern const const_char_ptr word_list[]; 8 | extern const uint32_t word_list_size; 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /libraries/utilities/tempdir.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Cryptonomex, Inc., and contributors. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include 26 | 27 | namespace graphene { 28 | namespace utilities { 29 | 30 | fc::path temp_directory_path() { 31 | const char *graphene_tempdir = getenv("GRAPHENE_TEMPDIR"); 32 | if (graphene_tempdir != nullptr) { 33 | return fc::path(graphene_tempdir); 34 | } 35 | return fc::temp_directory_path() / "graphene-tmp"; 36 | } 37 | 38 | } 39 | } // graphene::utilities 40 | -------------------------------------------------------------------------------- /plugins/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # for each subdirectory containing a CMakeLists.txt, add that subdirectory 2 | set(ENV{CHAIN_INTERNAL_PLUGINS} "") 3 | file(GLOB children RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *) 4 | foreach(child ${children}) 5 | if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${child}") 6 | if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${child}/CMakeLists.txt") 7 | add_subdirectory("${child}") 8 | set(ENV{CHAIN_INTERNAL_PLUGINS} "$ENV{CHAIN_INTERNAL_PLUGINS};${child}") 9 | endif() 10 | endif() 11 | endforeach() 12 | -------------------------------------------------------------------------------- /plugins/account_by_key/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET account_by_key) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/account_by_key/account_by_key_objects.hpp 5 | include/graphene/plugins/account_by_key/account_by_key_plugin.hpp 6 | ) 7 | 8 | list(APPEND CURRENT_TARGET_SOURCES 9 | account_by_key_plugin.cpp 10 | ) 11 | 12 | if(BUILD_SHARED_LIBRARIES) 13 | add_library(graphene_${CURRENT_TARGET} SHARED 14 | ${CURRENT_TARGET_HEADERS} 15 | ${CURRENT_TARGET_SOURCES} 16 | ) 17 | else() 18 | add_library(graphene_${CURRENT_TARGET} STATIC 19 | ${CURRENT_TARGET_HEADERS} 20 | ${CURRENT_TARGET_SOURCES} 21 | ) 22 | endif() 23 | 24 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 25 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 26 | 27 | target_link_libraries( 28 | graphene_${CURRENT_TARGET} 29 | graphene::chain_plugin 30 | graphene::p2p 31 | graphene::protocol 32 | graphene::network 33 | graphene_utilities 34 | graphene_time 35 | appbase 36 | ) 37 | target_include_directories(graphene_${CURRENT_TARGET} 38 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") 39 | 40 | install(TARGETS 41 | graphene_${CURRENT_TARGET} 42 | 43 | RUNTIME DESTINATION bin 44 | LIBRARY DESTINATION lib 45 | ARCHIVE DESTINATION lib 46 | ) -------------------------------------------------------------------------------- /plugins/account_by_key/include/graphene/plugins/account_by_key/account_by_key_objects.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | namespace graphene { 11 | namespace plugins { 12 | namespace account_by_key { 13 | 14 | using namespace std; 15 | using namespace graphene::chain; 16 | using namespace graphene::protocol; 17 | 18 | #ifndef ACCOUNT_BY_KEY_SPACE_ID 19 | #define ACCOUNT_BY_KEY_SPACE_ID 11 20 | #endif 21 | 22 | enum account_by_key_object_types { 23 | key_lookup_object_type = (ACCOUNT_BY_KEY_SPACE_ID << 8) 24 | }; 25 | 26 | class key_lookup_object 27 | : public object { 28 | public: 29 | template 30 | key_lookup_object(Constructor &&c, allocator a) { 31 | c(*this); 32 | } 33 | 34 | id_type id; 35 | 36 | public_key_type key; 37 | account_name_type account; 38 | }; 39 | typedef key_lookup_object::id_type key_lookup_id_type; 40 | 41 | using namespace boost::multi_index; 42 | 43 | struct by_key; 44 | 45 | typedef multi_index_container < 46 | key_lookup_object, 47 | indexed_by< 48 | ordered_unique < tag < 49 | by_id>, member>, 50 | ordered_unique , 51 | composite_key, 53 | member 54 | > 55 | > 56 | >, 57 | allocator 58 | > 59 | key_lookup_index; 60 | 61 | } 62 | } // graphene::plugins::account_by_key 63 | } 64 | 65 | FC_REFLECT((graphene::plugins::account_by_key::key_lookup_object), (id)(key)(account)) 66 | CHAINBASE_SET_INDEX_TYPE(graphene::plugins::account_by_key::key_lookup_object, graphene::plugins::account_by_key::key_lookup_index) 67 | -------------------------------------------------------------------------------- /plugins/account_history/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET account_history) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/account_history/plugin.hpp 5 | include/graphene/plugins/account_history/history_object.hpp 6 | ) 7 | 8 | list(APPEND CURRENT_TARGET_SOURCES 9 | plugin.cpp 10 | ) 11 | 12 | if (BUILD_SHARED_LIBRARIES) 13 | add_library(graphene_${CURRENT_TARGET} SHARED 14 | ${CURRENT_TARGET_HEADERS} 15 | ${CURRENT_TARGET_SOURCES} 16 | ) 17 | else() 18 | add_library(graphene_${CURRENT_TARGET} STATIC 19 | ${CURRENT_TARGET_HEADERS} 20 | ${CURRENT_TARGET_SOURCES} 21 | ) 22 | endif() 23 | 24 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 25 | 26 | target_link_libraries ( 27 | graphene_${CURRENT_TARGET} 28 | graphene_chain 29 | graphene_chain_plugin 30 | graphene_protocol 31 | graphene::operation_history 32 | appbase 33 | graphene_json_rpc 34 | graphene_time 35 | chainbase 36 | fc 37 | ) 38 | 39 | target_include_directories(graphene_${CURRENT_TARGET} 40 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 41 | "${CMAKE_CURRENT_SOURCE_DIR}/../../" 42 | ) 43 | 44 | install(TARGETS 45 | graphene_${CURRENT_TARGET} 46 | 47 | RUNTIME DESTINATION bin 48 | LIBRARY DESTINATION lib 49 | ARCHIVE DESTINATION lib 50 | ) -------------------------------------------------------------------------------- /plugins/auth_util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET auth_util) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/auth_util/plugin.hpp 5 | ) 6 | 7 | list(APPEND CURRENT_TARGET_SOURCES 8 | plugin.cpp 9 | ) 10 | 11 | if (BUILD_SHARED_LIBRARIES) 12 | add_library(graphene_${CURRENT_TARGET} SHARED 13 | ${CURRENT_TARGET_HEADERS} 14 | ${CURRENT_TARGET_SOURCES} 15 | ) 16 | else() 17 | add_library(graphene_${CURRENT_TARGET} STATIC 18 | ${CURRENT_TARGET_HEADERS} 19 | ${CURRENT_TARGET_SOURCES} 20 | ) 21 | endif() 22 | 23 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 24 | 25 | target_link_libraries ( 26 | graphene_${CURRENT_TARGET} 27 | graphene_chain 28 | graphene_chain_plugin 29 | graphene_protocol 30 | appbase 31 | fc 32 | ) 33 | 34 | target_include_directories(graphene_${CURRENT_TARGET} 35 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 36 | "${CMAKE_CURRENT_SOURCE_DIR}/../../" 37 | ) 38 | 39 | install(TARGETS 40 | graphene_${CURRENT_TARGET} 41 | 42 | RUNTIME DESTINATION bin 43 | LIBRARY DESTINATION lib 44 | ARCHIVE DESTINATION lib 45 | ) 46 | -------------------------------------------------------------------------------- /plugins/auth_util/include/graphene/plugins/auth_util/plugin.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace graphene { 13 | namespace plugins { 14 | namespace auth_util { 15 | 16 | using graphene::plugins::json_rpc::msg_pack; 17 | 18 | 19 | DEFINE_API_ARGS ( check_authority_signature, msg_pack, std::vector) 20 | 21 | class plugin final : public appbase::plugin { 22 | public: 23 | constexpr static const char *plugin_name = "auth_util"; 24 | 25 | APPBASE_PLUGIN_REQUIRES((chain::plugin)) 26 | 27 | static const std::string &name() { 28 | static std::string name = plugin_name; 29 | return name; 30 | } 31 | 32 | plugin(); 33 | 34 | ~plugin(); 35 | 36 | void set_program_options(boost::program_options::options_description &cli, 37 | boost::program_options::options_description &cfg) override; 38 | 39 | void plugin_initialize(const boost::program_options::variables_map &options) override; 40 | 41 | void plugin_startup() override; 42 | 43 | void plugin_shutdown() override { 44 | } 45 | 46 | DECLARE_API ( 47 | (check_authority_signature) 48 | ) 49 | 50 | private: 51 | struct plugin_impl; 52 | 53 | std::unique_ptr my; 54 | }; 55 | 56 | } 57 | } 58 | } // graphene::plugins::auth_util 59 | 60 | -------------------------------------------------------------------------------- /plugins/block_info/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET block_info) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/block_info/plugin.hpp 5 | include/graphene/plugins/block_info/block_info.hpp 6 | ) 7 | 8 | list(APPEND CURRENT_TARGET_SOURCES 9 | plugin.cpp 10 | ) 11 | 12 | if(BUILD_SHARED_LIBRARIES) 13 | add_library(graphene_${CURRENT_TARGET} SHARED 14 | ${CURRENT_TARGET_HEADERS} 15 | ${CURRENT_TARGET_SOURCES} 16 | ) 17 | else() 18 | add_library(graphene_${CURRENT_TARGET} STATIC 19 | ${CURRENT_TARGET_HEADERS} 20 | ${CURRENT_TARGET_SOURCES} 21 | ) 22 | endif() 23 | 24 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 25 | 26 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 27 | 28 | target_link_libraries( 29 | graphene_${CURRENT_TARGET} 30 | graphene_chain 31 | graphene_protocol 32 | appbase 33 | graphene_chain_plugin 34 | graphene::json_rpc 35 | fc 36 | ) 37 | 38 | target_include_directories( 39 | graphene_${CURRENT_TARGET} 40 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 41 | "${CMAKE_CURRENT_SOURCE_DIR}/../../" 42 | ) 43 | 44 | install(TARGETS 45 | graphene_${CURRENT_TARGET} 46 | 47 | RUNTIME DESTINATION bin 48 | LIBRARY DESTINATION lib 49 | ARCHIVE DESTINATION lib 50 | ) 51 | -------------------------------------------------------------------------------- /plugins/block_info/include/graphene/plugins/block_info/block_info.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace graphene { 6 | namespace plugins { 7 | namespace block_info { 8 | 9 | struct block_info { 10 | graphene::chain::block_id_type block_id; 11 | uint32_t block_size = 0; 12 | uint32_t average_block_size = 0; 13 | uint64_t aslot = 0; 14 | uint32_t last_irreversible_block_num = 0; 15 | }; 16 | 17 | struct block_with_info { 18 | graphene::chain::signed_block block; 19 | block_info info; 20 | }; 21 | 22 | } } } 23 | 24 | 25 | FC_REFLECT( (graphene::plugins::block_info::block_info), 26 | (block_id) 27 | (block_size) 28 | (average_block_size) 29 | (aslot) 30 | (last_irreversible_block_num) 31 | ) 32 | 33 | 34 | FC_REFLECT( (graphene::plugins::block_info::block_with_info), 35 | (block) 36 | (info) 37 | ) 38 | -------------------------------------------------------------------------------- /plugins/block_info/include/graphene/plugins/block_info/plugin.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace graphene { 14 | namespace protocol { 15 | 16 | struct signed_block; 17 | 18 | } } 19 | 20 | 21 | namespace graphene { 22 | namespace plugins { 23 | namespace block_info { 24 | 25 | using graphene::plugins::json_rpc::msg_pack; 26 | 27 | DEFINE_API_ARGS ( get_block_info, msg_pack, std::vector) 28 | DEFINE_API_ARGS ( get_blocks_with_info, msg_pack, std::vector) 29 | 30 | 31 | using boost::program_options::options_description; 32 | 33 | class plugin final : public appbase::plugin { 34 | public: 35 | APPBASE_PLUGIN_REQUIRES((graphene::plugins::chain::plugin)) 36 | 37 | constexpr const static char *plugin_name = "block_info"; 38 | 39 | static const std::string &name() { 40 | static std::string name = plugin_name; 41 | return name; 42 | } 43 | 44 | plugin(); 45 | 46 | ~plugin(); 47 | 48 | void set_program_options(boost::program_options::options_description &cli, boost::program_options::options_description &cfg) override { 49 | } 50 | 51 | void plugin_initialize(const boost::program_options::variables_map &options) override; 52 | 53 | void plugin_startup() override; 54 | 55 | void plugin_shutdown() override; 56 | 57 | DECLARE_API( 58 | (get_block_info) 59 | (get_blocks_with_info) 60 | ) 61 | void on_applied_block(const protocol::signed_block &b); 62 | 63 | private: 64 | struct plugin_impl; 65 | 66 | std::unique_ptr my; 67 | }; 68 | 69 | } } } 70 | 71 | 72 | -------------------------------------------------------------------------------- /plugins/chain/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET chain_plugin) 2 | list(APPEND CURRENT_TARGET_HEADERS 3 | include/graphene/plugins/chain/plugin.hpp 4 | ) 5 | 6 | list(APPEND CURRENT_TARGET_SOURCES 7 | plugin.cpp 8 | ) 9 | 10 | if(BUILD_SHARED_LIBRARIES) 11 | add_library(graphene_${CURRENT_TARGET} SHARED 12 | ${CURRENT_TARGET_HEADERS} 13 | ${CURRENT_TARGET_SOURCES} 14 | ) 15 | else() 16 | add_library(graphene_${CURRENT_TARGET} STATIC 17 | ${CURRENT_TARGET_HEADERS} 18 | ${CURRENT_TARGET_SOURCES} 19 | ) 20 | endif() 21 | 22 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 23 | 24 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 25 | 26 | target_link_libraries( 27 | graphene_${CURRENT_TARGET} 28 | graphene_chain 29 | graphene_protocol 30 | fc 31 | appbase 32 | graphene::json_rpc 33 | ) 34 | target_include_directories(graphene_${CURRENT_TARGET} 35 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/../../") 36 | 37 | install(TARGETS 38 | graphene_${CURRENT_TARGET} 39 | RUNTIME DESTINATION bin 40 | LIBRARY DESTINATION lib 41 | ARCHIVE DESTINATION lib 42 | ) 43 | install(FILES ${HEADERS} DESTINATION "include/graphene/chain_plugin") 44 | -------------------------------------------------------------------------------- /plugins/committee_api/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET committee_api) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/committee_api/committee_api.hpp 5 | ) 6 | 7 | list(APPEND CURRENT_TARGET_SOURCES 8 | committee_api.cpp 9 | ) 10 | 11 | if(BUILD_SHARED_LIBRARIES) 12 | add_library(graphene_${CURRENT_TARGET} SHARED 13 | ${CURRENT_TARGET_HEADERS} 14 | ${CURRENT_TARGET_SOURCES} 15 | ) 16 | else() 17 | add_library(graphene_${CURRENT_TARGET} STATIC 18 | ${CURRENT_TARGET_HEADERS} 19 | ${CURRENT_TARGET_SOURCES} 20 | ) 21 | endif() 22 | 23 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 24 | 25 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 26 | 27 | target_link_libraries( 28 | graphene_${CURRENT_TARGET} 29 | graphene_chain 30 | graphene::chain_plugin 31 | graphene::network 32 | graphene::api 33 | appbase 34 | ) 35 | 36 | target_include_directories( 37 | graphene_${CURRENT_TARGET} 38 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 39 | "${CMAKE_CURRENT_SOURCE_DIR}/../../" 40 | ) 41 | 42 | install(TARGETS 43 | graphene_${CURRENT_TARGET} 44 | 45 | RUNTIME DESTINATION bin 46 | LIBRARY DESTINATION lib 47 | ARCHIVE DESTINATION lib 48 | ) 49 | -------------------------------------------------------------------------------- /plugins/committee_api/include/graphene/plugins/committee_api/committee_api.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace graphene { namespace plugins { namespace committee_api { 8 | using plugins::json_rpc::msg_pack; 9 | using graphene::api::committee_api_object; 10 | using graphene::api::committee_vote_state; 11 | using namespace graphene::chain; 12 | 13 | DEFINE_API_ARGS(get_committee_request, msg_pack, committee_api_object) 14 | DEFINE_API_ARGS(get_committee_request_votes,msg_pack, std::vector) 15 | DEFINE_API_ARGS(get_committee_requests_list,msg_pack, std::vector) 16 | 17 | class committee_api final: public appbase::plugin { 18 | public: 19 | APPBASE_PLUGIN_REQUIRES ( 20 | (chain::plugin) 21 | (json_rpc::plugin) 22 | ) 23 | 24 | DECLARE_API( 25 | (get_committee_request) 26 | (get_committee_request_votes) 27 | (get_committee_requests_list) 28 | ) 29 | 30 | committee_api(); 31 | ~committee_api(); 32 | 33 | void set_program_options( 34 | boost::program_options::options_description&, 35 | boost::program_options::options_description& config_file_options 36 | ) override; 37 | 38 | static const std::string& name(); 39 | 40 | void plugin_initialize(const boost::program_options::variables_map& options) override; 41 | 42 | void plugin_startup() override; 43 | void plugin_shutdown() override; 44 | 45 | private: 46 | struct impl; 47 | std::unique_ptr pimpl; 48 | }; 49 | } } } // graphene::plugins::committee_api -------------------------------------------------------------------------------- /plugins/custom_protocol_api/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET custom_protocol_api) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/custom_protocol_api/custom_protocol_api.hpp 5 | include/graphene/plugins/custom_protocol_api/custom_protocol_api_visitor.hpp 6 | include/graphene/plugins/custom_protocol_api/custom_protocol_api_object.hpp 7 | ) 8 | 9 | list(APPEND CURRENT_TARGET_SOURCES 10 | custom_protocol_api.cpp 11 | custom_protocol_api_visitor.cpp 12 | ) 13 | 14 | if(BUILD_SHARED_LIBRARIES) 15 | add_library(graphene_${CURRENT_TARGET} SHARED 16 | ${CURRENT_TARGET_HEADERS} 17 | ${CURRENT_TARGET_SOURCES} 18 | ) 19 | else() 20 | add_library(graphene_${CURRENT_TARGET} STATIC 21 | ${CURRENT_TARGET_HEADERS} 22 | ${CURRENT_TARGET_SOURCES} 23 | ) 24 | endif() 25 | 26 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 27 | 28 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 29 | 30 | target_link_libraries( 31 | graphene_${CURRENT_TARGET} 32 | graphene_chain 33 | graphene::chain_plugin 34 | graphene::network 35 | graphene::api 36 | appbase 37 | ) 38 | 39 | target_include_directories( 40 | graphene_${CURRENT_TARGET} 41 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 42 | "${CMAKE_CURRENT_SOURCE_DIR}/../../" 43 | ) 44 | 45 | install(TARGETS 46 | graphene_${CURRENT_TARGET} 47 | 48 | RUNTIME DESTINATION bin 49 | LIBRARY DESTINATION lib 50 | ARCHIVE DESTINATION lib 51 | ) 52 | -------------------------------------------------------------------------------- /plugins/custom_protocol_api/custom_protocol_api_visitor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | namespace graphene { namespace plugins { namespace custom_protocol_api { 6 | 7 | operation_visitor::operation_visitor(database& db, uint8_t custom_protocol_store_size) 8 | : _db(db), _custom_protocol_store_size(custom_protocol_store_size) { 9 | } 10 | 11 | void operation_visitor::operator()(const custom_operation& op) const { 12 | std::vector accounts; 13 | for (const auto &i : op.required_active_auths) { 14 | accounts.emplace_back(i); 15 | } 16 | for (const auto &i : op.required_regular_auths) { 17 | accounts.emplace_back(i); 18 | } 19 | for (const auto i : accounts) { 20 | bool find=false; 21 | const auto &idx = _db.get_index().indices().get(); 22 | auto itr = idx.lower_bound(boost::make_tuple(i, uint64_t(-1) )); 23 | uint8_t custom_protocol_counter=0; 24 | while(!find && itr != idx.end() && itr->account == i){ 25 | const auto& custom_protocol_item = *itr; 26 | ++itr; 27 | custom_protocol_counter++; 28 | if(op.id == custom_protocol_item.custom_protocol_id){ 29 | find=true; 30 | _db.modify(custom_protocol_item, [&](custom_protocol_object& c){ 31 | c.custom_sequence++; 32 | c.custom_sequence_block_num = 1 + _db.head_block_num();//head_block_num contains previous block num 33 | }); 34 | } 35 | else{ 36 | if(custom_protocol_counter>=_custom_protocol_store_size){ 37 | _db.remove(custom_protocol_item); 38 | } 39 | } 40 | } 41 | if(!find){ 42 | _db.create([&](custom_protocol_object& c) { 43 | c.account=i; 44 | c.custom_protocol_id=op.id; 45 | c.custom_sequence = 1; 46 | c.custom_sequence_block_num = 1 + _db.head_block_num();//head_block_num contains previous block num 47 | }); 48 | } 49 | } 50 | } 51 | 52 | } } } // graphene::plugins::custom_protocol_api -------------------------------------------------------------------------------- /plugins/custom_protocol_api/include/graphene/plugins/custom_protocol_api/custom_protocol_api.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace graphene { namespace plugins { namespace custom_protocol_api { 10 | using plugins::json_rpc::msg_pack; 11 | using graphene::api::account_api_object; 12 | using graphene::plugins::custom_protocol_api::custom_protocol_object; 13 | using namespace graphene::chain; 14 | DEFINE_API_ARGS(get_account, msg_pack, account_api_object) 15 | 16 | class custom_protocol_api_plugin final: public appbase::plugin { 17 | public: 18 | APPBASE_PLUGIN_REQUIRES ( 19 | (chain::plugin) 20 | (json_rpc::plugin) 21 | ) 22 | 23 | DECLARE_API( 24 | /** 25 | * @brief Get accaount by name with custom protocol reference by id 26 | * @param name Name of the account 27 | * @param custom_protocol Id of the custom protocol 28 | * @return The account with custom protocol reference if founded in custom_sequence and custom_sequence_block_num 29 | */ 30 | (get_account) 31 | ) 32 | 33 | custom_protocol_api_plugin(); 34 | ~custom_protocol_api_plugin(); 35 | 36 | void set_program_options( 37 | boost::program_options::options_description&, 38 | boost::program_options::options_description& config_file_options 39 | ) override; 40 | 41 | static const std::string& name(); 42 | 43 | void plugin_initialize(const boost::program_options::variables_map& options) override; 44 | 45 | void plugin_startup() override; 46 | void plugin_shutdown() override; 47 | 48 | private: 49 | struct impl; 50 | std::unique_ptr pimpl; 51 | }; 52 | } } } // graphene::plugins::custom_protocol_api -------------------------------------------------------------------------------- /plugins/custom_protocol_api/include/graphene/plugins/custom_protocol_api/custom_protocol_api_visitor.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace graphene { namespace plugins { namespace custom_protocol_api { 7 | using graphene::plugins::custom_protocol_api::custom_protocol_object; 8 | struct operation_visitor { 9 | operation_visitor(database& db, const uint8_t custom_protocol_store_size); 10 | using result_type = void; 11 | 12 | database& _db; 13 | uint8_t _custom_protocol_store_size; 14 | 15 | void operator()(const custom_operation& op) const; 16 | 17 | template 18 | void operator()(Op&&) const { 19 | } /// ignore all other ops 20 | }; 21 | 22 | } } } // graphene::plugins::custom_protocol_api 23 | -------------------------------------------------------------------------------- /plugins/database_api/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET database_api) 2 | 3 | list(APPEND ${CURRENT_TARGET}_HEADERS 4 | include/graphene/plugins/database_api/state.hpp 5 | include/graphene/plugins/database_api/plugin.hpp 6 | 7 | include/graphene/plugins/database_api/api_objects/account_recovery_request_api_object.hpp 8 | include/graphene/plugins/database_api/forward.hpp 9 | include/graphene/plugins/database_api/api_objects/master_authority_history_api_object.hpp 10 | include/graphene/plugins/database_api/api_objects/proposal_api_object.hpp 11 | 12 | 13 | ) 14 | 15 | list(APPEND ${CURRENT_TARGET}_SOURCES 16 | api.cpp 17 | proposal_api_object.cpp 18 | ) 19 | 20 | if(BUILD_SHARED_LIBRARIES) 21 | add_library(graphene_${CURRENT_TARGET} SHARED 22 | ${${CURRENT_TARGET}_HEADERS} 23 | ${${CURRENT_TARGET}_SOURCES} 24 | ) 25 | else() 26 | add_library(graphene_${CURRENT_TARGET} STATIC 27 | ${${CURRENT_TARGET}_HEADERS} 28 | ${${CURRENT_TARGET}_SOURCES} 29 | ) 30 | endif() 31 | 32 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 33 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 34 | 35 | target_link_libraries( 36 | graphene_${CURRENT_TARGET} 37 | graphene_chain 38 | graphene::chain_plugin 39 | graphene::follow 40 | graphene_protocol 41 | graphene::json_rpc 42 | graphene_utilities 43 | appbase 44 | fc 45 | graphene::api 46 | ) 47 | target_include_directories(graphene_${CURRENT_TARGET} PUBLIC "include") 48 | 49 | install(TARGETS 50 | graphene_${CURRENT_TARGET} 51 | 52 | RUNTIME DESTINATION bin 53 | LIBRARY DESTINATION lib 54 | ARCHIVE DESTINATION lib 55 | ) 56 | -------------------------------------------------------------------------------- /plugins/database_api/include/graphene/plugins/database_api/api_objects/account_recovery_request_api_object.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CHAIN_ACCOUNT_RECOVERY_REQUEST_API_OBJ_HPP 2 | #define CHAIN_ACCOUNT_RECOVERY_REQUEST_API_OBJ_HPP 3 | 4 | #include 5 | 6 | namespace graphene { 7 | namespace plugins { 8 | namespace database_api { 9 | using graphene::chain::account_recovery_request_object; 10 | 11 | struct account_recovery_request_api_object { 12 | account_recovery_request_api_object(const graphene::chain::account_recovery_request_object &o) : id(o.id), 13 | account_to_recover(o.account_to_recover), new_master_authority(authority(o.new_master_authority)), 14 | expires(o.expires) { 15 | } 16 | 17 | account_recovery_request_api_object() { 18 | } 19 | 20 | account_recovery_request_object::id_type id; 21 | account_name_type account_to_recover; 22 | authority new_master_authority; 23 | time_point_sec expires; 24 | }; 25 | } 26 | } 27 | } 28 | 29 | 30 | FC_REFLECT((graphene::plugins::database_api::account_recovery_request_api_object), 31 | (id)(account_to_recover)(new_master_authority)(expires)) 32 | 33 | 34 | #endif //CHAIN_ACCOUNT_RECOVERY_REQUEST_API_OBJ_HPP 35 | -------------------------------------------------------------------------------- /plugins/database_api/include/graphene/plugins/database_api/api_objects/master_authority_history_api_object.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CHAIN_MASTER_AUTHORITY_HISTORY_API_OBJ_HPP 2 | #define CHAIN_MASTER_AUTHORITY_HISTORY_API_OBJ_HPP 3 | 4 | #include 5 | 6 | namespace graphene { 7 | namespace plugins { 8 | namespace database_api { 9 | 10 | using protocol::authority; 11 | using graphene::protocol::account_name_type; 12 | using graphene::chain::master_authority_history_object; 13 | 14 | struct master_authority_history_api_object { 15 | master_authority_history_api_object(const graphene::chain::master_authority_history_object &o) : id(o.id), 16 | account(o.account), previous_master_authority(authority(o.previous_master_authority)), 17 | last_valid_time(o.last_valid_time) { 18 | } 19 | 20 | master_authority_history_api_object() { 21 | } 22 | 23 | master_authority_history_object::id_type id; 24 | 25 | account_name_type account; 26 | authority previous_master_authority; 27 | time_point_sec last_valid_time; 28 | }; 29 | } 30 | } 31 | } 32 | 33 | FC_REFLECT((graphene::plugins::database_api::master_authority_history_api_object), 34 | (id)(account)(previous_master_authority)(last_valid_time)) 35 | #endif //CHAIN_MASTER_AUTHORITY_HISTORY_API_OBJ_HPP 36 | -------------------------------------------------------------------------------- /plugins/database_api/include/graphene/plugins/database_api/api_objects/proposal_api_object.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | namespace graphene { namespace plugins { namespace database_api { 10 | 11 | struct proposal_api_object final { 12 | proposal_api_object() = default; 13 | 14 | proposal_api_object(const graphene::chain::proposal_object& p); 15 | 16 | protocol::account_name_type author; 17 | std::string title; 18 | std::string memo; 19 | 20 | time_point_sec expiration_time; 21 | optional review_period_time; 22 | std::vector proposed_operations; 23 | flat_set required_active_approvals; 24 | flat_set available_active_approvals; 25 | flat_set required_master_approvals; 26 | flat_set available_master_approvals; 27 | flat_set required_regular_approvals; 28 | flat_set available_regular_approvals; 29 | flat_set available_key_approvals; 30 | }; 31 | 32 | }}} // graphene::plugins::database_api 33 | 34 | FC_REFLECT( 35 | (graphene::plugins::database_api::proposal_api_object), 36 | (author)(title)(memo)(expiration_time)(review_period_time)(proposed_operations) 37 | (required_active_approvals)(available_active_approvals) 38 | (required_master_approvals)(available_master_approvals) 39 | (required_regular_approvals)(available_regular_approvals) 40 | (available_key_approvals)) -------------------------------------------------------------------------------- /plugins/database_api/include/graphene/plugins/database_api/forward.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CHAIN_FORWARD_HPP 2 | #define CHAIN_FORWARD_HPP 3 | 4 | #include 5 | 6 | namespace graphene { namespace plugins { namespace database_api { 7 | using protocol::share_type; 8 | typedef graphene::chain::change_recovery_account_request_object change_recovery_account_request_api_object; 9 | typedef graphene::chain::block_summary_object block_summary_api_object; 10 | typedef graphene::chain::content_vote_object content_vote_api_object; 11 | typedef graphene::chain::dynamic_global_property_object dynamic_global_property_api_object; 12 | typedef graphene::chain::escrow_object escrow_api_object; 13 | typedef graphene::chain::withdraw_vesting_route_object withdraw_vesting_route_api_object; 14 | typedef graphene::chain::witness_vote_object witness_vote_api_object; 15 | typedef graphene::chain::witness_schedule_object witness_schedule_api_object; 16 | 17 | using vesting_delegation_api_object = graphene::chain::vesting_delegation_object; 18 | using vesting_delegation_expiration_api_object = graphene::chain::vesting_delegation_expiration_object; 19 | 20 | } } } // graphene::plugins::database_api 21 | 22 | #endif //CHAIN_FORWARD_HPP 23 | -------------------------------------------------------------------------------- /plugins/database_api/include/graphene/plugins/database_api/state.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "forward.hpp" 8 | #include 9 | 10 | namespace graphene { 11 | namespace plugins { 12 | namespace database_api { 13 | 14 | using graphene::protocol::asset; 15 | using graphene::api::account_api_object; 16 | using std::string; 17 | using std::vector; 18 | 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /plugins/database_api/proposal_api_object.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace graphene { namespace plugins { namespace database_api { 4 | 5 | proposal_api_object::proposal_api_object(const graphene::chain::proposal_object& p) 6 | : author(p.author), 7 | title(graphene::chain::to_string(p.title)), 8 | memo(graphene::chain::to_string(p.memo)), 9 | expiration_time(p.expiration_time), 10 | review_period_time(p.review_period_time), 11 | proposed_operations(p.operations()), 12 | required_active_approvals(p.required_active_approvals.begin(), p.required_active_approvals.end()), 13 | available_active_approvals(p.available_active_approvals.begin(), p.available_active_approvals.end()), 14 | required_master_approvals(p.required_master_approvals.begin(), p.required_master_approvals.end()), 15 | available_master_approvals(p.available_master_approvals.begin(), p.available_master_approvals.end()), 16 | required_regular_approvals(p.required_regular_approvals.begin(), p.required_regular_approvals.end()), 17 | available_regular_approvals(p.available_regular_approvals.begin(), p.available_regular_approvals.end()), 18 | available_key_approvals(p.available_key_approvals.begin(), p.available_key_approvals.end()) { 19 | } 20 | 21 | }}} // graphene::plugins::database_api -------------------------------------------------------------------------------- /plugins/debug_node/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET debug_node) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/debug_node/plugin.hpp 5 | ) 6 | 7 | list(APPEND CURRENT_TARGET_SOURCES 8 | plugin.cpp 9 | ) 10 | 11 | if(BUILD_SHARED_LIBRARIES) 12 | add_library(graphene_${CURRENT_TARGET} SHARED 13 | ${CURRENT_TARGET_HEADERS} 14 | ${CURRENT_TARGET_SOURCES} 15 | ) 16 | else() 17 | add_library(graphene_${CURRENT_TARGET} STATIC 18 | ${CURRENT_TARGET_HEADERS} 19 | ${CURRENT_TARGET_SOURCES} 20 | ) 21 | endif() 22 | 23 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 24 | 25 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 26 | 27 | target_link_libraries( 28 | graphene_${CURRENT_TARGET} 29 | graphene_chain 30 | graphene_protocol 31 | appbase 32 | graphene_utilities 33 | graphene_chain_plugin 34 | # graphene_json_rpc_plugin 35 | fc 36 | ) 37 | 38 | target_include_directories( 39 | graphene_${CURRENT_TARGET} 40 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 41 | "${CMAKE_CURRENT_SOURCE_DIR}/../../" 42 | ) 43 | 44 | install(TARGETS 45 | graphene_${CURRENT_TARGET} 46 | 47 | RUNTIME DESTINATION bin 48 | LIBRARY DESTINATION lib 49 | ARCHIVE DESTINATION lib 50 | ) 51 | -------------------------------------------------------------------------------- /plugins/follow/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET follow) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/follow/follow_api_object.hpp 5 | include/graphene/plugins/follow/follow_evaluators.hpp 6 | include/graphene/plugins/follow/follow_objects.hpp 7 | include/graphene/plugins/follow/follow_operations.hpp 8 | include/graphene/plugins/follow/follow_forward.hpp 9 | include/graphene/plugins/follow/plugin.hpp 10 | ) 11 | 12 | list(APPEND CURRENT_TARGET_SOURCES 13 | follow_evaluators.cpp 14 | follow_operations.cpp 15 | plugin.cpp 16 | ) 17 | 18 | if(BUILD_SHARED_LIBRARIES) 19 | add_library(graphene_${CURRENT_TARGET} SHARED 20 | ${CURRENT_TARGET_HEADERS} 21 | ${CURRENT_TARGET_SOURCES} 22 | ) 23 | else() 24 | add_library(graphene_${CURRENT_TARGET} STATIC 25 | ${CURRENT_TARGET_HEADERS} 26 | ${CURRENT_TARGET_SOURCES} 27 | ) 28 | endif() 29 | 30 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 31 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 32 | 33 | target_link_libraries( 34 | graphene_${CURRENT_TARGET} 35 | graphene_chain 36 | graphene::json_rpc 37 | graphene::chain_plugin 38 | graphene::protocol 39 | graphene::api 40 | appbase 41 | fc 42 | ) 43 | target_include_directories(graphene_${CURRENT_TARGET} PUBLIC "include") 44 | 45 | install(TARGETS 46 | graphene_${CURRENT_TARGET} 47 | 48 | RUNTIME DESTINATION bin 49 | LIBRARY DESTINATION lib 50 | ARCHIVE DESTINATION lib 51 | ) -------------------------------------------------------------------------------- /plugins/follow/follow_operations.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace graphene { 5 | namespace plugins { 6 | namespace follow { 7 | 8 | void follow_operation::validate() const { 9 | FC_ASSERT(follower != following, "You cannot follow yourself"); 10 | } 11 | 12 | void reblog_operation::validate() const { 13 | FC_ASSERT(account != author, "You cannot reblog your own content"); 14 | } 15 | 16 | } 17 | } 18 | } //graphene::follow 19 | 20 | DEFINE_OPERATION_TYPE(graphene::plugins::follow::follow_plugin_operation) -------------------------------------------------------------------------------- /plugins/follow/include/graphene/plugins/follow/follow_evaluators.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CHAIN_FOLLOW_EVALUATORS_HPP 2 | #define CHAIN_FOLLOW_EVALUATORS_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace graphene { 9 | namespace plugins { 10 | namespace follow { 11 | using graphene::chain::evaluator; 12 | using graphene::chain::database; 13 | 14 | class follow_evaluator : public graphene::chain::evaluator_impl { 15 | public: 16 | typedef follow_operation operation_type; 17 | 18 | follow_evaluator(database &db, plugin *plugin) : graphene::chain::evaluator_impl(db), _plugin(plugin) { 19 | } 20 | 21 | void do_apply(const follow_operation &o); 22 | 23 | plugin *_plugin; 24 | }; 25 | 26 | class reblog_evaluator : public graphene::chain::evaluator_impl { 27 | public: 28 | typedef reblog_operation operation_type; 29 | 30 | reblog_evaluator(database &db, plugin *plugin) : graphene::chain::evaluator_impl(db), _plugin(plugin) { 31 | } 32 | 33 | void do_apply(const reblog_operation &o); 34 | 35 | plugin *_plugin; 36 | }; 37 | } 38 | } 39 | } 40 | 41 | #endif //CHAIN_FOLLOW_EVALUATORS_HPP 42 | -------------------------------------------------------------------------------- /plugins/follow/include/graphene/plugins/follow/follow_forward.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CHAIN_FOLLOW_FORWARD_HPP 2 | #define CHAIN_FOLLOW_FORWARD_HPP 3 | 4 | #include 5 | 6 | namespace graphene { 7 | namespace plugins { 8 | namespace follow { 9 | 10 | enum follow_type { 11 | undefined, 12 | blog, 13 | ignore 14 | }; 15 | 16 | }}} 17 | 18 | FC_REFLECT_ENUM(graphene::plugins::follow::follow_type, (undefined)(blog)(ignore)) 19 | 20 | #endif //CHAIN_FORWARD_HPP 21 | -------------------------------------------------------------------------------- /plugins/follow/include/graphene/plugins/follow/follow_operations.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace graphene { 8 | namespace plugins { 9 | namespace follow { 10 | using graphene::chain::base_operation; 11 | using graphene::protocol::account_name_type; 12 | struct follow_operation : base_operation { 13 | protocol::account_name_type follower; 14 | protocol::account_name_type following; 15 | std::set what; /// blog, mute 16 | 17 | void validate() const; 18 | void get_required_regular_authorities(flat_set& a) const { 19 | a.insert(follower); 20 | } 21 | }; 22 | 23 | struct reblog_operation : base_operation{ 24 | protocol::account_name_type account; 25 | protocol::account_name_type author; 26 | std::string permlink; 27 | 28 | void validate() const; 29 | void get_required_regular_authorities(flat_set& a) const { 30 | a.insert(account); 31 | } 32 | }; 33 | 34 | using follow_plugin_operation = fc::static_variant; 35 | 36 | } 37 | } 38 | } // graphene::follow 39 | 40 | FC_REFLECT((graphene::plugins::follow::follow_operation), (follower)(following)(what)); 41 | FC_REFLECT((graphene::plugins::follow::reblog_operation), (account)(author)(permlink)); 42 | 43 | FC_REFLECT_TYPENAME((graphene::plugins::follow::follow_plugin_operation)); 44 | DECLARE_OPERATION_TYPE(graphene::plugins::follow::follow_plugin_operation) 45 | -------------------------------------------------------------------------------- /plugins/invite_api/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET invite_api) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/invite_api/invite_api.hpp 5 | ) 6 | 7 | list(APPEND CURRENT_TARGET_SOURCES 8 | invite_api.cpp 9 | ) 10 | 11 | if(BUILD_SHARED_LIBRARIES) 12 | add_library(graphene_${CURRENT_TARGET} SHARED 13 | ${CURRENT_TARGET_HEADERS} 14 | ${CURRENT_TARGET_SOURCES} 15 | ) 16 | else() 17 | add_library(graphene_${CURRENT_TARGET} STATIC 18 | ${CURRENT_TARGET_HEADERS} 19 | ${CURRENT_TARGET_SOURCES} 20 | ) 21 | endif() 22 | 23 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 24 | 25 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 26 | 27 | target_link_libraries( 28 | graphene_${CURRENT_TARGET} 29 | graphene_chain 30 | graphene::chain_plugin 31 | graphene::network 32 | graphene::api 33 | appbase 34 | ) 35 | 36 | target_include_directories( 37 | graphene_${CURRENT_TARGET} 38 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 39 | "${CMAKE_CURRENT_SOURCE_DIR}/../../" 40 | ) 41 | 42 | install(TARGETS 43 | graphene_${CURRENT_TARGET} 44 | 45 | RUNTIME DESTINATION bin 46 | LIBRARY DESTINATION lib 47 | ARCHIVE DESTINATION lib 48 | ) 49 | -------------------------------------------------------------------------------- /plugins/invite_api/include/graphene/plugins/invite_api/invite_api.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace graphene { namespace plugins { namespace invite_api { 8 | using plugins::json_rpc::msg_pack; 9 | using graphene::api::invite_api_object; 10 | using namespace graphene::chain; 11 | 12 | DEFINE_API_ARGS(get_invites_list, msg_pack, std::vector) 13 | DEFINE_API_ARGS(get_invite_by_id, msg_pack, invite_api_object) 14 | DEFINE_API_ARGS(get_invite_by_key, msg_pack, invite_api_object) 15 | 16 | class invite_api final: public appbase::plugin { 17 | public: 18 | APPBASE_PLUGIN_REQUIRES ( 19 | (chain::plugin) 20 | (json_rpc::plugin) 21 | ) 22 | 23 | DECLARE_API( 24 | (get_invites_list) 25 | (get_invite_by_id) 26 | (get_invite_by_key) 27 | ) 28 | 29 | invite_api(); 30 | ~invite_api(); 31 | 32 | void set_program_options( 33 | boost::program_options::options_description&, 34 | boost::program_options::options_description& config_file_options 35 | ) override; 36 | 37 | static const std::string& name(); 38 | 39 | void plugin_initialize(const boost::program_options::variables_map& options) override; 40 | 41 | void plugin_startup() override; 42 | void plugin_shutdown() override; 43 | 44 | private: 45 | struct impl; 46 | std::unique_ptr pimpl; 47 | }; 48 | } } } // graphene::plugins::invite_api -------------------------------------------------------------------------------- /plugins/json_rpc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET json_rpc) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/json_rpc/plugin.hpp 5 | include/graphene/plugins/json_rpc/utility.hpp 6 | ) 7 | 8 | list(APPEND CURRENT_TARGET_SOURCES 9 | plugin.cpp 10 | ) 11 | 12 | if(BUILD_SHARED_LIBRARIES) 13 | add_library(graphene_${CURRENT_TARGET} SHARED 14 | ${CURRENT_TARGET_HEADERS} 15 | ${CURRENT_TARGET_SOURCES} 16 | ) 17 | else() 18 | add_library(graphene_${CURRENT_TARGET} STATIC 19 | ${CURRENT_TARGET_HEADERS} 20 | ${CURRENT_TARGET_SOURCES} 21 | ) 22 | endif() 23 | 24 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 25 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 26 | target_link_libraries(graphene_${CURRENT_TARGET} appbase fc) 27 | target_include_directories(graphene_${CURRENT_TARGET} 28 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/../../") 29 | 30 | install(TARGETS 31 | graphene_${CURRENT_TARGET} 32 | 33 | RUNTIME DESTINATION bin 34 | LIBRARY DESTINATION lib 35 | ARCHIVE DESTINATION lib 36 | ) 37 | -------------------------------------------------------------------------------- /plugins/mongo_db/include/graphene/plugins/mongo_db/mongo_db_plugin.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace graphene { 11 | namespace plugins { 12 | namespace mongo_db { 13 | 14 | class mongo_db_plugin final : public appbase::plugin { 15 | public: 16 | 17 | APPBASE_PLUGIN_REQUIRES( 18 | (chain::plugin) 19 | ) 20 | 21 | mongo_db_plugin(); 22 | 23 | virtual ~mongo_db_plugin(); 24 | 25 | void set_program_options( 26 | boost::program_options::options_description& cli, 27 | boost::program_options::options_description& cfg 28 | ) override; 29 | 30 | void plugin_initialize(const boost::program_options::variables_map& options) override; 31 | 32 | void plugin_startup() override; 33 | 34 | void plugin_shutdown() override; 35 | 36 | constexpr const static char *plugin_name = "mongo_db"; 37 | 38 | static const std::string& name() { 39 | static std::string name = plugin_name; 40 | return name; 41 | } 42 | 43 | private: 44 | class mongo_db_plugin_impl; 45 | 46 | std::unique_ptr pimpl_; 47 | }; 48 | 49 | }}} // namespace graphene::plugins::mongo_db 50 | 51 | -------------------------------------------------------------------------------- /plugins/mongo_db/mongo_db_types.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace graphene { 4 | namespace plugins { 5 | namespace mongo_db { 6 | 7 | void bmi_insert_or_replace(db_map& bmi, named_document doc) { 8 | auto it = bmi.get().find(std::make_tuple( 9 | doc.collection_name, 10 | doc.key, doc.keyval, doc.is_removal)); 11 | if (it != bmi.get().end()) 12 | bmi.get().erase(it); 13 | bmi.push_back(std::move(doc)); 14 | } 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /plugins/network_broadcast_api/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET network_broadcast_api) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/network_broadcast_api/network_broadcast_api_plugin.hpp 5 | ) 6 | 7 | list(APPEND CURRENT_TARGET_SOURCES 8 | network_broadcast_api.cpp 9 | ) 10 | 11 | if(BUILD_SHARED_LIBRARIES) 12 | add_library(graphene_${CURRENT_TARGET} SHARED 13 | ${CURRENT_TARGET_HEADERS} 14 | ${CURRENT_TARGET_SOURCES} 15 | ) 16 | else() 17 | add_library(graphene_${CURRENT_TARGET} STATIC 18 | ${CURRENT_TARGET_HEADERS} 19 | ${CURRENT_TARGET_SOURCES} 20 | ) 21 | endif() 22 | 23 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 24 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 25 | 26 | target_link_libraries( 27 | graphene_${CURRENT_TARGET} 28 | graphene_chain 29 | graphene::chain_plugin 30 | graphene::json_rpc 31 | graphene::p2p 32 | appbase 33 | ) 34 | 35 | target_include_directories(graphene_${CURRENT_TARGET} 36 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/../../") 37 | 38 | install(TARGETS 39 | graphene_${CURRENT_TARGET} 40 | 41 | RUNTIME DESTINATION bin 42 | LIBRARY DESTINATION lib 43 | ARCHIVE DESTINATION lib 44 | ) 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /plugins/operation_history/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET operation_history) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/operation_history/plugin.hpp 5 | include/graphene/plugins/operation_history/history_object.hpp 6 | include/graphene/plugins/operation_history/applied_operation.hpp 7 | ) 8 | 9 | list(APPEND CURRENT_TARGET_SOURCES 10 | plugin.cpp 11 | applied_operation.cpp 12 | ) 13 | 14 | if (BUILD_SHARED_LIBRARIES) 15 | add_library(graphene_${CURRENT_TARGET} SHARED 16 | ${CURRENT_TARGET_HEADERS} 17 | ${CURRENT_TARGET_SOURCES} 18 | ) 19 | else() 20 | add_library(graphene_${CURRENT_TARGET} STATIC 21 | ${CURRENT_TARGET_HEADERS} 22 | ${CURRENT_TARGET_SOURCES} 23 | ) 24 | endif() 25 | 26 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 27 | 28 | target_link_libraries ( 29 | graphene_${CURRENT_TARGET} 30 | graphene_chain 31 | graphene_chain_plugin 32 | graphene_protocol 33 | appbase 34 | graphene_json_rpc 35 | graphene_time 36 | chainbase 37 | fc 38 | ) 39 | 40 | target_include_directories(graphene_${CURRENT_TARGET} 41 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 42 | "${CMAKE_CURRENT_SOURCE_DIR}/../../" 43 | ) 44 | 45 | install(TARGETS 46 | graphene_${CURRENT_TARGET} 47 | 48 | RUNTIME DESTINATION bin 49 | LIBRARY DESTINATION lib 50 | ARCHIVE DESTINATION lib 51 | ) -------------------------------------------------------------------------------- /plugins/operation_history/applied_operation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace graphene { namespace plugins { namespace operation_history { 4 | 5 | applied_operation::applied_operation() = default; 6 | 7 | applied_operation::applied_operation(const operation_object& op_obj) 8 | : trx_id(op_obj.trx_id), 9 | block(op_obj.block), 10 | trx_in_block(op_obj.trx_in_block), 11 | op_in_trx(op_obj.op_in_trx), 12 | virtual_op(op_obj.virtual_op), 13 | timestamp(op_obj.timestamp), 14 | op(fc::raw::unpack(op_obj.serialized_op)) { 15 | } 16 | 17 | } } } // graphene::plugins::operation_history 18 | -------------------------------------------------------------------------------- /plugins/operation_history/include/graphene/plugins/operation_history/applied_operation.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace graphene { namespace plugins { namespace operation_history { 8 | 9 | struct applied_operation final { 10 | applied_operation(); 11 | 12 | applied_operation(const operation_object&); 13 | 14 | graphene::protocol::transaction_id_type trx_id; 15 | uint32_t block = 0; 16 | uint32_t trx_in_block = 0; 17 | uint16_t op_in_trx = 0; 18 | uint64_t virtual_op = 0; 19 | fc::time_point_sec timestamp; 20 | graphene::protocol::operation op; 21 | }; 22 | 23 | } } } // graphene::plugins::operation_history 24 | 25 | FC_REFLECT( 26 | (graphene::plugins::operation_history::applied_operation), 27 | (trx_id)(block)(trx_in_block)(op_in_trx)(virtual_op)(timestamp)(op)) 28 | -------------------------------------------------------------------------------- /plugins/p2p/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET p2p) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/p2p/p2p_plugin.hpp 5 | ) 6 | 7 | list(APPEND CURRENT_TARGET_SOURCES 8 | p2p_plugin.cpp 9 | ) 10 | 11 | if(BUILD_SHARED_LIBRARIES) 12 | add_library(graphene_${CURRENT_TARGET} SHARED 13 | ${CURRENT_TARGET_HEADERS} 14 | ${CURRENT_TARGET_SOURCES} 15 | ) 16 | else() 17 | add_library(graphene_${CURRENT_TARGET} STATIC 18 | ${CURRENT_TARGET_HEADERS} 19 | ${CURRENT_TARGET_SOURCES} 20 | ) 21 | endif() 22 | 23 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 24 | 25 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 26 | 27 | target_link_libraries( 28 | graphene_${CURRENT_TARGET} 29 | graphene_chain 30 | graphene::chain_plugin 31 | graphene::network 32 | appbase 33 | ) 34 | 35 | target_include_directories( 36 | graphene_${CURRENT_TARGET} 37 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 38 | "${CMAKE_CURRENT_SOURCE_DIR}/../../" 39 | ) 40 | 41 | install(TARGETS 42 | graphene_${CURRENT_TARGET} 43 | 44 | RUNTIME DESTINATION bin 45 | LIBRARY DESTINATION lib 46 | ARCHIVE DESTINATION lib 47 | ) 48 | -------------------------------------------------------------------------------- /plugins/p2p/include/graphene/plugins/p2p/p2p_plugin.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #define P2P_PLUGIN_NAME "p2p" 8 | 9 | namespace graphene { 10 | namespace plugins { 11 | namespace p2p { 12 | namespace bpo = boost::program_options; 13 | 14 | namespace detail { 15 | class p2p_plugin_impl; 16 | } 17 | 18 | class p2p_plugin final : public appbase::plugin { 19 | public: 20 | APPBASE_PLUGIN_REQUIRES((chain::plugin)) 21 | 22 | p2p_plugin(); 23 | 24 | ~p2p_plugin(); 25 | 26 | void set_program_options(boost::program_options::options_description &, 27 | boost::program_options::options_description &config_file_options) override; 28 | 29 | static const std::string &name() { 30 | static std::string name = P2P_PLUGIN_NAME; 31 | return name; 32 | } 33 | 34 | void plugin_initialize(const boost::program_options::variables_map &options) override; 35 | 36 | void plugin_startup() override; 37 | 38 | void plugin_shutdown() override; 39 | 40 | void broadcast_block(const graphene::protocol::signed_block &block); 41 | 42 | void broadcast_block_post_validation(const graphene::protocol::block_id_type block_id, 43 | const std::string &witness_account, 44 | const graphene::protocol::signature_type &witness_signature); 45 | 46 | void broadcast_transaction(const graphene::protocol::signed_transaction &tx); 47 | 48 | void set_block_production(bool producing_blocks); 49 | 50 | private: 51 | std::unique_ptr my; 52 | }; 53 | 54 | } 55 | } 56 | } // graphene::plugins::p2p 57 | -------------------------------------------------------------------------------- /plugins/paid_subscription_api/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET paid_subscription_api) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/paid_subscription_api/paid_subscription_api.hpp 5 | ) 6 | 7 | list(APPEND CURRENT_TARGET_SOURCES 8 | paid_subscription_api.cpp 9 | ) 10 | 11 | if(BUILD_SHARED_LIBRARIES) 12 | add_library(graphene_${CURRENT_TARGET} SHARED 13 | ${CURRENT_TARGET_HEADERS} 14 | ${CURRENT_TARGET_SOURCES} 15 | ) 16 | else() 17 | add_library(graphene_${CURRENT_TARGET} STATIC 18 | ${CURRENT_TARGET_HEADERS} 19 | ${CURRENT_TARGET_SOURCES} 20 | ) 21 | endif() 22 | 23 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 24 | 25 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 26 | 27 | target_link_libraries( 28 | graphene_${CURRENT_TARGET} 29 | graphene_chain 30 | graphene::protocol 31 | graphene::chain_plugin 32 | graphene::network 33 | graphene::api 34 | appbase 35 | ) 36 | 37 | target_include_directories( 38 | graphene_${CURRENT_TARGET} 39 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 40 | "${CMAKE_CURRENT_SOURCE_DIR}/../../" 41 | ) 42 | 43 | install(TARGETS 44 | graphene_${CURRENT_TARGET} 45 | 46 | RUNTIME DESTINATION bin 47 | LIBRARY DESTINATION lib 48 | ARCHIVE DESTINATION lib 49 | ) 50 | -------------------------------------------------------------------------------- /plugins/paid_subscription_api/include/graphene/plugins/paid_subscription_api/paid_subscription_api.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace graphene { namespace plugins { namespace paid_subscription_api { 10 | using plugins::json_rpc::msg_pack; 11 | using graphene::chain::paid_subscription_object; 12 | using graphene::chain::paid_subscribe_object; 13 | using graphene::api::paid_subscription_state; 14 | using graphene::api::paid_subscribe_state; 15 | using namespace graphene::protocol; 16 | using namespace graphene::chain; 17 | 18 | DEFINE_API_ARGS(get_paid_subscriptions, msg_pack, std::vector) 19 | DEFINE_API_ARGS(get_paid_subscription_options, msg_pack, paid_subscription_state) 20 | DEFINE_API_ARGS(get_paid_subscription_status, msg_pack, paid_subscribe_state) 21 | DEFINE_API_ARGS(get_active_paid_subscriptions, msg_pack, std::vector) 22 | DEFINE_API_ARGS(get_inactive_paid_subscriptions, msg_pack, std::vector) 23 | 24 | class paid_subscription_api final: public appbase::plugin { 25 | public: 26 | APPBASE_PLUGIN_REQUIRES ( 27 | (chain::plugin) 28 | (json_rpc::plugin) 29 | ) 30 | 31 | DECLARE_API( 32 | (get_paid_subscriptions) 33 | (get_paid_subscription_options) 34 | (get_paid_subscription_status) 35 | (get_active_paid_subscriptions) 36 | (get_inactive_paid_subscriptions) 37 | ) 38 | 39 | paid_subscription_api(); 40 | ~paid_subscription_api(); 41 | 42 | void set_program_options( 43 | boost::program_options::options_description&, 44 | boost::program_options::options_description& config_file_options 45 | ) override; 46 | 47 | static const std::string& name(); 48 | 49 | void plugin_initialize(const boost::program_options::variables_map& options) override; 50 | 51 | void plugin_startup() override; 52 | void plugin_shutdown() override; 53 | 54 | private: 55 | struct impl; 56 | std::unique_ptr pimpl; 57 | }; 58 | } } } // graphene::plugins::paid_subscription_api -------------------------------------------------------------------------------- /plugins/private_message/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET private_message) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/private_message/private_message_plugin.hpp 5 | include/graphene/plugins/private_message/private_message_objects.hpp 6 | include/graphene/plugins/private_message/private_message_evaluators.hpp 7 | ) 8 | 9 | list(APPEND CURRENT_TARGET_SOURCES 10 | private_message_plugin.cpp 11 | private_message_objects.cpp 12 | ) 13 | 14 | if(BUILD_SHARED_LIBRARIES) 15 | add_library(graphene_${CURRENT_TARGET} SHARED 16 | ${CURRENT_TARGET_HEADERS} 17 | ${CURRENT_TARGET_SOURCES} 18 | ) 19 | else() 20 | add_library(graphene_${CURRENT_TARGET} STATIC 21 | ${CURRENT_TARGET_HEADERS} 22 | ${CURRENT_TARGET_SOURCES} 23 | ) 24 | endif() 25 | 26 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 27 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 28 | 29 | target_link_libraries( 30 | graphene_${CURRENT_TARGET} 31 | graphene::chain_plugin 32 | graphene::p2p 33 | graphene::protocol 34 | graphene::network 35 | graphene_utilities 36 | graphene_time 37 | appbase 38 | ) 39 | target_include_directories(graphene_${CURRENT_TARGET} 40 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") 41 | 42 | install(TARGETS 43 | graphene_${CURRENT_TARGET} 44 | 45 | RUNTIME DESTINATION bin 46 | LIBRARY DESTINATION lib 47 | ARCHIVE DESTINATION lib 48 | ) 49 | 50 | -------------------------------------------------------------------------------- /plugins/private_message/include/graphene/plugins/private_message/private_message_evaluators.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace graphene { 9 | namespace plugins { 10 | namespace private_message { 11 | 12 | class private_message_evaluator : public graphene::chain::evaluator_impl 13 | { 14 | public: 15 | typedef private_message_operation operation_type; 16 | 17 | private_message_evaluator(database& db, private_message_plugin* plugin) 18 | : graphene::chain::evaluator_impl( db ) 19 | , _plugin( plugin ) 20 | {} 21 | 22 | void do_apply( const private_message_operation& o ); 23 | 24 | private_message_plugin* _plugin; 25 | }; 26 | 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /plugins/private_message/private_message_objects.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace graphene { 5 | namespace plugins { 6 | namespace private_message { 7 | 8 | void private_message_operation::validate() const { 9 | FC_ASSERT(from != to, "You cannot write to yourself"); 10 | } 11 | } 12 | } 13 | } 14 | 15 | DEFINE_OPERATION_TYPE(graphene::plugins::private_message::private_message_plugin_operation); 16 | -------------------------------------------------------------------------------- /plugins/raw_block/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET raw_block) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/raw_block/plugin.hpp 5 | ) 6 | 7 | list(APPEND CURRENT_TARGET_SOURCES 8 | plugin.cpp 9 | ) 10 | 11 | if(BUILD_SHARED_LIBRARIES) 12 | add_library(graphene_${CURRENT_TARGET} SHARED 13 | ${CURRENT_TARGET_HEADERS} 14 | ${CURRENT_TARGET_SOURCES} 15 | ) 16 | else() 17 | add_library(graphene_${CURRENT_TARGET} STATIC 18 | ${CURRENT_TARGET_HEADERS} 19 | ${CURRENT_TARGET_SOURCES} 20 | ) 21 | endif() 22 | 23 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 24 | 25 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 26 | 27 | target_link_libraries( 28 | graphene_${CURRENT_TARGET} 29 | graphene_chain 30 | graphene_chain_plugin 31 | graphene_protocol 32 | appbase 33 | graphene::json_rpc 34 | fc 35 | ) 36 | 37 | target_include_directories( 38 | graphene_${CURRENT_TARGET} 39 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 40 | "${CMAKE_CURRENT_SOURCE_DIR}/../../" 41 | ) 42 | 43 | install(TARGETS 44 | graphene_${CURRENT_TARGET} 45 | 46 | RUNTIME DESTINATION bin 47 | LIBRARY DESTINATION lib 48 | ARCHIVE DESTINATION lib 49 | ) 50 | -------------------------------------------------------------------------------- /plugins/raw_block/include/graphene/plugins/raw_block/plugin.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace graphene { 12 | namespace plugins { 13 | namespace raw_block { 14 | 15 | using graphene::plugins::json_rpc::msg_pack; 16 | 17 | struct get_raw_block_r { 18 | graphene::chain::block_id_type block_id; 19 | graphene::chain::block_id_type previous; 20 | fc::time_point_sec timestamp; 21 | std::string raw_block; 22 | }; 23 | 24 | DEFINE_API_ARGS ( get_raw_block, msg_pack, get_raw_block_r ) 25 | 26 | using boost::program_options::options_description; 27 | 28 | class plugin final : public appbase::plugin { 29 | public: 30 | APPBASE_PLUGIN_REQUIRES( 31 | (chain::plugin) 32 | (json_rpc::plugin) 33 | ) 34 | 35 | constexpr const static char *plugin_name = "raw_block"; 36 | 37 | static const std::string &name() { 38 | static std::string name = plugin_name; 39 | return name; 40 | } 41 | 42 | plugin(); 43 | 44 | ~plugin(); 45 | 46 | void set_program_options( 47 | boost::program_options::options_description &cli, 48 | boost::program_options::options_description &cfg) override { 49 | } 50 | 51 | void plugin_initialize(const boost::program_options::variables_map &options) override; 52 | 53 | void plugin_startup() override; 54 | 55 | void plugin_shutdown() override; 56 | 57 | DECLARE_API ( 58 | (get_raw_block) 59 | ) 60 | 61 | private: 62 | struct plugin_impl; 63 | 64 | std::unique_ptr my; 65 | }; 66 | 67 | } } } // graphene::plugins::raw_block 68 | 69 | FC_REFLECT((graphene::plugins::raw_block::get_raw_block_r), 70 | (block_id)(previous)(timestamp)(raw_block) 71 | ) 72 | -------------------------------------------------------------------------------- /plugins/raw_block/plugin.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace graphene { 8 | namespace plugins { 9 | namespace raw_block { 10 | 11 | struct plugin::plugin_impl { 12 | public: 13 | plugin_impl() : db_(appbase::app().get_plugin().db()) { 14 | } 15 | // API 16 | get_raw_block_r get_raw_block(uint32_t block_num = 0); 17 | 18 | // HELPING METHODS 19 | graphene::chain::database &database() { 20 | return db_; 21 | } 22 | private: 23 | graphene::chain::database & db_; 24 | }; 25 | 26 | get_raw_block_r plugin::plugin_impl::get_raw_block(uint32_t block_num) { 27 | get_raw_block_r result; 28 | const auto &db = database(); 29 | 30 | auto block = db.fetch_block_by_number(block_num); 31 | if (!block.valid()) { 32 | return result; 33 | } 34 | std::vector serialized_block = fc::raw::pack(*block); 35 | result.raw_block = fc::base64_encode( 36 | std::string( 37 | &serialized_block[0], 38 | &serialized_block[0] + serialized_block.size() 39 | ) 40 | ); 41 | result.block_id = block->id(); 42 | result.previous = block->previous; 43 | result.timestamp = block->timestamp; 44 | return result; 45 | } 46 | 47 | DEFINE_API ( plugin, get_raw_block ) { 48 | auto tmp = args.args->at(0).as(); 49 | auto &db = my->database(); 50 | return db.with_weak_read_lock([&]() { 51 | return my->get_raw_block(tmp); 52 | }); 53 | } 54 | 55 | plugin::plugin() { 56 | } 57 | 58 | plugin::~plugin() { 59 | } 60 | 61 | void plugin::plugin_initialize(const boost::program_options::variables_map &options) { 62 | my.reset(new plugin_impl); 63 | JSON_RPC_REGISTER_API ( name() ) ; 64 | } 65 | 66 | void plugin::plugin_startup() { 67 | } 68 | 69 | void plugin::plugin_shutdown() { 70 | } 71 | 72 | } } } // graphene::plugin::raw_block 73 | -------------------------------------------------------------------------------- /plugins/social_network/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET social_network) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/social_network/social_network.hpp 5 | ) 6 | 7 | list(APPEND CURRENT_TARGET_SOURCES 8 | social_network.cpp 9 | ) 10 | 11 | if(BUILD_SHARED_LIBRARIES) 12 | add_library(graphene_${CURRENT_TARGET} SHARED 13 | ${CURRENT_TARGET_HEADERS} 14 | ${CURRENT_TARGET_SOURCES} 15 | ) 16 | else() 17 | add_library(graphene_${CURRENT_TARGET} STATIC 18 | ${CURRENT_TARGET_HEADERS} 19 | ${CURRENT_TARGET_SOURCES} 20 | ) 21 | endif() 22 | 23 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 24 | 25 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 26 | 27 | target_link_libraries( 28 | graphene_${CURRENT_TARGET} 29 | graphene_chain 30 | graphene::chain_plugin 31 | graphene::network 32 | graphene::follow 33 | graphene::tags 34 | appbase 35 | ) 36 | 37 | target_include_directories( 38 | graphene_${CURRENT_TARGET} 39 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 40 | "${CMAKE_CURRENT_SOURCE_DIR}/../../" 41 | ) 42 | 43 | install(TARGETS 44 | graphene_${CURRENT_TARGET} 45 | 46 | RUNTIME DESTINATION bin 47 | LIBRARY DESTINATION lib 48 | ARCHIVE DESTINATION lib 49 | ) 50 | -------------------------------------------------------------------------------- /plugins/tags/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET tags) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/tags/discussion_query.hpp 5 | include/graphene/plugins/tags/plugin.hpp 6 | include/graphene/plugins/tags/tag_api_object.hpp 7 | include/graphene/plugins/tags/tag_visitor.hpp 8 | include/graphene/plugins/tags/tags_object.hpp 9 | include/graphene/plugins/tags/tags_sort.hpp 10 | ) 11 | 12 | list(APPEND CURRENT_TARGET_SOURCES 13 | plugin.cpp 14 | tag_visitor.cpp 15 | discussion_query.cpp 16 | ) 17 | 18 | if(BUILD_SHARED_LIBRARIES) 19 | add_library(graphene_${CURRENT_TARGET} SHARED 20 | ${CURRENT_TARGET_HEADERS} 21 | ${CURRENT_TARGET_SOURCES} 22 | ) 23 | else() 24 | add_library(graphene_${CURRENT_TARGET} STATIC 25 | ${CURRENT_TARGET_HEADERS} 26 | ${CURRENT_TARGET_SOURCES} 27 | ) 28 | endif() 29 | 30 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 31 | 32 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 33 | 34 | target_link_libraries( 35 | graphene_${CURRENT_TARGET} 36 | graphene_chain 37 | graphene::chain_plugin 38 | graphene::network 39 | graphene::follow 40 | graphene::api 41 | appbase 42 | ) 43 | 44 | target_include_directories( 45 | graphene_${CURRENT_TARGET} 46 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 47 | "${CMAKE_CURRENT_SOURCE_DIR}/../../" 48 | ) 49 | 50 | install(TARGETS 51 | graphene_${CURRENT_TARGET} 52 | 53 | RUNTIME DESTINATION bin 54 | LIBRARY DESTINATION lib 55 | ARCHIVE DESTINATION lib 56 | ) 57 | -------------------------------------------------------------------------------- /plugins/tags/discussion_query.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | namespace graphene { namespace plugins { namespace tags { 6 | 7 | void tags_to_lower(std::set& tags) { 8 | auto src = std::move(tags); 9 | for (const auto& name: src) { 10 | auto value = boost::trim_copy(name); 11 | boost::to_lower(value); 12 | if (!value.empty()) { 13 | tags.insert(value); 14 | } 15 | } 16 | } 17 | 18 | void discussion_query::prepare() { 19 | tags_to_lower(select_tags); 20 | tags_to_lower(filter_tags); 21 | tags_to_lower(select_languages); 22 | tags_to_lower(filter_languages); 23 | } 24 | 25 | void discussion_query::validate() const { 26 | FC_ASSERT(limit <= 100); 27 | 28 | for (auto& itr : filter_tags) { 29 | FC_ASSERT(select_tags.find(itr) == select_tags.end()); 30 | } 31 | 32 | for (auto& itr : filter_languages) { 33 | FC_ASSERT(select_languages.find(itr) == select_languages.end()); 34 | } 35 | } 36 | 37 | bool discussion_query::is_good_tags(const discussion& d) const { 38 | if (!has_tags_selector() && !has_tags_filter() && !has_language_selector() && !has_language_filter()) { 39 | return true; 40 | } 41 | 42 | auto meta = tags::get_metadata(d); 43 | if ((has_language_selector() && !select_languages.count(meta.language)) || 44 | (has_language_filter() && filter_languages.count(meta.language)) 45 | ) { 46 | return false; 47 | } 48 | 49 | bool result = select_tags.empty(); 50 | for (auto& name: meta.tags) { 51 | if (has_tags_filter() && filter_tags.count(name)) { 52 | return false; 53 | } else if (!result && select_tags.count(name)) { 54 | result = true; 55 | } 56 | } 57 | 58 | return result; 59 | } 60 | 61 | } } } // graphene::plugins::tags 62 | 63 | -------------------------------------------------------------------------------- /plugins/tags/include/graphene/plugins/tags/tag_api_object.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CHAIN_TAG_API_OBJ_HPP 2 | #define CHAIN_TAG_API_OBJ_HPP 3 | 4 | #include 5 | #include 6 | 7 | namespace graphene { namespace plugins { namespace tags { 8 | struct tag_api_object { 9 | tag_api_object(const tags::tag_stats_object& o) 10 | : name(o.name), 11 | total_children_rshares(o.total_children_rshares), 12 | total_payouts(o.total_payout), 13 | net_votes(o.net_votes), top_posts(o.top_posts), 14 | contents(o.contents) { 15 | } 16 | 17 | tag_api_object() { 18 | } 19 | 20 | std::string name; 21 | fc::uint128_t total_children_rshares; 22 | graphene::protocol::asset total_payouts; 23 | int32_t net_votes = 0; 24 | uint32_t top_posts = 0; 25 | uint32_t contents = 0; 26 | }; 27 | } } } // graphene::plugins::tags 28 | 29 | 30 | FC_REFLECT((graphene::plugins::tags::tag_api_object), 31 | (name)(total_children_rshares)(total_payouts)(net_votes)(top_posts)(contents) 32 | ) 33 | #endif //CHAIN_TAG_API_OBJ_HPP 34 | -------------------------------------------------------------------------------- /plugins/test_api/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET test_api_plugin) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/test_api/test_api_plugin.hpp 5 | ) 6 | 7 | list(APPEND CURRENT_TARGET_SOURCES 8 | test_api_plugin.cpp 9 | ) 10 | 11 | if(BUILD_SHARED_LIBRARIES) 12 | add_library(graphene_${CURRENT_TARGET} SHARED 13 | ${CURRENT_TARGET_HEADERS} 14 | ${CURRENT_TARGET_SOURCES} 15 | ) 16 | else() 17 | add_library(graphene_${CURRENT_TARGET} STATIC 18 | ${CURRENT_TARGET_HEADERS} 19 | ${CURRENT_TARGET_SOURCES} 20 | ) 21 | endif() 22 | 23 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 24 | 25 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 26 | 27 | target_link_libraries( 28 | graphene_${CURRENT_TARGET} 29 | graphene::json_rpc 30 | fc 31 | appbase 32 | ) 33 | 34 | target_include_directories( 35 | graphene_${CURRENT_TARGET} 36 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 37 | "${CMAKE_CURRENT_SOURCE_DIR}/../../" 38 | ) 39 | 40 | install(TARGETS 41 | graphene_${CURRENT_TARGET} 42 | 43 | RUNTIME DESTINATION bin 44 | LIBRARY DESTINATION lib 45 | ARCHIVE DESTINATION lib 46 | ) 47 | 48 | install(FILES ${HEADERS} DESTINATION "include/graphene/test_api_plugin") 49 | 50 | 51 | #target_link_libraries( test_api_plugin plugin appbase fc ) -------------------------------------------------------------------------------- /plugins/test_api/include/graphene/plugins/test_api/test_api_plugin.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace graphene { 9 | namespace plugins { 10 | namespace test_api { 11 | 12 | using namespace appbase; 13 | using json_rpc::msg_pack; 14 | using fc::variant; 15 | 16 | struct test_api_a_t { 17 | std::string value; 18 | }; 19 | struct test_api_b_t { 20 | std::string value; 21 | }; 22 | 23 | /// API, args, return 24 | DEFINE_API_ARGS(test_api_a, msg_pack, test_api_a_t) 25 | DEFINE_API_ARGS(test_api_b, msg_pack, test_api_b_t) 26 | 27 | class test_api_plugin final : public appbase::plugin { 28 | public: 29 | test_api_plugin(); 30 | 31 | ~test_api_plugin(); 32 | 33 | constexpr static const char *plugin_name = "test_api"; 34 | 35 | APPBASE_PLUGIN_REQUIRES((json_rpc::plugin)); 36 | 37 | static const std::string &name() { 38 | static std::string name = plugin_name; 39 | return name; 40 | } 41 | 42 | void set_program_options(boost::program_options::options_description &, 43 | boost::program_options::options_description &) override { 44 | } 45 | 46 | void plugin_initialize(const boost::program_options::variables_map &options) override; 47 | 48 | void plugin_startup() override; 49 | 50 | void plugin_shutdown() override; 51 | 52 | DECLARE_API((test_api_a)(test_api_b)) 53 | }; 54 | 55 | } 56 | } 57 | } // graphene::plugins::test_api 58 | 59 | FC_REFLECT((graphene::plugins::test_api::test_api_a_t), (value)) 60 | FC_REFLECT((graphene::plugins::test_api::test_api_b_t), (value)) 61 | -------------------------------------------------------------------------------- /plugins/test_api/test_api_plugin.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace graphene { 6 | namespace plugins { 7 | namespace test_api { 8 | 9 | test_api_plugin::test_api_plugin() { 10 | } 11 | 12 | test_api_plugin::~test_api_plugin() { 13 | } 14 | 15 | void test_api_plugin::plugin_initialize(const boost::program_options::variables_map &options) { 16 | JSON_RPC_REGISTER_API(plugin_name); 17 | } 18 | 19 | void test_api_plugin::plugin_startup() { 20 | } 21 | 22 | void test_api_plugin::plugin_shutdown() { 23 | } 24 | 25 | DEFINE_API(test_api_plugin, test_api_a) { 26 | test_api_a_t result; 27 | result.value = "A"; 28 | return result; 29 | } 30 | 31 | DEFINE_API(test_api_plugin, test_api_b) { 32 | test_api_b_t result; 33 | result.value = "B"; 34 | return result; 35 | } 36 | 37 | } 38 | } 39 | } // graphene::plugins::test_api 40 | -------------------------------------------------------------------------------- /plugins/webserver/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET webserver_plugin) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/webserver/webserver_plugin.hpp 5 | ) 6 | 7 | list(APPEND CURRENT_TARGET_SOURCES 8 | webserver_plugin.cpp 9 | ) 10 | 11 | if(BUILD_SHARED_LIBRARIES) 12 | add_library(graphene_${CURRENT_TARGET} SHARED 13 | ${CURRENT_TARGET_HEADERS} 14 | ${CURRENT_TARGET_SOURCES} 15 | ) 16 | else() 17 | add_library(graphene_${CURRENT_TARGET} STATIC 18 | ${CURRENT_TARGET_HEADERS} 19 | ${CURRENT_TARGET_SOURCES} 20 | ) 21 | endif() 22 | 23 | 24 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 25 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 26 | target_link_libraries( 27 | graphene_${CURRENT_TARGET} 28 | graphene::json_rpc 29 | graphene_chain 30 | graphene::chain_plugin 31 | appbase 32 | fc) 33 | target_include_directories(graphene_${CURRENT_TARGET} 34 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/../../") 35 | 36 | install(TARGETS 37 | graphene_${CURRENT_TARGET} 38 | 39 | RUNTIME DESTINATION bin 40 | LIBRARY DESTINATION lib 41 | ARCHIVE DESTINATION lib 42 | ) 43 | -------------------------------------------------------------------------------- /plugins/webserver/include/graphene/plugins/webserver/webserver_plugin.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | 11 | #define WEBSERVER_PLUGIN_NAME "webserver" 12 | 13 | namespace graphene { 14 | namespace plugins { 15 | namespace webserver { 16 | 17 | using namespace appbase; 18 | 19 | /** 20 | * This plugin starts an HTTP/ws webserver and dispatches queries to 21 | * registered handles based on payload. The payload must be conform 22 | * to the JSONRPC 2.0 spec. 23 | * 24 | * The handler will be called from the appbase application io_service 25 | * thread. The callback can be called from any thread and will 26 | * automatically propagate the call to the http thread. 27 | * 28 | * The HTTP service will run in its own thread with its own io_service to 29 | * make sure that HTTP request processing does not interfer with other 30 | * plugins. 31 | */ 32 | class webserver_plugin final : public appbase::plugin { 33 | public: 34 | webserver_plugin(); 35 | 36 | ~webserver_plugin(); 37 | 38 | APPBASE_PLUGIN_REQUIRES((json_rpc::plugin)); 39 | 40 | static const std::string &name() { 41 | static std::string name = WEBSERVER_PLUGIN_NAME; 42 | return name; 43 | } 44 | 45 | void set_program_options(boost::program_options::options_description &, boost::program_options::options_description &cfg) override; 46 | 47 | protected: 48 | void plugin_initialize(const boost::program_options::variables_map &options) override; 49 | 50 | void plugin_startup() override; 51 | 52 | void plugin_shutdown() override; 53 | 54 | private: 55 | struct webserver_plugin_impl; 56 | std::unique_ptr my; 57 | }; 58 | 59 | } 60 | } 61 | } // graphene::plugins::webserver 62 | -------------------------------------------------------------------------------- /plugins/witness/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET witness) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/witness/witness.hpp 5 | ) 6 | 7 | list(APPEND CURRENT_TARGET_SOURCES 8 | witness.cpp 9 | ) 10 | 11 | if(BUILD_SHARED_LIBRARIES) 12 | add_library(graphene_${CURRENT_TARGET} SHARED 13 | ${CURRENT_TARGET_HEADERS} 14 | ${CURRENT_TARGET_SOURCES} 15 | ) 16 | else() 17 | add_library(graphene_${CURRENT_TARGET} STATIC 18 | ${CURRENT_TARGET_HEADERS} 19 | ${CURRENT_TARGET_SOURCES} 20 | ) 21 | endif() 22 | 23 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 24 | set_property(TARGET graphene_${CURRENT_TARGET} PROPERTY EXPORT_NAME ${CURRENT_TARGET}) 25 | 26 | target_link_libraries( 27 | graphene_${CURRENT_TARGET} 28 | graphene::chain_plugin 29 | graphene::p2p 30 | graphene::protocol 31 | graphene::network 32 | graphene_utilities 33 | graphene_time 34 | appbase 35 | ) 36 | target_include_directories(graphene_${CURRENT_TARGET} 37 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") 38 | 39 | install(TARGETS 40 | graphene_${CURRENT_TARGET} 41 | 42 | RUNTIME DESTINATION bin 43 | LIBRARY DESTINATION lib 44 | ARCHIVE DESTINATION lib 45 | ) 46 | 47 | -------------------------------------------------------------------------------- /plugins/witness/include/graphene/plugins/witness/witness.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace graphene { 12 | namespace plugins { 13 | namespace witness_plugin { 14 | 15 | using std::string; 16 | using protocol::public_key_type; 17 | using graphene::protocol::block_id_type; 18 | using graphene::chain::signed_block; 19 | 20 | namespace block_production_condition { 21 | enum block_production_condition_enum { 22 | produced = 0, 23 | not_synced = 1, 24 | not_my_turn = 2, 25 | not_time_yet = 3, 26 | no_private_key = 4, 27 | low_participation = 5, 28 | lag = 6, 29 | consecutive = 7, 30 | exception_producing_block = 8 31 | }; 32 | } 33 | 34 | class witness_plugin final : public appbase::plugin { 35 | public: 36 | APPBASE_PLUGIN_REQUIRES((chain::plugin) (p2p::p2p_plugin)) 37 | 38 | constexpr static const char *plugin_name = "witness"; 39 | 40 | static const std::string &name() { 41 | static std::string name = plugin_name; 42 | return name; 43 | } 44 | 45 | witness_plugin(); 46 | 47 | ~witness_plugin(); 48 | 49 | 50 | void set_program_options(boost::program_options::options_description &command_line_options, 51 | boost::program_options::options_description &config_file_options) override; 52 | 53 | void set_block_production(bool allow); 54 | 55 | void plugin_initialize(const boost::program_options::variables_map &options) override; 56 | 57 | void plugin_startup() override; 58 | 59 | void plugin_shutdown() override; 60 | 61 | private: 62 | struct impl; 63 | std::unique_ptr pimpl; 64 | 65 | }; 66 | 67 | } 68 | } 69 | } //graphene::witness_plugin 70 | -------------------------------------------------------------------------------- /plugins/witness_api/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET witness_api) 2 | 3 | list(APPEND CURRENT_TARGET_HEADERS 4 | include/graphene/plugins/witness_api/plugin.hpp 5 | include/graphene/plugins/witness_api/api_objects/feed_history_api_object.hpp 6 | ) 7 | 8 | list(APPEND CURRENT_TARGET_SOURCES 9 | plugin.cpp 10 | ) 11 | 12 | if (BUILD_SHARED_LIBRARIES) 13 | add_library(graphene_${CURRENT_TARGET} SHARED 14 | ${CURRENT_TARGET_HEADERS} 15 | ${CURRENT_TARGET_SOURCES} 16 | ) 17 | else() 18 | add_library(graphene_${CURRENT_TARGET} STATIC 19 | ${CURRENT_TARGET_HEADERS} 20 | ${CURRENT_TARGET_SOURCES} 21 | ) 22 | endif() 23 | 24 | add_library(graphene::${CURRENT_TARGET} ALIAS graphene_${CURRENT_TARGET}) 25 | 26 | target_link_libraries ( 27 | graphene_${CURRENT_TARGET} 28 | graphene_chain 29 | graphene_chain_plugin 30 | graphene_protocol 31 | graphene_api 32 | appbase 33 | graphene_json_rpc 34 | graphene_time 35 | chainbase 36 | fc 37 | ) 38 | 39 | target_include_directories(graphene_${CURRENT_TARGET} 40 | PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" 41 | "${CMAKE_CURRENT_SOURCE_DIR}/../../" 42 | ) 43 | 44 | install(TARGETS 45 | graphene_${CURRENT_TARGET} 46 | 47 | RUNTIME DESTINATION bin 48 | LIBRARY DESTINATION lib 49 | ARCHIVE DESTINATION lib 50 | ) -------------------------------------------------------------------------------- /plugins/witness_api/include/graphene/plugins/witness_api/api_objects/feed_history_api_object.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace graphene { namespace plugins { namespace witness_api { 6 | 7 | using namespace graphene::chain; 8 | using namespace graphene::protocol; 9 | 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /programs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(build_helpers) 2 | add_subdirectory(cli_wallet) 3 | add_subdirectory(vizd) 4 | #add_subdirectory( delayed_node ) 5 | add_subdirectory(js_operation_serializer) 6 | add_subdirectory(size_checker) 7 | add_subdirectory(util) 8 | -------------------------------------------------------------------------------- /programs/build_helpers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(cat-parts cat-parts.cpp) 2 | if(UNIX AND NOT APPLE) 3 | set(rt_library rt) 4 | endif() 5 | 6 | # we only actually need Boost, but link against FC for now so we don't duplicate it. 7 | target_link_libraries(cat-parts PRIVATE fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS}) 8 | -------------------------------------------------------------------------------- /programs/build_helpers/cat-parts.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | int main(int argc, char **argv, char **envp) { 8 | if (argc != 3) { 9 | std::cerr << "syntax: cat-parts DIR OUTFILE" << std::endl; 10 | return 1; 11 | } 12 | 13 | boost::filesystem::path p(argv[1]); 14 | 15 | try { 16 | std::vector v; 17 | 18 | for (boost::filesystem::directory_iterator it(p); 19 | it != boost::filesystem::directory_iterator(); 20 | ++it) { 21 | boost::filesystem::path pit = it->path(); 22 | std::string spit = pit.generic_string(); 23 | size_t n = spit.length(); 24 | if (n <= 3) { 25 | continue; 26 | } 27 | if (spit.substr(n - 3, 3) != ".hf") { 28 | continue; 29 | } 30 | v.push_back(pit); 31 | } 32 | std::sort(v.begin(), v.end()); 33 | 34 | // open each file and grab its contents, concatenating into single stringstream 35 | std::stringstream ss_data; 36 | for (const boost::filesystem::path &p : v) { 37 | boost::filesystem::ifstream ifs(p); 38 | ss_data << ifs.rdbuf(); 39 | } 40 | std::string new_data = ss_data.str(); 41 | 42 | boost::filesystem::path opath(argv[2]); 43 | 44 | if (boost::filesystem::exists(opath)) { 45 | boost::filesystem::ifstream ifs(opath); 46 | std::stringstream ss_old_data; 47 | ss_old_data << ifs.rdbuf(); 48 | std::string old_data = ss_old_data.str(); 49 | if (old_data == new_data) { 50 | std::cerr << "File " << opath << " up-to-date with .d directory" 51 | << std::endl; 52 | return 0; 53 | } 54 | } 55 | 56 | { 57 | boost::filesystem::ofstream ofs(opath); 58 | ofs.write(new_data.c_str(), new_data.length()); 59 | } 60 | 61 | std::cerr << "Built " << opath << " from .d directory" << std::endl; 62 | } 63 | catch (const boost::filesystem::filesystem_error &e) { 64 | std::cout << e.what() << std::endl; 65 | return 1; 66 | } 67 | return 0; 68 | } -------------------------------------------------------------------------------- /programs/build_helpers/cat_parts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | from pathlib import Path 5 | 6 | 7 | def print_usage(program_name): 8 | print("usage: {} DIR OUTFILE".format(program_name)) 9 | 10 | 11 | def generate_concatenated_outfile(input_dir, suffix_filter="hf"): 12 | def predicate(path): 13 | if not path.is_file(): 14 | return false 15 | if suffix_filter == "": 16 | return true 17 | else: 18 | return path.suffix == ("." + suffix_filter) 19 | 20 | input_files = [p for p in input_dir.iterdir() if predicate(p)] 21 | output = "" 22 | for p in sorted(input_files): 23 | with p.open(mode='r') as f: 24 | output += f.read() 25 | return output 26 | 27 | 28 | def main(program_name, args): 29 | if len(args) < 2: 30 | print_usage(program_name) 31 | return 1 32 | 33 | input_dir = Path(args[0]) 34 | if not input_dir.is_dir(): 35 | print_usage(program_name) 36 | return 1 37 | 38 | out_file = Path(args[1]) 39 | if out_file.exists(): 40 | if not out_file.is_file(): 41 | print('Chosen OUTFILE "{}" is not a file'.format( 42 | out_file.absolute().as_posix())) 43 | return 1 44 | new_outfile_contents = generate_concatenated_outfile(input_dir) 45 | with out_file.open(mode='r') as f: 46 | if f.read() == new_outfile_contents: 47 | print('File "{}" up-to-date with .d directory'.format(out_file)) 48 | return 0 49 | else: 50 | if not out_file.parent.exists(): 51 | try: 52 | out_file.parent.mkdir(parents=True) 53 | except FileExistsError: 54 | pass 55 | except: 56 | print( 57 | 'Unexpected error occured while trying to create directory "{}"'.format( 58 | out_file.parent.absolute().as_posix())) 59 | raise 60 | elif not out_file.parent.is_dir(): 61 | print('"{}" is not a directory'.format( 62 | out_file.parent.absolute().as_posix())) 63 | return 1 64 | new_outfile_contents = generate_concatenated_outfile(input_dir) 65 | 66 | with out_file.open(mode='w') as f: 67 | f.write(new_outfile_contents) 68 | print('Built "{}" from .d directory'.format(out_file)) 69 | return 0 70 | 71 | 72 | if __name__ == "__main__": 73 | sys.exit(main(sys.argv[0], sys.argv[1:])) 74 | -------------------------------------------------------------------------------- /programs/cli_wallet/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(cli_wallet main.cpp) 2 | if(UNIX AND NOT APPLE) 3 | set(rt_library rt) 4 | endif() 5 | 6 | if(APPLE) 7 | list(APPEND PLATFORM_SPECIFIC_LIBS readline) 8 | endif() 9 | 10 | find_package(Gperftools QUIET) 11 | if(GPERFTOOLS_FOUND) 12 | message(STATUS "Found gperftools; compiling cli_wallet with TCMalloc") 13 | list(APPEND PLATFORM_SPECIFIC_LIBS tcmalloc) 14 | endif() 15 | 16 | FIND_PACKAGE(Boost REQUIRED COMPONENTS 17 | regex 18 | ) 19 | 20 | # I don't know why graphene_app is required twice in the following line, I just know the linker breaks if it isn't. 21 | target_link_libraries( 22 | cli_wallet 23 | PRIVATE 24 | graphene_network 25 | graphene_chain 26 | graphene_protocol 27 | graphene_utilities 28 | graphene_wallet 29 | graphene::database_api 30 | graphene::account_history 31 | graphene::social_network 32 | graphene::private_message 33 | graphene::follow 34 | graphene::network_broadcast_api 35 | graphene::witness_api 36 | fc 37 | ${readline_libraries} 38 | ${CMAKE_DL_LIBS} 39 | ${PLATFORM_SPECIFIC_LIBS} 40 | ${Boost_LIBRARIES} 41 | ) 42 | 43 | if(MSVC) 44 | set_source_files_properties(main.cpp PROPERTIES COMPILE_FLAGS "/bigobj") 45 | endif(MSVC) 46 | 47 | install(TARGETS 48 | cli_wallet 49 | 50 | RUNTIME DESTINATION bin 51 | LIBRARY DESTINATION lib 52 | ARCHIVE DESTINATION lib 53 | ) 54 | -------------------------------------------------------------------------------- /programs/js_operation_serializer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(js_operation_serializer main.cpp) 2 | if(UNIX AND NOT APPLE) 3 | set(rt_library rt) 4 | endif() 5 | 6 | target_link_libraries(js_operation_serializer 7 | PRIVATE graphene_chain graphene_protocol graphene_utilities fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS}) 8 | 9 | install(TARGETS 10 | js_operation_serializer 11 | 12 | RUNTIME DESTINATION bin 13 | LIBRARY DESTINATION lib 14 | ARCHIVE DESTINATION lib 15 | ) 16 | -------------------------------------------------------------------------------- /programs/size_checker/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(size_checker main.cpp) 2 | if(UNIX AND NOT APPLE) 3 | set(rt_library rt) 4 | endif() 5 | 6 | target_link_libraries(size_checker 7 | PRIVATE graphene_chain graphene_protocol fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS}) 8 | 9 | install(TARGETS 10 | size_checker 11 | 12 | RUNTIME DESTINATION bin 13 | LIBRARY DESTINATION lib 14 | ARCHIVE DESTINATION lib 15 | ) 16 | -------------------------------------------------------------------------------- /programs/util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(get_dev_key get_dev_key.cpp) 2 | 3 | target_link_libraries(get_dev_key 4 | PRIVATE graphene_chain graphene_protocol graphene_utilities fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS}) 5 | 6 | install(TARGETS 7 | get_dev_key 8 | 9 | RUNTIME DESTINATION bin 10 | LIBRARY DESTINATION lib 11 | ARCHIVE DESTINATION lib 12 | ) 13 | 14 | 15 | add_executable(test_shared_mem test_shared_mem.cpp) 16 | 17 | target_link_libraries(test_shared_mem 18 | PRIVATE graphene_chain graphene_protocol graphene_utilities fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS}) 19 | 20 | add_executable(sign_digest sign_digest.cpp) 21 | 22 | target_link_libraries(sign_digest 23 | PRIVATE graphene_chain graphene_protocol graphene_utilities fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS}) 24 | 25 | install(TARGETS 26 | sign_digest 27 | 28 | RUNTIME DESTINATION bin 29 | LIBRARY DESTINATION lib 30 | ARCHIVE DESTINATION lib 31 | ) 32 | 33 | add_executable(sign_transaction sign_transaction.cpp) 34 | 35 | target_link_libraries(sign_transaction 36 | PRIVATE graphene_chain graphene_protocol graphene_utilities fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS}) 37 | 38 | install(TARGETS 39 | sign_transaction 40 | 41 | RUNTIME DESTINATION bin 42 | LIBRARY DESTINATION lib 43 | ARCHIVE DESTINATION lib 44 | ) 45 | 46 | #add_executable( schema_test schema_test.cpp ) 47 | #target_link_libraries( schema_test 48 | # PRIVATE graphene_chain fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) 49 | # 50 | #install( TARGETS 51 | # schema_test 52 | # 53 | # RUNTIME DESTINATION bin 54 | # LIBRARY DESTINATION lib 55 | # ARCHIVE DESTINATION lib 56 | #) 57 | 58 | add_executable(test_block_log test_block_log.cpp) 59 | target_link_libraries(test_block_log 60 | PRIVATE graphene_chain graphene_protocol fc ${CMAKE_DL_LIB} ${PLATFORM_SPECIFIC_LIBS}) 61 | 62 | install(TARGETS 63 | test_block_log 64 | 65 | RUNTIME DESTINATION bin 66 | LIBRARY DESTINATION lib 67 | ARCHIVE DESTINATION lib 68 | ) 69 | -------------------------------------------------------------------------------- /programs/util/inflation_plot.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import json 4 | import matplotlib 5 | import sys 6 | 7 | matplotlib.use("Agg") 8 | 9 | import matplotlib.pyplot as plt 10 | from matplotlib.ticker import AutoMinorLocator 11 | 12 | x = [] 13 | y = [] 14 | 15 | names = ["curate", "content", "producer", "liquidity", "pow"] 16 | inflections = {} 17 | markers = [] 18 | 19 | colors = iter("mgbr") 20 | shapes = iter("ovx+") 21 | 22 | ax = plt.gca() 23 | 24 | plt.axis([0, 10, 5e9, 320e9]) 25 | ax.set_xticks(range(11)) 26 | ax.xaxis.set_minor_locator(AutoMinorLocator(12)) 27 | ax.set_yscale("log") 28 | ax.tick_params(axis="y", which="minor", left="off", right="off") 29 | ax.set_yticks( 30 | [10e6, 20e6, 40e6, 80e6, 160e6, 320e6, 640e6, 1300e6, 2600e6, 5200e6, 10e9, 31 | 20e9, 40e9, 80e9, 160e9, 320e9]) 32 | ax.set_yticklabels( 33 | ["10M", "20M", "40M", "80M", "160M", "320M", "640M", "1.3B", "2.6B", "5.2B", 34 | "10B", "20B", "40B", "80B", "160B", "320B"]) 35 | plt.grid(True, which="major", linestyle="-") 36 | ax.xaxis.grid(True, which="minor", linestyle="-", color="g") 37 | 38 | BLOCKS_PER_YEAR = 20 * 60 * 24 * 365 39 | 40 | with open(sys.argv[1], "r") as f: 41 | n = 0 42 | for line in f: 43 | n += 1 44 | d = json.loads(line) 45 | b = int(d["b"]) 46 | s = int(d["s"]) 47 | 48 | if (b % 10000) != 0: 49 | continue 50 | 51 | px = b / BLOCKS_PER_YEAR 52 | py = s / 1000 53 | 54 | x.append(px) 55 | y.append(py) 56 | for i in range(len(names)): 57 | if i == 1: 58 | continue 59 | if names[i] in inflections: 60 | continue 61 | if (int(d["rvec"][i * 2]) % 1000) == 0: 62 | continue 63 | inflections[names[i]] = d["b"] 64 | markers.append([[[px], [py], next(colors) + next(shapes)], 65 | {"label": names[i]}]) 66 | 67 | plt.plot(x, y) 68 | for m in markers: 69 | print(m) 70 | plt.plot(*m[0], **m[1]) 71 | plt.legend(loc=4) 72 | plt.title("10-year supply projection") 73 | plt.savefig("myfig.png") 74 | -------------------------------------------------------------------------------- /programs/util/pretty_schema.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import itertools 4 | import json 5 | import requests 6 | 7 | id_count = itertools.count(1) 8 | 9 | result = requests.post("http://127.0.0.1:18390", data=json.dumps( 10 | {"jsonrpc": "2.0", "method": "call", 11 | "params": ["debug_node_api", "debug_get_json_schema", []], 12 | "id": next(id_count)})) 13 | str_schema = result.json()["result"] 14 | schema = json.loads(str_schema) 15 | 16 | 17 | def maybe_json(s): 18 | try: 19 | return json.loads(s) 20 | except ValueError: 21 | return s 22 | 23 | 24 | new_types = {k: maybe_json(v) for k, v in schema["types"].items()} 25 | schema["types"] = new_types 26 | 27 | print(json.dumps(schema, indent=3, sort_keys=True)) 28 | -------------------------------------------------------------------------------- /programs/util/saltpass.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import base64 4 | import getpass 5 | import hashlib 6 | import json 7 | import os 8 | 9 | pw = getpass.getpass("enter your password: ") 10 | pw_bytes = pw.encode("utf-8") 11 | salt_bytes = os.urandom(8) 12 | salt_b64 = base64.b64encode(salt_bytes) 13 | pw_hash = hashlib.sha256(pw_bytes + salt_bytes).digest() 14 | pw_hash_b64 = base64.b64encode(pw_hash) 15 | 16 | print(json.dumps( 17 | { 18 | "password_hash_b64": pw_hash_b64.decode("ascii"), 19 | "password_salt_b64": salt_b64.decode("ascii"), 20 | }, 21 | sort_keys=True, 22 | indent=3, separators=(',', ' : ') 23 | )) 24 | -------------------------------------------------------------------------------- /programs/util/schema_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | using namespace graphene::db; 14 | 15 | struct mystruct { 16 | std::string alpha; 17 | uint64_t beta; 18 | }; 19 | 20 | FC_REFLECT(mystruct, 21 | (alpha) 22 | (beta) 23 | ); 24 | 25 | void process(std::shared_ptr s) { 26 | std::string name; 27 | s->get_name(name); 28 | std::cout << " name = " << name; 29 | std::vector> deps; 30 | s->get_deps(deps); 31 | std::vector dep_names; 32 | for (const std::shared_ptr &s : deps) { 33 | std::string s_name; 34 | s->get_name(s_name); 35 | dep_names.push_back(s_name); 36 | } 37 | std::cout << " deps = " << fc::json::to_string(dep_names); 38 | std::string str_schema; 39 | s->get_str_schema(str_schema); 40 | std::cout << " s = " << str_schema; 41 | std::cout << std::endl; 42 | } 43 | 44 | int main(int argc, char **argv, char **envp) { 45 | std::vector> schemas; 46 | 47 | schemas.push_back(get_schema_for_type()); 48 | schemas.push_back(get_schema_for_type()); 49 | add_dependent_schemas(schemas); 50 | 51 | for (const std::shared_ptr &s : schemas) { 52 | process(s); 53 | } 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /programs/util/sign_digest.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | 12 | struct signing_request { 13 | fc::sha256 dig; 14 | std::string wif; 15 | }; 16 | 17 | struct signing_result { 18 | fc::sha256 dig; 19 | graphene::protocol::public_key_type key; 20 | graphene::protocol::signature_type sig; 21 | }; 22 | 23 | FC_REFLECT((signing_request), (dig)(wif)) 24 | FC_REFLECT((signing_result), (dig)(key)(sig)) 25 | 26 | int main(int argc, char **argv, char **envp) { 27 | // hash key pairs on stdin 28 | std::string chain_id, hash, wif; 29 | while (std::cin) { 30 | std::string line; 31 | std::getline(std::cin, line); 32 | boost::trim(line); 33 | if (line == "") { 34 | continue; 35 | } 36 | 37 | fc::variant v = fc::json::from_string(line, fc::json::strict_parser); 38 | signing_request sreq; 39 | fc::from_variant(v, sreq); 40 | signing_result sres; 41 | sres.dig = sreq.dig; 42 | fc::ecc::private_key priv_key = *graphene::utilities::wif_to_key(sreq.wif); 43 | sres.sig = priv_key.sign_compact(sreq.dig); 44 | sres.key = graphene::protocol::public_key_type(priv_key.get_public_key()); 45 | std::cout << fc::json::to_string(sres) << std::endl; 46 | } 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /programs/util/sign_transaction.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | 12 | struct tx_signing_request { 13 | graphene::protocol::transaction tx; 14 | std::string wif; 15 | }; 16 | 17 | struct tx_signing_result { 18 | graphene::protocol::transaction tx; 19 | fc::sha256 digest; 20 | fc::sha256 sig_digest; 21 | graphene::protocol::public_key_type key; 22 | graphene::protocol::signature_type sig; 23 | }; 24 | 25 | FC_REFLECT((tx_signing_request), (tx)(wif)) 26 | FC_REFLECT((tx_signing_result), (digest)(sig_digest)(key)(sig)) 27 | 28 | int main(int argc, char **argv, char **envp) { 29 | // hash key pairs on stdin 30 | std::string chain_id, hash, wif; 31 | while (std::cin) { 32 | std::string line; 33 | std::getline(std::cin, line); 34 | boost::trim(line); 35 | if (line == "") { 36 | continue; 37 | } 38 | 39 | fc::variant v = fc::json::from_string(line, fc::json::strict_parser); 40 | tx_signing_request sreq; 41 | fc::from_variant(v, sreq); 42 | tx_signing_result sres; 43 | sres.tx = sreq.tx; 44 | sres.digest = sreq.tx.digest(); 45 | sres.sig_digest = sreq.tx.sig_digest(CHAIN_ID); 46 | 47 | fc::ecc::private_key priv_key = *graphene::utilities::wif_to_key(sreq.wif); 48 | sres.sig = priv_key.sign_compact(sres.sig_digest); 49 | sres.key = graphene::protocol::public_key_type(priv_key.get_public_key()); 50 | std::cout << fc::json::to_string(sres) << std::endl; 51 | } 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /programs/util/test_block_log.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv, char **envp) { 4 | try { 5 | //graphene::chain::database db; 6 | graphene::chain::block_log log; 7 | 8 | fc::temp_directory temp_dir("."); 9 | 10 | //db.open( temp_dir ); 11 | log.open(temp_dir.path() / "log"); 12 | 13 | idump((log.head())); 14 | 15 | graphene::protocol::signed_block b1; 16 | b1.witness = "alice"; 17 | b1.previous = graphene::protocol::block_id_type(); 18 | 19 | log.append(b1); 20 | log.flush(); 21 | idump((b1)); 22 | idump((log.head())); 23 | idump((fc::raw::pack_size(b1))); 24 | 25 | graphene::protocol::signed_block b2; 26 | b2.witness = "bob"; 27 | b2.previous = b1.id(); 28 | 29 | log.append(b2); 30 | log.flush(); 31 | idump((b2)); 32 | idump((log.head())); 33 | idump((fc::raw::pack_size(b2))); 34 | 35 | auto r1 = log.read_block(0); 36 | idump((r1)); 37 | idump((fc::raw::pack_size(r1.first))); 38 | 39 | auto r2 = log.read_block(r1.second); 40 | idump((r2)); 41 | idump((fc::raw::pack_size(r2.first))); 42 | 43 | idump((log.read_head())); 44 | idump((fc::raw::pack_size(log.read_head()))); 45 | 46 | auto r3 = log.read_block(r2.second); 47 | idump((r3)); 48 | } 49 | catch (const std::exception &e) { 50 | edump((std::string(e.what()))); 51 | } 52 | 53 | return 0; 54 | } -------------------------------------------------------------------------------- /programs/vizd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CURRENT_TARGET vizd) 2 | add_executable(${CURRENT_TARGET} main.cpp) 3 | 4 | if(UNIX AND NOT APPLE) 5 | set(rt_library rt) 6 | elseif(APPLE) 7 | list(APPEND PLATFORM_SPECIFIC_LIBS readline) 8 | endif() 9 | 10 | find_package(Gperftools QUIET) 11 | if(GPERFTOOLS_FOUND) 12 | message(STATUS "Found gperftools; compiling vizd with TCMalloc") 13 | list(APPEND PLATFORM_SPECIFIC_LIBS tcmalloc) 14 | endif() 15 | 16 | target_link_libraries( 17 | ${CURRENT_TARGET} PRIVATE 18 | appbase 19 | graphene::webserver_plugin 20 | graphene::p2p 21 | graphene_utilities 22 | graphene::chain_plugin 23 | graphene::network_broadcast_api 24 | graphene::witness 25 | graphene::witness_api 26 | graphene::database_api 27 | graphene::test_api_plugin 28 | graphene::social_network 29 | graphene::tags 30 | graphene::operation_history 31 | graphene::account_by_key 32 | graphene::account_history 33 | graphene::private_message 34 | graphene::auth_util 35 | graphene::debug_node 36 | graphene::raw_block 37 | graphene::block_info 38 | graphene::json_rpc 39 | graphene::follow 40 | graphene::committee_api 41 | graphene::invite_api 42 | graphene::paid_subscription_api 43 | graphene::custom_protocol_api 44 | ${MONGO_LIB} 45 | graphene_protocol 46 | fc 47 | ${CMAKE_DL_LIBS} 48 | ${PLATFORM_SPECIFIC_LIBS} 49 | ) 50 | 51 | install(TARGETS 52 | ${CURRENT_TARGET} 53 | 54 | RUNTIME DESTINATION bin 55 | LIBRARY DESTINATION lib 56 | ARCHIVE DESTINATION lib 57 | ) 58 | -------------------------------------------------------------------------------- /share/vizd/docker/Dockerfile-lowmem: -------------------------------------------------------------------------------- 1 | FROM phusion/baseimage:0.9.19 as builder 2 | 3 | ENV LANG=en_US.UTF-8 4 | ENV APPDIR /usr/local/src/viz/ 5 | ENV HOME /var/lib/vizd 6 | 7 | RUN \ 8 | apt-get update && \ 9 | apt-get install -y \ 10 | autoconf \ 11 | automake \ 12 | autotools-dev \ 13 | bsdmainutils \ 14 | build-essential \ 15 | cmake \ 16 | doxygen \ 17 | git \ 18 | ccache\ 19 | libboost-all-dev \ 20 | libreadline-dev \ 21 | libssl-dev \ 22 | libtool \ 23 | ncurses-dev \ 24 | pbzip2 \ 25 | pkg-config \ 26 | python3 \ 27 | python3-dev \ 28 | python3-pip && \ 29 | pip3 install gcovr 30 | 31 | # Explicitly copy needed files to avoid re-building when changing other files 32 | COPY .git $APPDIR/.git 33 | COPY .gitignore .gitmodules CMakeLists.txt Doxyfile $APPDIR/ 34 | COPY programs $APPDIR/programs 35 | COPY thirdparty $APPDIR/thirdparty 36 | COPY plugins $APPDIR/plugins 37 | COPY libraries $APPDIR/libraries 38 | 39 | RUN \ 40 | cd $APPDIR && \ 41 | git submodule deinit -f . && \ 42 | git submodule update --init --recursive -f && \ 43 | mkdir build && \ 44 | cd build && \ 45 | cmake \ 46 | -DCMAKE_BUILD_TYPE=Release \ 47 | -DBUILD_SHARED_LIBRARIES=FALSE \ 48 | -DLOW_MEMORY_NODE=TRUE \ 49 | -DCHAINBASE_CHECK_LOCKING=FALSE \ 50 | -DENABLE_MONGO_PLUGIN=FALSE \ 51 | .. \ 52 | && \ 53 | make -j$(nproc) 54 | 55 | RUN set -xe ;\ 56 | cd $APPDIR/build ;\ 57 | make install ;\ 58 | rm -rf $APPDIR 59 | 60 | FROM phusion/baseimage:0.9.19 61 | COPY --from=builder /usr/local /usr/local 62 | 63 | RUN set -xe ;\ 64 | useradd -s /bin/bash -m -d /var/lib/vizd vizd ;\ 65 | mkdir /var/cache/vizd ;\ 66 | chown vizd:vizd -R /var/cache/vizd 67 | 68 | COPY share/vizd/vizd.sh /etc/service/vizd/run 69 | COPY share/vizd/snapshot.json /var/lib/vizd 70 | COPY share/vizd/config/config.ini /etc/vizd/config.ini 71 | COPY share/vizd/seednodes /etc/vizd/seednodes 72 | 73 | # rpc services: 74 | # http 75 | EXPOSE 8090 76 | # ws 77 | EXPOSE 8091 78 | # p2p service: 79 | EXPOSE 2001 80 | 81 | VOLUME ["/var/lib/vizd", "/etc/vizd"] 82 | -------------------------------------------------------------------------------- /share/vizd/docker/Dockerfile-production: -------------------------------------------------------------------------------- 1 | FROM phusion/baseimage:bionic-1.0.0 as builder 2 | 3 | ENV LANG=en_US.UTF-8 4 | ENV APPDIR /usr/local/src/viz/ 5 | ENV HOME /var/lib/vizd 6 | 7 | RUN \ 8 | apt-get update && \ 9 | apt-get install -y \ 10 | autoconf \ 11 | automake \ 12 | autotools-dev \ 13 | binutils \ 14 | bsdmainutils \ 15 | build-essential \ 16 | cmake \ 17 | doxygen \ 18 | git \ 19 | ccache \ 20 | libboost-all-dev \ 21 | libreadline-dev \ 22 | libssl-dev \ 23 | libtool \ 24 | ncurses-dev \ 25 | pbzip2 \ 26 | pkg-config \ 27 | python3 \ 28 | python3-dev \ 29 | python3-pip && \ 30 | pip3 install gcovr 31 | 32 | # Explicitly copy needed files to avoid re-building when changing other files 33 | COPY .git $APPDIR/.git 34 | COPY .gitignore .gitmodules CMakeLists.txt Doxyfile $APPDIR/ 35 | COPY programs $APPDIR/programs 36 | COPY thirdparty $APPDIR/thirdparty 37 | COPY plugins $APPDIR/plugins 38 | COPY libraries $APPDIR/libraries 39 | 40 | RUN \ 41 | cd $APPDIR && \ 42 | git submodule deinit -f . && \ 43 | git submodule update --init --recursive -f && \ 44 | mkdir build && \ 45 | cd build && \ 46 | cmake \ 47 | -DCMAKE_BUILD_TYPE=Release \ 48 | -DBUILD_SHARED_LIBRARIES=FALSE \ 49 | -DLOW_MEMORY_NODE=FALSE \ 50 | -DCHAINBASE_CHECK_LOCKING=FALSE \ 51 | -DENABLE_MONGO_PLUGIN=FALSE \ 52 | .. \ 53 | && \ 54 | make -j$(nproc) 55 | 56 | RUN set -xe ;\ 57 | cd $APPDIR/build ;\ 58 | make install ;\ 59 | rm -rf $APPDIR 60 | 61 | RUN \ 62 | apt-get clean && \ 63 | apt-get autoremove -y && \ 64 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/cache/* 65 | 66 | FROM phusion/baseimage:bionic-1.0.0 as production 67 | COPY --from=builder /usr/local /usr/local 68 | 69 | RUN set -xe ;\ 70 | useradd -s /bin/bash -m -d /var/lib/vizd vizd ;\ 71 | mkdir /var/cache/vizd ;\ 72 | chown vizd:vizd -R /var/cache/vizd 73 | 74 | COPY share/vizd/vizd.sh /etc/service/vizd/run 75 | COPY share/vizd/snapshot.json /var/lib/vizd 76 | COPY share/vizd/config/config.ini /etc/vizd/config.ini 77 | COPY share/vizd/seednodes /etc/vizd/seednodes 78 | 79 | # rpc services: 80 | # http 81 | EXPOSE 8090 82 | # ws 83 | EXPOSE 8091 84 | # p2p service: 85 | EXPOSE 2001 86 | 87 | VOLUME ["/var/lib/vizd", "/etc/vizd"] 88 | -------------------------------------------------------------------------------- /share/vizd/docker/Dockerfile-testnet: -------------------------------------------------------------------------------- 1 | FROM phusion/baseimage:bionic-1.0.0 as builder 2 | 3 | ENV LANG=en_US.UTF-8 4 | ENV APPDIR /usr/local/src/viz/ 5 | ENV HOME /var/lib/vizd 6 | 7 | RUN \ 8 | apt-get update && \ 9 | apt-get install -y \ 10 | autoconf \ 11 | automake \ 12 | autotools-dev \ 13 | binutils \ 14 | bsdmainutils \ 15 | build-essential \ 16 | cmake \ 17 | doxygen \ 18 | git \ 19 | ccache \ 20 | libboost-all-dev \ 21 | libreadline-dev \ 22 | libssl-dev \ 23 | libtool \ 24 | ncurses-dev \ 25 | pbzip2 \ 26 | pkg-config \ 27 | python3 \ 28 | python3-dev \ 29 | python3-pip && \ 30 | pip3 install gcovr 31 | 32 | # Explicitly copy needed files to avoid re-building when changing other files 33 | COPY .git $APPDIR/.git 34 | COPY .gitignore .gitmodules CMakeLists.txt Doxyfile $APPDIR/ 35 | COPY programs $APPDIR/programs 36 | COPY thirdparty $APPDIR/thirdparty 37 | COPY plugins $APPDIR/plugins 38 | COPY libraries $APPDIR/libraries 39 | 40 | RUN \ 41 | cd $APPDIR && \ 42 | git submodule deinit -f . && \ 43 | git submodule update --init --recursive -f && \ 44 | mkdir build && \ 45 | cd build && \ 46 | cmake \ 47 | -DCMAKE_BUILD_TYPE=Release \ 48 | -DBUILD_SHARED_LIBRARIES=FALSE \ 49 | -DBUILD_TESTNET=TRUE \ 50 | -DLOW_MEMORY_NODE=FALSE \ 51 | -DCHAINBASE_CHECK_LOCKING=FALSE \ 52 | -DENABLE_MONGO_PLUGIN=FALSE \ 53 | .. \ 54 | && \ 55 | make -j$(nproc) 56 | 57 | RUN set -xe ;\ 58 | cd $APPDIR/build ;\ 59 | make install ;\ 60 | rm -rf $APPDIR 61 | 62 | RUN \ 63 | apt-get clean && \ 64 | apt-get autoremove -y && \ 65 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/cache/* 66 | 67 | FROM phusion/baseimage:bionic-1.0.0 as production 68 | COPY --from=builder /usr/local /usr/local 69 | 70 | RUN set -xe ;\ 71 | useradd -s /bin/bash -m -d /var/lib/vizd vizd ;\ 72 | mkdir /var/cache/vizd ;\ 73 | chown vizd:vizd -R /var/cache/vizd 74 | 75 | COPY share/vizd/vizd.sh /etc/service/vizd/run 76 | COPY share/vizd/snapshot-testnet.json /var/lib/vizd/snapshot.json 77 | COPY share/vizd/config/config_testnet.ini /etc/vizd/config.ini 78 | 79 | # rpc services: 80 | # http 81 | EXPOSE 8090 82 | # ws 83 | EXPOSE 8091 84 | # p2p service: 85 | EXPOSE 2001 86 | 87 | VOLUME ["/var/lib/vizd", "/etc/vizd"] 88 | -------------------------------------------------------------------------------- /share/vizd/seednodes: -------------------------------------------------------------------------------- 1 | 116.203.64.42:2001 2 | 95.217.177.173:2001 3 | 65.108.61.129:2001 4 | 178.20.47.231:2001 5 | viz1.lexai.host:2001 6 | -------------------------------------------------------------------------------- /share/vizd/seednodes_empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIZ-Blockchain/viz-cpp-node/786afa351fb24bfa7353578bdf6a88e5687ee8ca/share/vizd/seednodes_empty -------------------------------------------------------------------------------- /share/vizd/snapshot-testnet.json: -------------------------------------------------------------------------------- 1 | { 2 | "accounts": [ 3 | { 4 | "login":"alice", 5 | "public_key":"VIZ5zTAE2hiGcqYaDTQeEBqTtPeoWtSNjpznwmbvqJXesrK1Qn3e8", 6 | "shares_amount":"100000000" 7 | }, 8 | { 9 | "login":"bob", 10 | "public_key":"VIZ5zTAE2hiGcqYaDTQeEBqTtPeoWtSNjpznwmbvqJXesrK1Qn3e8", 11 | "shares_amount":"100000000" 12 | }, 13 | { 14 | "login":"charlie", 15 | "public_key":"VIZ5zTAE2hiGcqYaDTQeEBqTtPeoWtSNjpznwmbvqJXesrK1Qn3e8", 16 | "shares_amount":"100000000" 17 | }, 18 | { 19 | "login":"chuck", 20 | "public_key":"VIZ5zTAE2hiGcqYaDTQeEBqTtPeoWtSNjpznwmbvqJXesrK1Qn3e8", 21 | "shares_amount":"100000000" 22 | }, 23 | { 24 | "login":"dan", 25 | "public_key":"VIZ5zTAE2hiGcqYaDTQeEBqTtPeoWtSNjpznwmbvqJXesrK1Qn3e8", 26 | "shares_amount":"100000000" 27 | }, 28 | { 29 | "login":"frank", 30 | "public_key":"VIZ5zTAE2hiGcqYaDTQeEBqTtPeoWtSNjpznwmbvqJXesrK1Qn3e8", 31 | "shares_amount":"100000000" 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /share/vizd/vizd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export HOME="/var/lib/vizd" 4 | 5 | VIZD="/usr/local/bin/vizd" 6 | 7 | chown -R vizd:vizd $HOME 8 | 9 | # seed nodes come from documentation/seednodes which is 10 | # installed by docker into /etc/vizd/seednodes 11 | SEED_NODES="$(cat /etc/vizd/seednodes | awk -F' ' '{print $1}')" 12 | 13 | ARGS="" 14 | 15 | # if user did not pass in any desired 16 | # seed nodes, use the ones above: 17 | if [[ -z "$VIZD_SEED_NODES" ]]; then 18 | for NODE in $SEED_NODES ; do 19 | ARGS+=" --p2p-seed-node=$NODE" 20 | done 21 | fi 22 | 23 | # if user did pass in desired seed nodes, use 24 | # the ones the user specified: 25 | if [[ ! -z "$VIZD_SEED_NODES" ]]; then 26 | for NODE in $VIZD_SEED_NODES ; do 27 | ARGS+=" --p2p-seed-node=$NODE" 28 | done 29 | fi 30 | 31 | if [[ ! -z "$VIZD_WITNESS_NAME" ]]; then 32 | ARGS+=" --witness=\"$VIZD_WITNESS_NAME\"" 33 | fi 34 | 35 | if [[ ! -z "$VIZD_PRIVATE_KEY" ]]; then 36 | ARGS+=" --private-key=$VIZD_PRIVATE_KEY" 37 | fi 38 | 39 | # overwrite local config with image one 40 | cp /etc/vizd/config.ini $HOME/config.ini 41 | 42 | chown vizd:vizd $HOME/config.ini 43 | 44 | if [[ ! -d $HOME/blockchain ]]; then 45 | if [[ -e /var/cache/vizd/blocks.tbz2 ]]; then 46 | # init with blockchain cached in image 47 | ARGS+=" --replay-blockchain" 48 | mkdir -p $HOME/blockchain/database 49 | cd $HOME/blockchain/database 50 | tar xvjpf /var/cache/vizd/blocks.tbz2 51 | chown -R vizd:vizd $HOME/blockchain 52 | fi 53 | fi 54 | 55 | # without --data-dir it uses cwd as datadir(!) 56 | # who knows what else it dumps into current dir 57 | cd $HOME 58 | 59 | # slow down restart loop if flapping 60 | sleep 1 61 | 62 | if [[ ! -z "$VIZD_RPC_ENDPOINT" ]]; then 63 | RPC_ENDPOINT=$VIZD_RPC_ENDPOINT 64 | else 65 | RPC_ENDPOINT="0.0.0.0:8090" 66 | fi 67 | 68 | if [[ ! -z "$VIZD_P2P_ENDPOINT" ]]; then 69 | P2P_ENDPOINT=$VIZD_P2P_ENDPOINT 70 | else 71 | P2P_ENDPOINT="0.0.0.0:2001" 72 | fi 73 | 74 | exec chpst -uvizd \ 75 | $VIZD \ 76 | --rpc-endpoint=${RPC_ENDPOINT} \ 77 | --p2p-endpoint=${P2P_ENDPOINT} \ 78 | --data-dir=$HOME \ 79 | $ARGS \ 80 | $VIZD_EXTRA_OPTS \ 81 | 2>&1 82 | -------------------------------------------------------------------------------- /thirdparty/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(appbase) 2 | add_subdirectory(fc) 3 | add_subdirectory(chainbase) --------------------------------------------------------------------------------