Repository: bitcoin/bitcoin
File: src/flatfile.h (C/C++)

Code before:
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2020 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_FLATFILE_H
#define BITCOIN_FLATFILE_H

#include <string>

#include <serialize.h>
#include <util/fs.h>

struct FlatFilePos
{
    int nFile{-1};
    unsigned int nPos{0};

    SERIALIZE_METHODS(FlatFilePos, obj) { READWRITE(VARINT_MODE(obj.nFile, VarIntMode::NONNEGATIVE_SIGNED), VARINT(obj.nPos)); }

    FlatFilePos() = default;

    FlatFilePos(int nFileIn, unsigned int nPosIn) :
        nFile(nFileIn),
        nPos(nPosIn)
    {}

    friend bool operator==(const FlatFilePos &a, const FlatFilePos &b) {
        return (a.nFile == b.nFile && a.nPos == b.nPos);
    }

    friend bool operator!=(const FlatFilePos &a, const FlatFilePos &b) {
        return !(a == b);
    }

    bool IsNull() const { return (nFile == -1); }

    std::string ToString() const;

Review comment (refactor):
In commit fa128d1488c08d9816f425c73d01db4c1597ee68:

Would the return type of `GetTotalSize` fit into the criteria for this refactor?

```diff
diff --git a/src/blockencodings.cpp b/src/blockencodings.cpp
index cf6da55aa9..9d50dfe949 100644
--- a/src/blockencodings.cpp
+++ b/src/blockencodings.cpp
@@ -195 +195 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<
-    unsigned int tx_missing_size = 0;
+    uint32_t tx_missing_size = 0;
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 80902b9e9c..cfb5f80f6a 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -2474 +2474 @@ void PeerManagerImpl::SendBlockTransactions(CNode& pfrom, Peer& peer, const CBlo
-    unsigned int tx_requested_size = 0;
+    uint32_t tx_requested_size = 0;
diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp
index e80ab60fcd..10c9361850 100644
--- a/src/primitives/transaction.cpp
+++ b/src/primitives/transaction.cpp
@@ -110 +110 @@ CAmount CTransaction::GetValueOut() const
-unsigned int CTransaction::GetTotalSize() const
+uint32_t CTransaction::GetTotalSize() const
```

Code after:
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2020 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_FLATFILE_H
#define BITCOIN_FLATFILE_H

#include <string>

#include <serialize.h>
#include <util/fs.h>

struct FlatFilePos
{
    int32_t nFile{-1};
    uint32_t nPos{0};

    SERIALIZE_METHODS(FlatFilePos, obj) { READWRITE(VARINT_MODE(obj.nFile, VarIntMode::NONNEGATIVE_SIGNED), VARINT(obj.nPos)); }

    FlatFilePos() = default;

    FlatFilePos(int32_t nFileIn, uint32_t nPosIn)
        : nFile{nFileIn},
          nPos{nPosIn}
    {}

    friend bool operator==(const FlatFilePos &a, const FlatFilePos &b) {
        return (a.nFile == b.nFile && a.nPos == b.nPos);
    }

    friend bool operator!=(const FlatFilePos &a, const FlatFilePos &b) {
        return !(a == b);
    }

    bool IsNull() const { return (nFile == -1); }

    std::string ToString() const;