Skip to content

Commit

Permalink
Fix arguments in transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
MizukiSonoko committed Sep 27, 2016
1 parent d8c9f06 commit 893897c
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 30 deletions.
3 changes: 2 additions & 1 deletion core/model/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
add_subdirectory(instance)
add_subdirectory(instance)
add_subdirectory(transactions)
9 changes: 6 additions & 3 deletions core/model/transactions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
set(CMAKE_BUILD_TYPE Debug)

SET(CMAKE_CXX_FLAGS_RELEASE "-Wall -O3 -std=c++14")
SET(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wextra -O0 -std=c++14")
# This is infra knowledge
SET(MESSAGE_PACK_PATH ${PROJECT_SOURCE_DIR}/core/vendor/msgpack-c)
include_directories(${MESSAGE_PACK_PATH}/include)

SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/domain/transactions)
ADD_LIBRARY(transfer_transaction STATIC
transfer_transaction.cpp
)
10 changes: 5 additions & 5 deletions core/model/transactions/abstract_transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class AbstractTransaction {
AbstractTransaction(const AbstractTransaction&) = default; // support copying
AbstractTransaction& operator = (const AbstractTransaction&) = default;

virtual std::string getHash() = 0;
virtual std::string getRawData() = 0;
virtual std::string getAsText() = 0;
virtual unsigned long long getTimestamp() = 0;
virtual TransactionType getType() = 0;
virtual std::string getHash() const = 0;
virtual std::string getRawData() const = 0;
virtual std::string getAsText() const = 0;
virtual unsigned long long getTimestamp() const = 0;
virtual TransactionType getType() const = 0;
};
} // namespace abstract_transaction

Expand Down
26 changes: 11 additions & 15 deletions core/model/transactions/transfer_transaction.cpp
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
#include "transfer_transaction.hpp"
#include "abstract_transfer_transaction.hpp"
#include <string>

namespace transfer_transaction {
class TransferTransaction : public AbstractTransaction {
std::string hash;
AbstractTransaction::TransactionType type;
namespace transaction {

std::string getHash() {
std::string TransferTransaction::getHash() {
return hash;
}

std::string getRawData() {
std::string TransferTransaction::getRawData() {
//TODO
}
std::string getAsText() {

std::string TransferTransaction::getAsText() {
//TODO
}
unsigned long long getTimestamp() {

unsigned long long TransferTransaction::getTimestamp() {
return timestamp;
}
TransactionType getType() {

abstract_transaction::TransactionType TransferTransaction::getType() {
return type;
}
};

}; // namespace transfer_transaction

}; // namespace transaction
36 changes: 30 additions & 6 deletions core/model/transactions/transfer_transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,40 @@
#include "abstract_transaction.hpp"
#include <msgpack.hpp>

namespace transfer_transaction {
AbstractTransaction::TransactionType type;
unsigned char* senderPublicKey;
unsigned char* receiverPublicKey;
namespace transaction {

class TransferTransaction : public abstract_transaction::AbstractTransaction {
std::string prevTxHash;
std::string hash;
abstract_transaction::TransactionType type;
std::string senderPublicKey;
std::string receiverPublicKey;
std::string domain;
std::string asset;
long long makotos; // TODO: JS NUMBER range from -9007199254740992 to +9007199254740992 対応
short int precision;
unsigned long long timestamp;

MSGPACK_DEFINE(
prevTxHash,
hash,
senderPublicKey,
receiverPublicKey,
domain,
asset,
makotos,
precision,
signature,
timestamp
);

std::string getHash();
std::string getRawData();
std::string getAsText();
unsigned long long getTimestamp();
abstract_transaction::TransactionType getType();
};

MSGPACK_DEFINE(prevTxHash, hash, type, senderPublicKey, receiverPublicKey, domain, asset, makotos, precision, signature, timestamp);
}; // namespace transfer_transaction
}; // namespace transaction

#endif // CORE_DOMAIN_TRANSACTIONS_TRANSFERTRANSACTION_HPP_

0 comments on commit 893897c

Please sign in to comment.