Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.0 --> main] update datastream, bump version, and fix duplicate definition of capi_checksum256 #31

Merged
merged 7 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ project(cdt)
set(VERSION_MAJOR 3)
set(VERSION_MINOR 0)
set(VERSION_PATCH 0)
set(VERSION_SUFFIX rc2)
set(VERSION_SUFFIX rc3)

if (VERSION_SUFFIX)
set(VERSION_FULL "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_SUFFIX}")
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ CDT currently supports Linux x86_64 Debian packages. Visit the [release page](ht
The latest version of CDT is 3.0. Download the appropriate version of the Debian package and then install as follows:

```sh
wget https://github.com/AntelopeIO/cdt/releases/download/v3.0.0-rc2/cdt_3.0.0-rc2_amd64.deb
sudo apt install ./cdt_3.0.0-rc2_amd64.deb
wget https://github.com/AntelopeIO/cdt/releases/download/v3.0.0-rc3/cdt_3.0.0-rc3_amd64.deb
sudo apt install ./cdt_3.0.0-rc3_amd64.deb
```
### Debian package uninstall

Expand Down
4 changes: 2 additions & 2 deletions libraries/eosiolib/core/eosio/crypto_ext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace eosio {
namespace internal_use_do_not_use {
extern "C" {

struct __attribute__((aligned (16))) capi_checksum256 { uint8_t hash[32]; };
struct __attribute__((aligned (16))) capi_checksum256_ext { uint8_t hash[32]; };

__attribute__((eosio_wasm_import))
int32_t alt_bn128_add( const char* op1, uint32_t op1_len, const char* op2, uint32_t op2_len, char* result, uint32_t result_len);
Expand All @@ -40,7 +40,7 @@ namespace eosio {
}

static inline auto sha3_helper(const char* data, uint32_t length, bool keccak) {
internal_use_do_not_use::capi_checksum256 hash;
internal_use_do_not_use::capi_checksum256_ext hash;
internal_use_do_not_use::sha3( data, length, (char*)&hash, sizeof(hash), keccak);
eosio::checksum256 dg;
eosio::datastream<uint8_t*> ds = {&hash.hash[0], sizeof(hash)};
Expand Down
24 changes: 14 additions & 10 deletions libraries/eosiolib/core/eosio/datastream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,17 +699,18 @@ datastream<Stream>& operator >> ( datastream<Stream>& ds, T (&v)[N] ) {
}

/**
* Serialize a vector of char
* Serialize a vector of T, where T is a primitive data type
*
* @param ds - The stream to write
* @param v - The value to serialize
* @tparam Stream - Type of datastream buffer
* @return datastream<Stream>& - Reference to the datastream
*/
template<typename Stream>
datastream<Stream>& operator << ( datastream<Stream>& ds, const std::vector<char>& v ) {
template<typename Stream, typename T,
std::enable_if_t<_datastream_detail::is_primitive<T>()>* = nullptr>
datastream<Stream>& operator << ( datastream<Stream>& ds, const std::vector<T>& v ) {
ds << unsigned_int( v.size() );
ds.write( v.data(), v.size() );
ds.write( (const void*)v.data(), v.size()*sizeof(T) );
return ds;
}

Expand All @@ -722,7 +723,8 @@ datastream<Stream>& operator << ( datastream<Stream>& ds, const std::vector<char
* @tparam T - Type of the object contained in the vector
* @return datastream<Stream>& - Reference to the datastream
*/
template<typename Stream, typename T>
template<typename Stream, typename T,
std::enable_if_t<!_datastream_detail::is_primitive<T>()>* = nullptr>
datastream<Stream>& operator << ( datastream<Stream>& ds, const std::vector<T>& v ) {
ds << unsigned_int( v.size() );
for( const auto& i : v )
Expand All @@ -731,19 +733,20 @@ datastream<Stream>& operator << ( datastream<Stream>& ds, const std::vector<T>&
}

/**
* Deserialize a vector of char
* Deserialize a vector of T, where T is a primitive data type
*
* @param ds - The stream to read
* @param v - The destination for deserialized value
* @tparam Stream - Type of datastream buffer
* @return datastream<Stream>& - Reference to the datastream
*/
template<typename Stream>
datastream<Stream>& operator >> ( datastream<Stream>& ds, std::vector<char>& v ) {
template<typename Stream, typename T,
std::enable_if_t<_datastream_detail::is_primitive<T>()>* = nullptr>
datastream<Stream>& operator >> ( datastream<Stream>& ds, std::vector<T>& v ) {
unsigned_int s;
ds >> s;
v.resize( s.value );
ds.read( v.data(), v.size() );
ds.read( (char*)v.data(), v.size()*sizeof(T) );
return ds;
}

Expand All @@ -756,7 +759,8 @@ datastream<Stream>& operator >> ( datastream<Stream>& ds, std::vector<char>& v )
* @tparam T - Type of the object contained in the vector
* @return datastream<Stream>& - Reference to the datastream
*/
template<typename Stream, typename T>
template<typename Stream, typename T,
std::enable_if_t<!_datastream_detail::is_primitive<T>()>* = nullptr>
datastream<Stream>& operator >> ( datastream<Stream>& ds, std::vector<T>& v ) {
unsigned_int s;
ds >> s;
Expand Down