Skip to content

Commit

Permalink
EOSIO#2625 got blocks flowing
Browse files Browse the repository at this point in the history
  • Loading branch information
pmesnier authored and PaulCalabrese committed May 1, 2018
1 parent 2ec8535 commit 3956ff7
Show file tree
Hide file tree
Showing 10 changed files with 225 additions and 221 deletions.
2 changes: 1 addition & 1 deletion libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace eosio { namespace chain {
struct config {
struct runtime_limits {
fc::microseconds max_push_block_us = fc::microseconds(100000);
fc::microseconds max_push_transaction_us = fc::microseconds(1000'000);
fc::microseconds max_push_transaction_us = fc::microseconds(1000'000); //' for colorizer
fc::microseconds max_deferred_transactions_us = fc::microseconds(100000);
};

Expand Down
5 changes: 5 additions & 0 deletions libraries/chain/include/eosio/chain/transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,18 @@ namespace eosio { namespace chain {
bytes packed_context_free_data;
bytes packed_trx;

time_point_sec expiration()const;
transaction_id_type id()const;
bytes get_raw_transaction()const;
vector<bytes> get_context_free_data()const;
transaction get_transaction()const;
signed_transaction get_signed_transaction()const;
void set_transaction(const transaction& t, compression_type _compression = none);
void set_transaction(const transaction& t, const vector<bytes>& cfd, compression_type _compression = none);

private:
mutable optional<transaction> unpacked_trx; // <-- intermediate buffer used to retrieve values
void local_unpack()const;
};


Expand Down
33 changes: 23 additions & 10 deletions libraries/chain/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,25 +273,38 @@ vector<bytes> packed_transaction::get_context_free_data()const
} FC_CAPTURE_AND_RETHROW((compression)(packed_context_free_data))
}

time_point_sec packed_transaction::expiration()const
{
local_unpack();
return unpacked_trx->expiration;
}

transaction_id_type packed_transaction::id()const
{
try {
return get_transaction().id();
} FC_CAPTURE_AND_RETHROW((compression)(packed_trx))
local_unpack();
return get_transaction().id();
}

transaction packed_transaction::get_transaction()const
void packed_transaction::local_unpack()const
{
try {
switch(compression) {
if (!unpacked_trx) {
try {
switch(compression) {
case none:
return unpack_transaction(packed_trx);
unpacked_trx = unpack_transaction(packed_trx);
case zlib:
return zlib_decompress_transaction(packed_trx);
unpacked_trx = zlib_decompress_transaction(packed_trx);
default:
FC_THROW("Unknown transaction compression algorithm");
}
} FC_CAPTURE_AND_RETHROW((compression)(packed_trx))
}
} FC_CAPTURE_AND_RETHROW((compression)(packed_trx))
}
}

transaction packed_transaction::get_transaction()const
{
local_unpack();
return transaction(*unpacked_trx);
}

signed_transaction packed_transaction::get_signed_transaction() const
Expand Down
13 changes: 12 additions & 1 deletion plugins/net_plugin/include/eosio/net_plugin/protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ namespace eosio {
static_assert(sizeof(std::chrono::system_clock::duration::rep) >= 8, "system_clock is expected to be at least 64 bits");
typedef std::chrono::system_clock::duration::rep tstamp;

struct chain_size_message {
uint32_t last_irreversible_block_num = 0;
block_id_type last_irreversible_block_id;
uint32_t head_num = 0;
block_id_type head_id;
};

struct handshake_message {
uint16_t network_version = 0; ///< incremental value above a computed base
chain_id_type chain_id; ///< used to identify chain
Expand All @@ -32,6 +39,7 @@ namespace eosio {
int16_t generation;
};


enum go_away_reason {
no_reason, ///< no reason to go away
self, ///< the connection is to itself
Expand Down Expand Up @@ -130,18 +138,21 @@ namespace eosio {
};

using net_message = static_variant<handshake_message,
chain_size_message,
go_away_message,
time_message,
notice_message,
request_message,
sync_request_message,
signed_block,
signed_transaction,
packed_transaction>;

} // namespace eosio

FC_REFLECT( eosio::select_ids<fc::sha256>, (mode)(pending)(ids) )
FC_REFLECT( eosio::chain_size_message,
(last_irreversible_block_num)(last_irreversible_block_id)
(head_num)(head_id))
FC_REFLECT( eosio::handshake_message,
(network_version)(chain_id)(node_id)(key)
(time)(token)(sig)(p2p_address)
Expand Down
Loading

0 comments on commit 3956ff7

Please sign in to comment.