Skip to content

Commit

Permalink
Corrections in MR: #3081 (develop -> master)
Browse files Browse the repository at this point in the history
Signed-off-by: Grzegorz Bazior <bazior@agh.edu.pl>
Signed-off-by: Grzegorz Bazior <g.bazior@yodiss.pl>
  • Loading branch information
Grzegorz Bazior authored and appetrosyan committed Apr 14, 2023
1 parent 63f8688 commit fef6a34
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 71 deletions.
5 changes: 1 addition & 4 deletions iroha-lib/grpc_client/GrpcClient.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef GRPC_CLIENT_HPP
#define GRPC_CLIENT_HPP
#pragma once

#include <endpoint.grpc.pb.h>
#include <grpc++/grpc++.h>
Expand All @@ -26,5 +25,3 @@ class GrpcClient {
};

}

#endif
2 changes: 0 additions & 2 deletions iroha-lib/model/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ add_library(iroha_lib_model
generators/QueryGenerator.cpp
utils/Utils.h
utils/Utils.cpp
LibsAndClassDeclarations.h
ClassDeclarations.h
)

target_link_libraries(iroha_lib_model
Expand Down
5 changes: 0 additions & 5 deletions iroha-lib/model/ClassDeclarations.h

This file was deleted.

4 changes: 0 additions & 4 deletions iroha-lib/model/LibsAndClassDeclarations.h

This file was deleted.

37 changes: 23 additions & 14 deletions iroha-lib/model/Query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,43 @@ Query& Query::getAccountDetail(const std::string& account_id)
return *this;
}

Query& Query::getAccountTransactions(const std::string& account_id)
Query& Query::getAccountTransactions(const std::string& account_id,
const std::optional<std::string*>& first_tx_hash,
const std::optional<google::protobuf::Timestamp*>& first_tx_time,
const std::optional<google::protobuf::Timestamp*>& last_tx_time,
const std::optional<uint64_t> first_tx_height,
const std::optional<uint64_t> last_tx_height)
{
protobuf_query_ = *query_generator_.generateGetAccountTransactions(
account_id,
counter_,
created_time_,
{},
{},
{},
{},
{});
first_tx_hash,
first_tx_time,
last_tx_time,
first_tx_height,
last_tx_height);
return *this;
}

Query& Query::getAccountAssetTransactions(
const std::string& account_id,
const std::string& asset_id)
Query& Query::getAccountAssetTransactions(const std::string& account_id,
const std::string& asset_id,
const std::optional<std::string*>& first_tx_hash,
const std::optional<google::protobuf::Timestamp*>& first_tx_time,
const std::optional<google::protobuf::Timestamp*>& last_tx_time,
const std::optional<uint64_t> first_tx_height,
const std::optional<uint64_t> last_tx_height)
{
protobuf_query_ = *query_generator_.generateGetAccountAssetTransactions(
account_id,
counter_,
created_time_,
asset_id,
{},
{},
{},
{},
{});
first_tx_hash,
first_tx_time,
last_tx_time,
first_tx_height,
last_tx_height);
return *this;
}

Expand Down
31 changes: 19 additions & 12 deletions iroha-lib/model/Query.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#include "LibsAndClassDeclarations.h"

