This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
51 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <eosio/state_history/compression.hpp> | ||
|
||
#include <boost/iostreams/device/back_inserter.hpp> | ||
#include <boost/iostreams/filter/zlib.hpp> | ||
#include <boost/iostreams/filtering_stream.hpp> | ||
|
||
namespace eosio { | ||
namespace state_history { | ||
|
||
namespace bio = boost::iostreams; | ||
bytes zlib_compress_bytes(const bytes& in) { | ||
bytes out; | ||
bio::filtering_ostream comp; | ||
comp.push(bio::zlib_compressor(bio::zlib::default_compression)); | ||
comp.push(bio::back_inserter(out)); | ||
bio::write(comp, in.data(), in.size()); | ||
bio::close(comp); | ||
return out; | ||
} | ||
|
||
bytes zlib_decompress(const bytes& in) { | ||
bytes out; | ||
bio::filtering_ostream decomp; | ||
decomp.push(bio::zlib_decompressor()); | ||
decomp.push(bio::back_inserter(out)); | ||
bio::write(decomp, in.data(), in.size()); | ||
bio::close(decomp); | ||
return out; | ||
} | ||
|
||
} // namespace state_history | ||
} // namespace eosio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
libraries/state_history/include/eosio/state_history/compression.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#include <eosio/chain/types.hpp> | ||
|
||
namespace eosio { | ||
namespace state_history { | ||
|
||
using chain::bytes; | ||
|
||
bytes zlib_compress_bytes(const bytes& in); | ||
bytes zlib_decompress(const bytes& in); | ||
|
||
} // namespace state_history | ||
} // namespace eosio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters