Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Steem 0.16.0 #639

Merged
merged 226 commits into from
Nov 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
226 commits
Select commit Hold shift + click to select a range
2f4102c
Audit and changes of password reset #240
Sep 15, 2016
6b593c2
some work toward fixed sized memory and memory mapped files
revflash Sep 15, 2016
a0e6456
Updating fc dependency
revflash Sep 15, 2016
a35b044
Converted Account Names from std::string to fc::fixed_string
revflash Sep 16, 2016
999d054
implement shared_authority
revflash Sep 16, 2016
c59aaa9
update tags plugin to use fixed width tags and limit to 3 per post
revflash Sep 16, 2016
341ceaa
adding missing test file
revflash Sep 19, 2016
698bdf3
Merge branch 'develop' into shared-db
Sep 19, 2016
0debab3
Fix tests
Sep 19, 2016
1843f5b
Fix gcc compile
theoreticalbts Sep 19, 2016
a34ad57
Fix uninitialized variable in version parsing #393
theoreticalbts Sep 19, 2016
c28cfcf
Added some documentation about testing with docker
sneak Sep 20, 2016
2d6d68c
Fixed segv bug in sign state
Sep 20, 2016
c7a87d7
Update follow plugin to use account_id_type internally.
Sep 20, 2016
5e9d1a2
bump fc
Sep 20, 2016
02e71fc
Clean up authority checking
Sep 20, 2016
c9c0911
Serialize ops in account history objects #446
theoreticalbts Sep 20, 2016
30c7a74
Fix the build.
theoreticalbts Sep 20, 2016
9114830
Check for non-existing account in get_compromised_accounts() instead …
theoreticalbts Sep 19, 2016
5a3cc31
Rename full_operation_object -> applied_operation, fix check_reflect.…
theoreticalbts Sep 21, 2016
33721bb
Merge pull request #442 from steemit/441-hf9-noexcept
Sep 21, 2016
9d2a6d5
Merge pull request #447 from steemit/446-history-serialize-ops
Sep 21, 2016
ac54779
Finish removing std::stringstream from raw_block_api.cpp #452
theoreticalbts Sep 21, 2016
ffa9a77
Misc cleanup
Sep 21, 2016
23524b4
Merge pull request #453 from steemit/452-cleanup-rawblock-stringstream
Sep 21, 2016
f5ba99c
backing up progress on db2
revflash Sep 21, 2016
986f63f
Merge branch 'shared-db' of github.com:steemit/steem into shared-db
revflash Sep 21, 2016
1932dfb
Update follow plugin and api to return reblog time.
Sep 22, 2016
31d063c
Move evaluator_registry into evaluator_registry.hpp #454
theoreticalbts Sep 19, 2016
3c26fb8
Rename evaluators #454
theoreticalbts Sep 21, 2016
9a18ae5
Rename evaluator -> evaluator_impl by manual editing #454
theoreticalbts Sep 21, 2016
417f546
Rename evaluator_base -> evaluator #454
theoreticalbts Sep 21, 2016
bbabb09
Merge pull request #455 from steemit/454-refactor-evaluator
Sep 22, 2016
3e0a991
finish removing compile errors from db2
revflash Sep 22, 2016
a92bd1f
Create JSON object schema from FC reflection #264
theoreticalbts Sep 23, 2016
5f74e7a
authority.hpp: Don't reflect typename for classification enum #264
theoreticalbts Sep 23, 2016
ca44aec
types.hpp: Reflect typenames for some additional types #264
theoreticalbts Sep 23, 2016
30c810c
types.hpp: Reflect all object_id_types #264
theoreticalbts Sep 23, 2016
af1c4dc
steem_operations.hpp: Add pow2_work type #264
theoreticalbts Sep 23, 2016
b0a695e
authority.hpp: Name account_authority_map, key_authority_map #264
theoreticalbts Sep 23, 2016
42af184
Bump fc
theoreticalbts Sep 23, 2016
97749ad
Kill console spam
theoreticalbts Sep 23, 2016
02f2442
Fix tests #264
Sep 23, 2016
638af34
fix build errors, implement tests
revflash Sep 23, 2016
db782c9
Don't use field names space_id, type_id as it confuses check_reflect.py
theoreticalbts Sep 26, 2016
7bb2e7b
Merge remote-tracking branch 'origin/shared-db' into 264-schema
theoreticalbts Sep 26, 2016
f7a73ca
Merge pull request #460 from steemit/264-schema
Sep 26, 2016
e1c7be2
Refactor to create steemit protocol library #458
Sep 23, 2016
9608a54
Clean up exceptions
Sep 26, 2016
ebeaf52
Add extra condition to allow merkle to pass in shared db #463
Sep 27, 2016
1429a38
Requested changes for #461
Sep 27, 2016
86bacf0
Merge pull request #461 from steemit/458-protocol-lib
theoreticalbts Sep 27, 2016
c98495c
Prototype of chain2 api
revflash Sep 27, 2016
3d28d5a
Merge branch 'shared-db' into 240-lostpassword #240
Sep 27, 2016
b6409cf
progress testing db2 with chain2
revflash Sep 27, 2016
8268d58
Adding missing files
revflash Sep 27, 2016
3a7e280
adding support for serailizing oid types in db2
revflash Sep 28, 2016
c6a12dc
update chain2 with more tests
revflash Sep 28, 2016
984be2d
progress...
Sep 28, 2016
edfd9ff
Merge commit 'c6a12dc8ff120016d851e1fe743c0a38f81cd813' into shared-db
Sep 28, 2016
fb34961
implement export and import for db
revflash Sep 28, 2016
953198d
Merge commit 'fb34961544c0a84ab81dc36d08c18c1221d95e68' into shared-db
Sep 28, 2016
6cf5cab
adding some basic checks to verify that the memory mapped file state …
revflash Sep 29, 2016
7524c1e
integrate fork database
revflash Sep 29, 2016
f1fb3d7
More progress...
Sep 29, 2016
29f3d44
various updates and reverting to c++11
revflash Sep 29, 2016
0e3d379
small changes to fix clang warnings
Oct 3, 2016
b53049c
Compilation now requires plugins
Oct 4, 2016
f465e39
tags plugin compiles
Oct 4, 2016
0aa9312
follow plugin and shared authority
Oct 5, 2016
3d07a8c
database api and more plugins compile
Oct 6, 2016
1987889
Need to fix linking
Oct 6, 2016
6b05b5b
steamd builds
Oct 6, 2016
38da595
progress...
Oct 6, 2016
11d9b6f
Merge commit '0e3d379033a2c57e72bff4dbad97f5ceaa442386' into 20160928…
Oct 6, 2016
ee40b98
reindexes but does not sync
Oct 7, 2016
4bb8af7
Progress on syncing
Oct 10, 2016
184c75c
Merge branch '465-auth-validate' into 20160928-chain-refactor
Oct 10, 2016
56f6a72
Merge branch '463-shared-db-sync' into 20160928-chain-refactor
Oct 11, 2016
f2f87ac
Steamed syncs. Segfailt when live
Oct 12, 2016
e76207a
Reindexes properly
Oct 13, 2016
e5e5d60
Fix gcc compile error
theoreticalbts Oct 13, 2016
d2fb345
Add doc comment to generic_index::emplace()
theoreticalbts Oct 13, 2016
ea14878
Add missing comments in generic_index::squash()
theoreticalbts Oct 13, 2016
78543ae
Add database_tests target and make it compile
theoreticalbts Oct 13, 2016
1bb2690
Implement unit test for next_id undo bug #504
theoreticalbts Oct 13, 2016
313ac8d
Fix next_id undo bug #504
theoreticalbts Oct 13, 2016
896e68f
Fixed a bug in the undo state. steamd appears to be working on the li…
Oct 13, 2016
1445027
Merge commit '313ac8d566af0ea33a574269fc0c5c292d253f5f' into 20160928…
Oct 13, 2016
0a81167
Refactor account auth into its own object
Oct 14, 2016
23ccd52
Clean up startup and shutdown logic
Oct 14, 2016
52ba857
generic_id specification
Oct 18, 2016
39cf5f7
Building up to unit tests
Oct 18, 2016
a97d9a1
Remove db directory
Oct 18, 2016
d3896bf
Fix a few more refactor bugs
Oct 18, 2016
e13e94f
Copy schema to separate library
theoreticalbts Oct 17, 2016
bf20d7e
Add get_schema() to indexes
theoreticalbts Oct 17, 2016
be40df2
Add generic object manipulation methods to indexes
theoreticalbts Oct 18, 2016
9a91e6e
Add generic object manipulation methods to database
theoreticalbts Oct 18, 2016
67ac4cd
Comment out binary methods until more fc::raw::pack() implementations…
theoreticalbts Oct 18, 2016
5aa2424
Various minor compilation fixes
theoreticalbts Oct 18, 2016
72eb101
Compilation and unit test progress
Oct 19, 2016
3357f5a
Most test updates and bug fixes
Oct 20, 2016
3b37135
Finish fixing unit tests
Oct 20, 2016
032a0bc
bump fc
Oct 20, 2016
235c560
Allow resizing of shared memory file in unit tests to support various…
Oct 20, 2016
2bbcaec
Fix reflection
Oct 21, 2016
2a8c82a
Update Dockerfile to do testing in release mode
Oct 21, 2016
103c915
check_reflect.py: *_object now needs FC_REFLECT, not FC_REFLECT_DERIVED
theoreticalbts Oct 21, 2016
b0ce4d3
Merge branch 'develop' into shared-db
Oct 21, 2016
3692042
Fix debug node plugin after merge
Oct 21, 2016
99a0914
Lookup accounts by keys
Oct 24, 2016
f20330e
Fix reindexing and work on plugin. Uniqueness constraints currently v…
Oct 25, 2016
2a3140c
Fix uniqueness problem #531
Oct 25, 2016
acfb2ec
Cleanup #531
Oct 25, 2016
af5daff
Adds HF9 auth changes to plugin and changes wallet to check the plugi…
Oct 25, 2016
ba0fb19
Update block_log to play correctly with standard library #532
theoreticalbts Oct 25, 2016
1ce7fb0
Account lookup by key works. #531
Oct 26, 2016
c32ba6a
add rapidjson dependency to docker file
Oct 26, 2016
e52c9a4
Merge commit '532-block-log' into shared-db #532
Oct 27, 2016
b8fc349
Update APIs for web
Oct 27, 2016
716352a
Remove rapid JSON dependency
Oct 27, 2016
d746ac2
Remove block log spam for chain tests
Oct 27, 2016
ce89ba5
Fix build
Oct 27, 2016
94efcb6
Fix block_log so that it properly appends to the block file.
Oct 28, 2016
5284404
Fix block log when files do not exist
Oct 28, 2016
09c0be2
Fix problems with clean startup #539
Nov 1, 2016
6091991
Handle signatures on truncated ops #541
Nov 1, 2016
36e5fdf
Shutdown during sync is not always clean, but preserves database #542
Nov 1, 2016
39325c2
Fix unit tests
Nov 1, 2016
5eed3a3
Fix signature verification for shared-db #541
Nov 2, 2016
1932f85
Add read-write locking to shared-db
Nov 2, 2016
ad5e112
Merge commit '3379b5be8fa1567ece35beab1c8af1761d5d4e00' into shared-db
Nov 2, 2016
ceb0398
debug node no longer uses variant objects.
Nov 3, 2016
b44b9b1
Progress on timing out read-write locks shared db
Nov 3, 2016
160bc44
Update to use chainbase
Nov 4, 2016
2e9712a
Remove db2
Nov 4, 2016
67a9265
Fix error in submodule
Nov 4, 2016
c1aa1aa
Merge pull request #472 from steemit/shared-db
Nov 4, 2016
6d3cf52
Tags plugin objects now properly match their corresponding comment ob…
Nov 4, 2016
bbad220
Partial Implementation of #551 - update inflation rates, vesting with…
bytemaster Nov 5, 2016
45874e3
Remove POW inclusion reward #551
bytemaster Nov 5, 2016
318a461
#551 pay miners and runner up witnesses 5x the top 19 per block produced
bytemaster Nov 5, 2016
5f4ef76
Add hardfork constants. Tests still need updating #551
Nov 7, 2016
f1fd567
Set cashout time when returning replies #546
Nov 7, 2016
b7328bb
Renames posts to comments in the extended account object #507
Nov 7, 2016
73a2b52
Merge pull request #550 from steemit/549-get-discussions-bug
Nov 7, 2016
215f37f
Merge pull request #555 from steemit/507-rename-state-posts-to-comments
Nov 7, 2016
45d4360
Merge pull request #556 from steemit/546-set-cashout-time
Nov 7, 2016
4a8a9bc
Fix top 19 calculation #551
Nov 7, 2016
1d8c61d
Improve parsing of --shared-file-size command #557
theoreticalbts Nov 7, 2016
f54a846
Refactor config constants and fix unit tests #551
Nov 8, 2016
3b8762f
Merge commit '4a8a9bc535ab7d610640b30f2cd366d14ec062f0' into 551-hard…
Nov 8, 2016
314d6cd
Improve some comments
Alex-GR Nov 9, 2016
fe61fb9
Merge pull request #564 from Alex-GR/Alex-GR-patch-1
Nov 9, 2016
ffd4af2
Update more error messages #564
Nov 9, 2016
0c99de6
Fix average witness reward #551
Nov 11, 2016
2fdf7c5
Merge pull request #559 from steemit/557-shared-size-parsing
Nov 11, 2016
1834806
Fix broken out-of-tree wallet build #570
theoreticalbts Nov 15, 2016
591caea
Update pow2 op to use equihash
Nov 16, 2016
7b199a9
Update witness to mine with equihash
Nov 16, 2016
147d50e
Update economic parameters #551
Nov 16, 2016
76e9164
Parameterize Witness Pay #551
Nov 17, 2016
87e40d0
Fix reindex #551
Nov 17, 2016
74d053a
Fix get_followers and get_following API calls in the follow plugin
Nov 17, 2016
c831bcf
Merge pull request #572 from steemit/570-build-wallet
Nov 17, 2016
8c3bfc7
Report trending tags #578
theoreticalbts Nov 17, 2016
3b5d915
follow api returns correct variable types #577
Nov 18, 2016
0b8c68f
Merge pull request #579 from steemit/578-trending-tags
Nov 18, 2016
47fef3f
Add support for multiple read process and a single write process on t…
Nov 11, 2016
9bbd1ba
Fix tests
Nov 11, 2016
9c0a710
Add a dummy revision check when opening database
Nov 14, 2016
b3430db
Merge pull request #567 from steemit/564-PR
Nov 18, 2016
1bde13b
Revert changes to follow objects which used object IDs as the interna…
Nov 18, 2016
be9f160
Update hf date and minor cleanup #551
Nov 18, 2016
af50afd
Merge branch 'develop' into 551-hardfork16
Nov 18, 2016
670691e
Merge pull request #577 from steemit/20161117-fix-get-followers
Nov 18, 2016
641cc5b
Merge pull request #585 from steemit/551-hardfork16
Nov 18, 2016
953449d
Merge commit ‘origin’ into 551-hardfork16
Nov 18, 2016
342dbd9
Allow network broadcast API to forward tx when running a read-only no…
Nov 22, 2016
1ac33f4
fixes for #36 #355 and #439
Nov 22, 2016
e8c1deb
Merge pull request #592 from steemit/36-callback-crash-fix
Nov 22, 2016
b134fd8
Implement --flush argument #596
theoreticalbts Nov 21, 2016
a0c70c5
Fix overflow multiplying constants #594
theoreticalbts Nov 22, 2016
81d1bd9
Refactor process_funds one-liner for readability, fix negative rate h…
theoreticalbts Nov 22, 2016
7a4e46d
‘steemd --version' displays version info and exits. ‘about’ in the c…
Nov 22, 2016
15ab11e
Refactor process_funds one-liner for readability #594
theoreticalbts Nov 22, 2016
f5de378
Merge pull request #598 from steemit/596-flush-blocks
Nov 22, 2016
b3f4ed5
Fix sad stability test
Nov 22, 2016
6db2808
Merge commit '15ab11e6c73d61903cf139225555aa5c0cf0fb33' into 594-fix-…
Nov 22, 2016
1834b54
Request changes and bump fc #591
Nov 22, 2016
78bc88c
Merge pull request #599 from steemit/594-fix-overflow
Nov 23, 2016
61167d2
Merge pull request #600 from steemit/591-steemd-version
bytemaster Nov 23, 2016
22cceee
Fix segfault in _next_flush_block implementation #596 #601
theoreticalbts Nov 22, 2016
f10d0bd
Allows accounts to cancel a power down when they control less than 10…
Nov 8, 2016
b7daf76
Cleanup steamed warnings #605
Nov 23, 2016
8e203b9
p2p and database have a co-dependency on shutdown. This breaks the co…
Nov 23, 2016
47e0b7d
Merge pull request #603 from steemit/601-fix-flush-block
Nov 23, 2016
1639130
Flush block log when appending #588 #589
theoreticalbts Nov 23, 2016
a8aa4fb
Merge pull request #604 from steemit/562-cancel-min-withdraw
Nov 23, 2016
c411557
More warning cleanup #605
theoreticalbts Nov 23, 2016
c2eb224
Merge pull request #608 from steemit/607-shutdown-segv
Nov 23, 2016
adcce72
Merge pull request #609 from steemit/605-clean-warnings
Nov 23, 2016
f8afa14
Fix follow api calls and add follow count #574
Nov 23, 2016
5b8f699
Merge pull request #610 from steemit/574-follow-count
Nov 23, 2016
d74a16b
More application shutdown stability #613
Nov 28, 2016
0c9da97
Fix return type of get_active_witnesses() #620
theoreticalbts Nov 28, 2016
5314900
Add chain_id reporting to network hello message #612
Nov 28, 2016
b8a0337
Merge pull request #623 from steemit/620-api-get-active-witnesses
Nov 28, 2016
417a8fa
Merge branch 'develop' into 587-read-node-forward #587
Nov 28, 2016
46405ee
Merge pull request #625 from steemit/612-network-crosstalk
Nov 28, 2016
cf858b8
Merge pull request #624 from steemit/613-app-segv
Nov 28, 2016
ee918b7
Can specify shared file location with —shared-file-dir option #626
Nov 28, 2016
766cd83
Merge pull request #628 from steemit/626-shared-dir
Nov 28, 2016
b308f82
Merge branch 'develop' into 587-read-node-forward
Nov 28, 2016
5dfb424
Merge pull request #629 from steemit/587-read-node-forward
Nov 28, 2016
bd36025
Soft fork to prevent tx spamming #523
Nov 29, 2016
e02330b
Fix type of proxied_vsf_votes #631
theoreticalbts Nov 29, 2016
432d583
Merge pull request #633 from steemit/631-fix-proxied-vsf-votes
Nov 29, 2016
88afb31
Merge pull request #632 from steemit/523-tx-bandwidth
Nov 29, 2016
fea6461
p2p-endpoint and rpc-endpoint will both resolve hostnames
Nov 29, 2016
e905fdd
The shared file directory is used when running in read only mode
Nov 29, 2016
52fc68d
Fix build #634
Nov 29, 2016
7e63a33
Merge pull request #637 from steemit/20161129-shared-file-dir
Nov 29, 2016
f2d02ee
Merge pull request #636 from steemit/634-local-hostname-endpoints
Nov 29, 2016
4c4638f
Merge branch 'develop' into 20161129-steem_v0_16_0
Nov 29, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "libraries/fc"]
path = libraries/fc
url = https://github.com/steemit/fc.git
[submodule "libraries/chainbase"]
path = libraries/chainbase
url = https://github.com/steemit/chainbase.git
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ else( WIN32 ) # Apple AND Linux
if( APPLE )
# Apple Specific Options Here
message( STATUS "Configuring Steem on OS X" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -stdlib=libc++ -Wall -Wno-conversion" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -stdlib=libc++ -Wall -Wno-conversion -Wno-deprecated-declarations" )
else( APPLE )
# Linux Specific Options Here
message( STATUS "Configuring Steem on Linux" )
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN \
mkdir build && \
cd build && \
cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_STEEM_TESTNET=ON \
-DLOW_MEMORY_NODE=OFF \
-DCLEAR_VOTES=ON \
Expand Down
4 changes: 3 additions & 1 deletion libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
add_subdirectory( fc )
add_subdirectory( db )
add_subdirectory( schema )
add_subdirectory( chainbase )
add_subdirectory( chain )
add_subdirectory( protocol )
add_subdirectory( net )
add_subdirectory( time )
add_subdirectory( utilities )
Expand Down
2 changes: 1 addition & 1 deletion libraries/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ add_library( steemit_app
${HEADERS}
)