#include "crypto/keypair.hpp"
#include "queries.pb.h"
#include "generators/QueryGenerator.hpp"
Expand All @@ -10,14 +8,6 @@
namespace iroha_lib {

class Query {

private:
uint64_t counter_;
uint64_t created_time_;
iroha::protocol::Query protobuf_query_;
iroha::keypair_t keypair_;
QueryGenerator query_generator_;

public:
Query(const iroha::keypair_t& keypair,
uint64_t counter = 1u,
Expand All @@ -26,10 +16,20 @@ class Query {
Query& getAccount(const std::string& account_id);
Query& getAccountAssets(const std::string& account_id);
Query& getAccountDetail(const std::string& account_id);
Query& getAccountTransactions(const std::string& account_id);
Query& getAccountTransactions(const std::string& account_id,
const std::optional<std::string*>& first_tx_hash={},
const std::optional<google::protobuf::Timestamp*>& first_tx_time={},
const std::optional<google::protobuf::Timestamp*>& last_tx_time={},
const std::optional<uint64_t> first_tx_height={},
const std::optional<uint64_t> last_tx_height={});
Query& getAccountAssetTransactions(
const std::string& account_id,
const std::string& asset_id);
const std::string& asset_id,
const std::optional<std::string*>& first_tx_hash={},
const std::optional<google::protobuf::Timestamp*>& first_tx_time={},
const std::optional<google::protobuf::Timestamp*>& last_tx_time={},
const std::optional<uint64_t> first_tx_height={},
const std::optional<uint64_t> last_tx_height={});
Query& getTransactions(
const std::string& account_id,
const std::vector<std::string>& tx_hashes);
Expand All @@ -43,6 +43,13 @@ class Query {
const std::string& role_id);

const iroha::protocol::Query signAndAddSignature();

private:
uint64_t counter_;
uint64_t created_time_;
iroha::protocol::Query protobuf_query_;
iroha::keypair_t keypair_;
QueryGenerator query_generator_;
};

} // namespace iroha_lib
2 changes: 0 additions & 2 deletions iroha-lib/model/Tx.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef TX_HPP
#define TX_HPP

#include "LibsAndClassDeclarations.h"

#include "transaction.pb.h"
#include <boost/bimap.hpp>
#include "crypto/keypair.hpp"
Expand Down
2 changes: 0 additions & 2 deletions iroha-lib/model/TxBatch.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef TX_BATCH_HPP
#define TX_BATCH_HPP

#include "LibsAndClassDeclarations.h"

#include "transaction.pb.h"
#include <endpoint.pb.h>

Expand Down
40 changes: 18 additions & 22 deletions iroha-lib/model/generators/QueryGenerator.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef QUERY_GENERATOR_HPP
#define QUERY_GENERATOR_HPP
#pragma once

#include "queries.pb.h"
#include <optional>
Expand All @@ -10,13 +9,6 @@ namespace iroha_lib {
using namespace iroha::protocol;

class QueryGenerator {

private:
std::shared_ptr<iroha::protocol::Query> generateQuery(
const std::string& account_id,
uint64_t counter,
const uint64_t created_time);

public:
std::shared_ptr<iroha::protocol::Query> generateGetAccount(
const std::string& account_id,
Expand All @@ -34,21 +26,21 @@ class QueryGenerator {
const std::string& account_id,
uint64_t counter,
const uint64_t created_time,
const std::optional<std::string*>& first_tx_hash,
const std::optional<google::protobuf::Timestamp*>& first_tx_time,
const std::optional<google::protobuf::Timestamp*>& last_tx_time,
const std::optional<uint64_t> first_tx_height,
const std::optional<uint64_t> last_tx_height);
const std::optional<std::string*>& first_tx_hash={},
const std::optional<google::protobuf::Timestamp*>& first_tx_time={},
const std::optional<google::protobuf::Timestamp*>& last_tx_time={},
const std::optional<uint64_t> first_tx_height={},
const std::optional<uint64_t> last_tx_height={});
std::shared_ptr<iroha::protocol::Query> generateGetAccountAssetTransactions(
const std::string& account_id,
uint64_t counter,
const uint64_t created_time,
const std::string& assetId,
const std::optional<std::string*>& first_tx_hash,
const std::optional<google::protobuf::Timestamp*>& first_tx_time,
const std::optional<google::protobuf::Timestamp*>& last_tx_time,
const std::optional<uint64_t> first_tx_height,
const std::optional<uint64_t> last_tx_height);
const std::optional<std::string*>& first_tx_hash={},
const std::optional<google::protobuf::Timestamp*>& first_tx_time={},
const std::optional<google::protobuf::Timestamp*>& last_tx_time={},
const std::optional<uint64_t> first_tx_height={},
const std::optional<uint64_t> last_tx_height={});
std::shared_ptr<iroha::protocol::Query> generateGetTransactions(
const std::string& account_id,
uint64_t counter,
Expand All @@ -72,8 +64,12 @@ class QueryGenerator {
uint64_t counter,
const uint64_t created_time,
const std::string& role_id);
};

}
private:
std::shared_ptr<iroha::protocol::Query> generateQuery(
const std::string& account_id,
uint64_t counter,
const uint64_t created_time);
};

#endif
} // namespace iroha_lib
8 changes: 4 additions & 4 deletions shared_model/validators/validators_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ namespace shared_model {
const bool txs_duplicates_allowed;

/**
* Parameter specifying transaction how many hours in the past
* since current peer time transaction's `created_time` can be setted.
* The default value is FieldValidator::kDefaultMaxDelay hours.
* The value should be the same in a whole iroha network.
* A parameter, which specifies how many hours before the current peer's
* `created_time` can the transaction be set.
* Default is `FieldValidator::KDefaultMaxDelay` (hours).
* The value must be synchronised across all peers.
*/
std::optional<uint32_t> max_past_created_hours;
};
Expand Down

0 comments on commit fef6a34

Please sign in to comment.