-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored blockchain_message and blockchain_message_handler (#597)
* Refactored blockchain_message and blockchain_message_handler * Returning formatted message on ReceiveMessage * Fixed tests * Fixed test (2) * Update prediction_market_agent/db/models.py Co-authored-by: Peter Jung <[email protected]> * Implemented PR comments * Fixing tests * typo * Renamed test * Trying to fix test again * Tests now passing * Fixed additional tests --------- Co-authored-by: Peter Jung <[email protected]>
- Loading branch information
1 parent
7cdf762
commit 2ad0275
Showing
17 changed files
with
245 additions
and
186 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
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
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,20 @@ | ||
import zlib | ||
|
||
from prediction_market_agent_tooling.tools.hexbytes_custom import HexBytes | ||
|
||
|
||
def compress_message(message: str) -> bytes: | ||
"""Used to reduce size of the message before sending it to reduce gas costs.""" | ||
return zlib.compress(message.encode(), level=zlib.Z_BEST_COMPRESSION) | ||
|
||
|
||
def decompress_message(message: bytes) -> str: | ||
return zlib.decompress(message).decode() | ||
|
||
|
||
def unzip_message_else_do_nothing(data_field: str) -> str: | ||
"""We try decompressing the message, else we return the original data field.""" | ||
try: | ||
return decompress_message(HexBytes(data_field)) | ||
except Exception: | ||
return data_field |
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
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.