Skip to content

Commit

Permalink
style: Removed blank lines and added [[nodiscard]]
Browse files Browse the repository at this point in the history
  • Loading branch information
EduMenges committed May 7, 2024
1 parent f47d660 commit 2af9d1e
Show file tree
Hide file tree
Showing 49 changed files with 163 additions and 264 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Checks: >
-google-build-using-namespace,
-google-explicit-constructor,
-google-readability-namespace-comments,
-google-readability-todo,
hicpp-multiway-paths-covered,
Expand Down
3 changes: 1 addition & 2 deletions src/authorship/block_builder.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#ifndef SUPERGENIUS_SRC_AUTHORSHIP_BLOCK_BUILDER_HPP
#define SUPERGENIUS_SRC_AUTHORSHIP_BLOCK_BUILDER_HPP

Expand All @@ -25,7 +24,7 @@ namespace sgns::authorship {
/**
* Create a block from extrinsics and header
*/
virtual outcome::result<primitives::Block> bake() const = 0;
[[nodiscard]] virtual outcome::result<primitives::Block> bake() const = 0;
};

} // namespace sgns::authorship
Expand Down
11 changes: 2 additions & 9 deletions src/authorship/block_builder_factory.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@

#ifndef SUPERGENIUS_SRC_AUTHORSHIP_BLOCK_BUILDER_FACTORY_HPP
#define SUPERGENIUS_SRC_AUTHORSHIP_BLOCK_BUILDER_FACTORY_HPP

#include <vector>

#include "authorship/block_builder.hpp"
#include "primitives/block_id.hpp"
#include "runtime/block_builder.hpp"
#include "runtime/core.hpp"
#include "integration/IComponent.hpp"

namespace sgns::authorship {
Expand All @@ -24,10 +19,8 @@ namespace sgns::authorship {
* Prepares BlockBuilder for creating block on top of parent block and using
* provided digests. Also initialises the block created in BlockBuilder
*/
virtual outcome::result<std::unique_ptr<BlockBuilder>> create(
const primitives::BlockId &parent_id,
primitives::Digest inherent_digest) const = 0;

[[nodiscard]] virtual outcome::result<std::unique_ptr<BlockBuilder>> create(
const primitives::BlockId &parent_id, primitives::Digest inherent_digest ) const = 0;
};

} // namespace sgns::authorship
Expand Down
1 change: 0 additions & 1 deletion src/authorship/impl/block_builder_error.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include "authorship/impl/block_builder_error.hpp"

