diff --git a/platonlib/include/platon/txencode.hpp b/platonlib/include/platon/txencode.hpp index d3aa40e..fc9b0da 100644 --- a/platonlib/include/platon/txencode.hpp +++ b/platonlib/include/platon/txencode.hpp @@ -6,11 +6,12 @@ #include #include "RLP.h" +#include /** * @brief Transaction coding operation * */ -namespace platon { +namespace platon{ /** * @brief Specified type encoding @@ -18,7 +19,7 @@ namespace platon { * @param stream RLP stream * @param d int8_t type */ - inline void txEncode(RLPStream &stream, int8_t d){ + inline void txEncodeValue(RLPStream &stream, int8_t d){ d = boost::endian::endian_reverse(d); bytesConstRef ref((byte*)&d, sizeof(d)); @@ -31,7 +32,7 @@ namespace platon { * @param stream RLP stream * @param d uint16_t type */ - inline void txEncode(RLPStream &stream, uint16_t d){ + inline void txEncodeValue(RLPStream &stream, uint16_t d){ d = boost::endian::endian_reverse(d); bytesConstRef ref((byte*)&d, sizeof(d)); @@ -44,7 +45,7 @@ namespace platon { * @param stream RLP stream * @param d int16_t type */ - inline void txEncode(RLPStream &stream, int16_t d){ + inline void txEncodeValue(RLPStream &stream, int16_t d){ d = boost::endian::endian_reverse(d); bytesConstRef ref((byte*)&d, sizeof(d)); @@ -57,7 +58,7 @@ namespace platon { * @param stream RLP stream * @param d uint32_t type */ - inline void txEncode(RLPStream &stream, uint32_t d){ + inline void txEncodeValue(RLPStream &stream, uint32_t d){ d = boost::endian::endian_reverse(d); bytesConstRef ref((byte*)&d, sizeof(d)); @@ -70,27 +71,25 @@ namespace platon { * @param stream RLP stream * @param d int32_t type */ - inline void txEncode(RLPStream &stream, int32_t d){ + inline void txEncodeValue(RLPStream &stream, int32_t d){ d = boost::endian::endian_reverse(d); bytesConstRef ref((byte*)&d, sizeof(d)); stream.append(ref); } -#ifdef WASM_COMPILE /** * @brief Specified type encoding * * @param stream RLP stream * @param d int type */ - inline void txEncode(RLPStream &stream, int d){ + inline void txEncodeValue(RLPStream &stream, int d){ d = boost::endian::endian_reverse((int32_t)d); bytesConstRef ref((byte*)&d, sizeof(d)); stream.append(ref); } -#endif /** * @brief Specified type encoding @@ -98,7 +97,7 @@ namespace platon { * @param stream RLP stream * @param d uint64_t type */ - inline void txEncode(RLPStream &stream, uint64_t d){ + inline void txEncodeValue(RLPStream &stream, uint64_t d){ d = boost::endian::endian_reverse(d); bytesConstRef ref((byte*)&d, sizeof(d)); @@ -111,7 +110,7 @@ namespace platon { * @param stream RLP stream * @param d int64_t type */ - inline void txEncode(RLPStream &stream, int64_t d){ + inline void txEncodeValue(RLPStream &stream, int64_t d){ d = boost::endian::endian_reverse(d); bytesConstRef ref((byte*)&d, sizeof(d)); @@ -124,7 +123,7 @@ namespace platon { * @param stream RLP stream * @param d std::string type */ - inline void txEncode(RLPStream &stream, const std::string & d){ + inline void txEncodeValue(RLPStream &stream, const std::string d){ stream.append(d); } @@ -134,7 +133,7 @@ namespace platon { * @param stream RLP stream * @param d Char pointer type */ - inline void txEncode(RLPStream &stream, const char *d){ + inline void txEncodeValue(RLPStream &stream, const char *d){ stream.append(std::string(d)); } @@ -143,10 +142,13 @@ namespace platon { * * @param stream */ - inline void txEncode(RLPStream &stream){ + inline void txEncodeValue(RLPStream &stream){ } - + template + inline void txEncode(RLPStream &stream,T arg){ + txEncodeValue(stream,arg); + } /** * @brief Serialize to RLPStream @@ -159,7 +161,7 @@ namespace platon { */ template void txEncode(RLPStream &stream, Arg&& a, Args&&... args ) { - txEncode(stream, a); + txEncodeValue(stream, a); txEncode(stream, args...); } }