#undeclared vector<Transaction> (Blockchain)

5 messages · Page 1 of 1 (latest)

graceful quarry
#

Hello, can you help me with this error:

/Users/oblivisheee/Documents/GitHub/Oblivion/src/Block.h:19:17: error: use of undeclared identifier 'Transaction'
    std::vector<Transaction> transactions;
                ^
/Users/oblivisheee/Documents/GitHub/Oblivion/src/Block.h:28:17: error: use of undeclared identifier 'Transaction'
    std::vector<Transaction> GetTransactions() const;
                ^
In file included from /Users/oblivisheee/Documents/GitHub/Oblivion/src/Block.cpp:6:
In file included from /Users/oblivisheee/Documents/GitHub/Oblivion/src/Transaction.h:8:
/Users/oblivisheee/Documents/GitHub/Oblivion/src/Blockchain.h:22:17: error: use of undeclared identifier 'Transaction'
    std::vector<Transaction> getAllTransactions() const;
                ^
3 errors generated.

Block.cpp

#include <string>
#include <vector>
#include <map>
#include <optional>
#include "crypto/SHA256.h"
#include "Transaction.h"

Block::Block(std::map<std::string, std::string> dataIn, std::string sPrevHashIn, std::string sExtraDataIn, std::string sMemoIn) {
    this->data = dataIn;
    this->sPrevHash = sPrevHashIn;
    this->sExtraData = sExtraDataIn;
    this->sMemo = sMemoIn;
    this->nNonce = 0;
    this->sHash = CalculateHash();
}


std::string Block::CalculateHash() const {
    std::string dataString;
    for (const auto& pair : this->data) {
        dataString += pair.first + pair.second;
    }
    return generateSHA256(dataString + sPrevHash + std::to_string(nNonce) + sExtraData + sMemo); // Added memo to hash calculation
}

std::string Block::GetHash() const {
    return this->sHash;
}

std::string Block::GetPrevHash() const {
    return this->sPrevHash;
}

std::string Block::GetExtraData() const {
    return this->sExtraData;
}

std::string Block::GetMemo() const {
    return this->sMemo;
}

std::vector<Transaction> Block::GetTransactions() const {
    return this->transactions;
}

Block.h

#ifndef BLOCK_H
#define BLOCK_H

#include <string>
#include <vector>
#include <map>
#include <optional>
#include "crypto/SHA256.h"
#include "Transaction.h"

class Block {
public:
    std::string sPrevHash;
    std::string sHash;
    int nNonce = -1;
    std::map<std::string, std::string> data;
    std::string sExtraData;
    std::string sMemo;
    std::vector<Transaction> transactions;

    Block(std::map<std::string, std::string> dataIn, std::string sPrevHashIn, std::string sExtraDataIn = "", std::string sMemoIn = "");

    std::string GetHash() const;
    std::string GetPrevHash() const;
    std::string GetExtraData() const;
    std::string GetMemo() const;
    std::string CalculateHash() const;
    std::vector<Transaction> GetTransactions() const;
};
#endif

I am developing blockchain. This variable have to save all transactions into block.
https://github.com/oblivisheee/Oblivion

GitHub

Blockchain. Contribute to oblivisheee/Oblivion development by creating an account on GitHub.

silk portalBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

graceful quarry
#

!solved

silk portalBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity

graceful quarry
#

!howto ask