OUTCOME_CPP_DEFINE_CATEGORY_3(sgns::authorship, BlockBuilderError, e) {
Expand Down
1 change: 0 additions & 1 deletion src/authorship/impl/block_builder_factory_impl.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include "authorship/impl/block_builder_factory_impl.hpp"

#include "authorship/impl/block_builder_impl.hpp"
Expand Down
8 changes: 3 additions & 5 deletions src/authorship/impl/block_builder_factory_impl.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#ifndef SUPERGENIUS_SRC_AUTHORSHIP_IMPL_BLOCK_BUILDER_FACTORY_IMPL_HPP
#define SUPERGENIUS_SRC_AUTHORSHIP_IMPL_BLOCK_BUILDER_FACTORY_IMPL_HPP

Expand All @@ -18,10 +17,9 @@ namespace sgns::authorship {
//std::shared_ptr<runtime::BlockBuilder> r_block_builder,
std::shared_ptr<blockchain::BlockHeaderRepository> header_backend);

outcome::result<std::unique_ptr<BlockBuilder>> create(
const sgns::primitives::BlockId &parent_id,
primitives::Digest inherent_digest) const override;

[[nodiscard]] outcome::result<std::unique_ptr<BlockBuilder>> create(
const sgns::primitives::BlockId &parent_id, primitives::Digest inherent_digest ) const override;

std::string GetName() override
{
return "BlockBuilderFactoryImpl";
Expand Down
8 changes: 2 additions & 6 deletions src/authorship/impl/block_builder_impl.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@

#ifndef SUPERGENIUS_SRC_AUTHORSHIP_IMPL_BLOCK_BUILDER_IMPL_HPP
#define SUPERGENIUS_SRC_AUTHORSHIP_IMPL_BLOCK_BUILDER_IMPL_HPP

#include "authorship/block_builder.hpp"

#include "base/logger.hpp"
#include "primitives/block_id.hpp"
#include "runtime/block_builder.hpp"
#include "runtime/core.hpp"

namespace sgns::authorship {

Expand All @@ -21,9 +17,9 @@ namespace sgns::authorship {
outcome::result<void> pushExtrinsic(
const primitives::Extrinsic &extrinsic) override;

outcome::result<primitives::Block> bake() const override;
[[nodiscard]] outcome::result<primitives::Block> bake() const override;

private:
private:
primitives::BlockHeader block_header_;
//std::shared_ptr<runtime::BlockBuilder> r_block_builder_;
base::Logger logger_;
Expand Down
1 change: 0 additions & 1 deletion src/authorship/impl/proposer_impl.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include "authorship/impl/proposer_impl.hpp"

namespace sgns::authorship {
Expand Down
2 changes: 0 additions & 2 deletions src/authorship/impl/proposer_impl.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@

#ifndef SUPERGENIUS_SRC_AUTHORSHIP_IMPL_AITHORING_IMPL_HPP
#define SUPERGENIUS_SRC_AUTHORSHIP_IMPL_AITHORING_IMPL_HPP

#include "authorship/proposer.hpp"

#include "authorship/block_builder_factory.hpp"
#include "base/logger.hpp"
#include "runtime/block_builder.hpp"
#include "transaction_pool/transaction_pool.hpp"

namespace sgns::authorship {
Expand Down
14 changes: 5 additions & 9 deletions src/authorship/proposer.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@


#ifndef SUPERGENIUS_SRC_AUTHORSHIP_PROPOSER_TEST_HPP
#define SUPERGENIUS_SRC_AUTHORSHIP_PROPOSER_TEST_HPP

#include "clock/clock.hpp"
#include "primitives/block.hpp"
#include "primitives/block_id.hpp"
#include "primitives/digest.hpp"
Expand All @@ -17,19 +14,18 @@ namespace sgns::authorship {
*/
class Proposer : public IComponent {
public:
virtual ~Proposer() = default;
~Proposer() override = default;

/**
/**
* Creates block from provided parameters
* @param parent_block_id hash or number of parent
* @param inherent_data additional data on block from unsigned extrinsics
* @param inherent_digests - chain-specific block auxilary data
* @return proposed block or error
*/
virtual outcome::result<primitives::Block> propose(
const primitives::BlockId &parent_block_id,
const primitives::InherentData &inherent_data,
const primitives::Digest &inherent_digest) = 0;
virtual outcome::result<primitives::Block> propose( const primitives::BlockId &parent_block_id,
const primitives::InherentData &inherent_data,
const primitives::Digest &inherent_digest ) = 0;
};

} // namespace sgns::authorship
Expand Down
2 changes: 0 additions & 2 deletions src/base/blob.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#include "base/blob.hpp"

OUTCOME_CPP_DEFINE_CATEGORY_3(sgns::base, BlobError, e) {
Expand Down
33 changes: 17 additions & 16 deletions src/base/blob.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#ifndef SUPERGENIUS_BLOB_HPP
#define SUPERGENIUS_BLOB_HPP

Expand Down Expand Up @@ -55,30 +53,33 @@ namespace sgns::base {
/**
* Converts current blob to std::string
*/
std::string toString() const noexcept {
return std::string{this->begin(), this->end()};
[[nodiscard]] std::string toString() const noexcept
{
return std::string{ this->begin(), this->end() };
}

/**
* Converts current blob to a readable std::string
*/
std::string toReadableString() const noexcept {
std::string out_str;
char temp_buf[3];
for ( auto it = this->begin(); it != this->end(); ++it )
{
snprintf( temp_buf, sizeof( temp_buf ), "%02x", *it );
out_str.append( temp_buf, sizeof( temp_buf ) - 1 );
}
return out_str;
[[nodiscard]] std::string toReadableString() const noexcept
{
std::string out_str;
char temp_buf[3];
for ( auto it = this->begin(); it != this->end(); ++it )
{
snprintf( temp_buf, sizeof( temp_buf ), "%02x", *it );
out_str.append( temp_buf, sizeof( temp_buf ) - 1 );
}
return out_str;
}

/**
* Converts current blob to hex string.
*/
std::string toHex() const noexcept {
// return hex_lower({this->begin(), this->end()});
return hex_lower(gsl::make_span(*this));
[[nodiscard]] std::string toHex() const noexcept
{
// return hex_lower({this->begin(), this->end()});
return hex_lower( gsl::make_span( *this ) );
}

/**
Expand Down
7 changes: 3 additions & 4 deletions src/base/buffer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#include "base/buffer.hpp"
#include "base/hexutil.hpp"
#include <iostream>
Expand Down Expand Up @@ -36,8 +34,9 @@ namespace sgns::base {
return hex_lower(data_);
}

const std::string_view Buffer::toString() const {
return std::string_view(reinterpret_cast<const char*>(data_.data()), data_.size()); // NOLINT
std::string_view Buffer::toString() const
{
return { reinterpret_cast<const char *>( data_.data() ), data_.size() };
}

bool Buffer::empty() const {
Expand Down
16 changes: 7 additions & 9 deletions src/base/buffer.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#ifndef SUPERGENIUS_BUFFER_HPP
#define SUPERGENIUS_BUFFER_HPP

Expand Down Expand Up @@ -110,29 +108,29 @@ namespace sgns::base {
/**
* @brief Iterator, which points to last of this buffer.
*/
const_reverse_iterator rbegin() const;
[[nodiscard]] const_reverse_iterator rbegin() const;

/**
* @brief Iterator, which points to the element previous to first in this
* buffer.
*/
const_reverse_iterator rend() const;
[[nodiscard]] const_reverse_iterator rend() const;

/**
* @brief Iterator, which points to begin of this buffer.
*/
const_iterator begin() const;
[[nodiscard]] const_iterator begin() const;

/**
* @brief Iterator, which points to the element next to the last in this
* buffer.
*/
const_iterator end() const;
[[nodiscard]] const_iterator end() const;

/**
* @brief Getter for size of this buffer.
*/
size_t size() const;
[[nodiscard]] size_t size() const;

/**
* @brief Put a 8-bit {@param n} in this buffer.
Expand Down Expand Up @@ -239,9 +237,9 @@ namespace sgns::base {
* @note Does not ensure correct encoding
* @return string
*/
const std::string_view toString() const;
std::string_view toString() const;

private:
private:
std::vector<uint8_t> data_;

template <typename T>
Expand Down
1 change: 0 additions & 1 deletion src/base/buffer_back_insert_iterator.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include "base/buffer.hpp"

using sgns::base::Buffer;
Expand Down
2 changes: 0 additions & 2 deletions src/base/hexutil.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#include "base/hexutil.hpp"

#include <boost/algorithm/hex.hpp>
Expand Down
2 changes: 0 additions & 2 deletions src/base/logger.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#include "base/logger.hpp"

#include <spdlog/sinks/stdout_color_sinks.h>
Expand Down
2 changes: 0 additions & 2 deletions src/base/logger.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#ifndef SUPERGENIUS_LOGGER_HPP
#define SUPERGENIUS_LOGGER_HPP

Expand Down
2 changes: 0 additions & 2 deletions src/base/mp_utils.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#include "base/mp_utils.hpp"

#include <gsl/gsl_util>
Expand Down
2 changes: 0 additions & 2 deletions src/base/mp_utils.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#ifndef SUPERGENIUS_SRC_CRYPTO_MP_UTILS_HPP
#define SUPERGENIUS_SRC_CRYPTO_MP_UTILS_HPP

Expand Down
2 changes: 0 additions & 2 deletions src/base/outcome_throw.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#ifndef SUPERGENIUS_SRC_COMMON_OUTCOME_THROW_HPP
#define SUPERGENIUS_SRC_COMMON_OUTCOME_THROW_HPP

Expand Down
1 change: 0 additions & 1 deletion src/base/type_traits.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#ifndef SUPERGENIUS_TYPE_TRAITS
#define SUPERGENIUS_TYPE_TRAITS

Expand Down
1 change: 0 additions & 1 deletion src/base/unused.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#ifndef SUPERGENIUS_UNUSED
#define SUPERGENIUS_UNUSED

Expand Down
2 changes: 0 additions & 2 deletions src/base/visitor.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#ifndef SUPERGENIUS_VISITOR_HPP
#define SUPERGENIUS_VISITOR_HPP

Expand Down
3 changes: 0 additions & 3 deletions src/base/wrapper.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@


#ifndef SUPERGENIUS_SRC_COMMON_WRAPPER_HPP
#define SUPERGENIUS_SRC_COMMON_WRAPPER_HPP

#include <memory>
#include <type_traits>

#include <boost/operators.hpp>
Expand Down
Loading

0 comments on commit 2af9d1e

Please sign in to comment.