target_link_libraries( steemit_app steemit_chain steemit_tags steemit_follow steemit_mf_plugins fc graphene_db graphene_net graphene_time graphene_utilities )
target_link_libraries( steemit_app steemit_chain steemit_protocol steemit_tags steemit_follow steemit_mf_plugins fc graphene_net graphene_time graphene_utilities )
target_include_directories( steemit_app
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )

Expand Down
165 changes: 109 additions & 56 deletions libraries/app/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
#include <steemit/app/api_access.hpp>
#include <steemit/app/application.hpp>
#include <steemit/app/impacted.hpp>

#include <steemit/protocol/get_config.hpp>

#include <steemit/chain/database.hpp>
#include <steemit/chain/get_config.hpp>
#include <steemit/chain/steem_objects.hpp>
#include <steemit/chain/transaction_object.hpp>

Expand All @@ -38,6 +40,9 @@
#include <fc/crypto/hex.hpp>
#include <fc/smart_ref_impl.hpp>

#include <graphene/utilities/git_revision.hpp>
#include <fc/git_revision.hpp>

namespace steemit { namespace app {

login_api::login_api(const api_context& ctx)
Expand Down Expand Up @@ -110,6 +115,14 @@ namespace steemit { namespace app {
return it->second;
}

steem_version_info login_api::get_version()
{
return steem_version_info(
fc::string( STEEMIT_BLOCKCHAIN_VERSION ),
fc::string( graphene::utilities::git_revision_sha ),
fc::string( fc::git_revision_sha ) );
}

network_broadcast_api::network_broadcast_api(const api_context& a):_app(a.app)
{
/// NOTE: cannot register callbacks in constructor because shared_from_this() is not valid.
Expand All @@ -125,14 +138,17 @@ namespace steemit { namespace app {

bool network_broadcast_api::check_max_block_age( int32_t max_block_age )
{
if( max_block_age < 0 )
return false;
return _app.chain_database()->with_read_lock( [&]()
{
if( max_block_age < 0 )
return false;

fc::time_point_sec now = graphene::time::now();
std::shared_ptr< database > db = _app.chain_database();
const dynamic_global_property_object& dgpo = db->get_dynamic_global_properties();
fc::time_point_sec now = graphene::time::now();
std::shared_ptr< database > db = _app.chain_database();
const dynamic_global_property_object& dgpo = db->get_dynamic_global_properties();

return ( dgpo.time < now - fc::seconds( max_block_age ) );
return ( dgpo.time < now - fc::seconds( max_block_age ) );
});
}

void network_broadcast_api::set_max_block_age( int32_t max_block_age )
Expand All @@ -142,80 +158,117 @@ namespace steemit { namespace app {

void network_broadcast_api::on_applied_block( const signed_block& b )
{
int32_t block_num = int32_t(b.block_num());
if( _callbacks.size() )
{
/// we need to ensure the database_api is not deleted for the life of the async operation
auto capture_this = shared_from_this();
for( int32_t trx_num = 0; trx_num < b.transactions.size(); ++trx_num )
/// we need to ensure the database_api is not deleted for the life of the async operation
auto capture_this = shared_from_this();

fc::async( [this,capture_this,b]() {
int32_t block_num = int32_t(b.block_num());
if( _callbacks.size() )
{
const auto& trx = b.transactions[trx_num];
auto id = trx.id();
auto itr = _callbacks.find(id);
if( itr != _callbacks.end() )
for( size_t trx_num = 0; trx_num < b.transactions.size(); ++trx_num )
{
const auto& trx = b.transactions[trx_num];
auto id = trx.id();
auto itr = _callbacks.find(id);
if( itr == _callbacks.end() ) continue;
confirmation_callback callback = itr->second;
fc::async( [capture_this,id,block_num,trx_num,callback](){ callback( fc::variant(transaction_confirmation( id, block_num, trx_num, false )) ); } );
_callbacks.erase( itr );
itr->second = [](variant){};
callback( fc::variant(transaction_confirmation( id, block_num, int32_t(trx_num), false )) );
}
}
}

/// clear all expirations
while( true )
{
auto exp_it = _callbacks_expirations.begin();
if( exp_it == _callbacks_expirations.end() )
break;
if( exp_it->first > b.timestamp )
break;
for( const transaction_id_type& txid : exp_it->second )
/// clear all expirations
while( true )
{
auto cb_it = _callbacks.find( txid );
// If it's empty, that means the transaction has been confirmed and has been deleted by the above check.
if( cb_it == _callbacks.end() )
continue;
std::shared_ptr< network_broadcast_api > capture_this = shared_from_this();
confirmation_callback callback = cb_it->second;
transaction_id_type txid_byval = txid; // can't pass in by reference as it's going to be deleted
fc::async( [capture_this,block_num,txid_byval,callback](){ callback( fc::variant(transaction_confirmation{ txid_byval, block_num, -1, true}) ); } );
_callbacks.erase( cb_it );
auto exp_it = _callbacks_expirations.begin();
if( exp_it == _callbacks_expirations.end() )
break;
if( exp_it->first >= b.timestamp )
break;
for( const transaction_id_type& txid : exp_it->second )
{
auto cb_it = _callbacks.find( txid );
// If it's empty, that means the transaction has been confirmed and has been deleted by the above check.
if( cb_it == _callbacks.end() )
continue;

confirmation_callback callback = cb_it->second;
transaction_id_type txid_byval = txid; // can't pass in by reference as it's going to be deleted
callback( fc::variant(transaction_confirmation{ txid_byval, block_num, -1, true}) );

_callbacks.erase( cb_it );
}
_callbacks_expirations.erase( exp_it );
}
_callbacks_expirations.erase( exp_it );
}
}); /// fc::async

}

void network_broadcast_api::broadcast_transaction(const signed_transaction& trx)
{
trx.validate();
FC_ASSERT( !check_max_block_age( _max_block_age ) );
_app.chain_database()->push_transaction(trx);
_app.p2p_node()->broadcast_transaction(trx);

if( _app._read_only )
{
FC_ASSERT( _app._remote_net_api, "Write node RPC not configured properly or non connected." );
(*_app._remote_net_api)->broadcast_transaction( trx );
}
else
{
FC_ASSERT( !check_max_block_age( _max_block_age ) );
_app.chain_database()->push_transaction(trx);
_app.p2p_node()->broadcast_transaction(trx);
}
}

fc::variant network_broadcast_api::broadcast_transaction_synchronous(const signed_transaction& trx)
{
promise<fc::variant>::ptr prom( new fc::promise<fc::variant>() );
broadcast_transaction_with_callback( [=]( const fc::variant& v ){
prom->set_value(v);
}, trx );
return future<fc::variant>(prom).wait();
if( _app._read_only )
{
FC_ASSERT( _app._remote_net_api, "Write node RPC not configured properly or non connected." );
return (*_app._remote_net_api)->broadcast_transaction_synchronous( trx );
}
else
{
promise<fc::variant>::ptr prom( new fc::promise<fc::variant>() );
broadcast_transaction_with_callback( [=]( const fc::variant& v ){
prom->set_value(v);
}, trx );
return future<fc::variant>(prom).wait();
}
}

void network_broadcast_api::broadcast_block( const signed_block& b )
{
_app.chain_database()->push_block(b);
_app.p2p_node()->broadcast( graphene::net::block_message( b ));
if( _app._read_only )
{
FC_ASSERT( _app._remote_net_api, "Write node RPC not configured properly or non connected." );
(*_app._remote_net_api)->broadcast_block( b );
}
else
{
_app.chain_database()->push_block(b);
_app.p2p_node()->broadcast( graphene::net::block_message( b ));
}
}

void network_broadcast_api::broadcast_transaction_with_callback(confirmation_callback cb, const signed_transaction& trx)
{
FC_ASSERT( !check_max_block_age( _max_block_age ) );
trx.validate();
_callbacks[trx.id()] = cb;
_callbacks_expirations[trx.expiration].push_back(trx.id());
if( _app._read_only )
{
FC_ASSERT( _app._remote_net_api, "Write node RPC not configured properly or non connected." );
(*_app._remote_net_api)->broadcast_transaction_with_callback( cb, trx );
}
else
{
FC_ASSERT( !check_max_block_age( _max_block_age ) );
trx.validate();
_callbacks[trx.id()] = cb;
_callbacks_expirations[trx.expiration].push_back(trx.id());

_app.chain_database()->push_transaction(trx);
_app.p2p_node()->broadcast_transaction(trx);
_app.chain_database()->push_transaction(trx);
_app.p2p_node()->broadcast_transaction(trx);
}
}

network_node_api::network_node_api( const api_context& a ) : _app( a.app )
Expand Down
Loading