From a8ab5d20f121cb72b172e7c88c873da75cd345da Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Fri, 3 Apr 2020 04:20:55 -0500 Subject: [PATCH] moving onionrutils over to ujson --- src/onionrutils/blockmetadata/fromdata.py | 22 +++++++++++----------- src/onionrutils/validatemetadata.py | 17 +++++++++-------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/onionrutils/blockmetadata/fromdata.py b/src/onionrutils/blockmetadata/fromdata.py index a39f54c3..c437d6df 100644 --- a/src/onionrutils/blockmetadata/fromdata.py +++ b/src/onionrutils/blockmetadata/fromdata.py @@ -1,9 +1,11 @@ -''' - Onionr - Private P2P Communication +"""Onionr - Private P2P Communication. Return a useful tuple of (metadata (header), meta, and data) by accepting raw block data -''' -''' +""" +import ujson as json + +from onionrutils import bytesconverter +""" This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or @@ -16,17 +18,15 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . -''' +""" -import json -from onionrutils import bytesconverter def get_block_metadata_from_data(block_data): - ''' - accepts block contents as string, returns a tuple of - metadata, meta (meta being internal metadata, which will be + """ + accepts block contents as string, returns a tuple of + metadata, meta (meta being internal metadata, which will be returned as an encrypted base64 string if it is encrypted, dict if not). - ''' + """ meta = {} metadata = {} data = block_data diff --git a/src/onionrutils/validatemetadata.py b/src/onionrutils/validatemetadata.py index 9349ec9e..8cb7a1cf 100644 --- a/src/onionrutils/validatemetadata.py +++ b/src/onionrutils/validatemetadata.py @@ -1,8 +1,13 @@ -""" - Onionr - Private P2P Communication +"""Onionr - Private P2P Communication. - validate new block's metadata +validate new block's metadata """ +import ujson as json + +import logger, onionrexceptions +from etc import onionrvalues +from . import stringvalidators, epoch, bytesconverter +import config, filepaths, onionrcrypto """ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,11 +22,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . """ -import json -import logger, onionrexceptions -from etc import onionrvalues -from . import stringvalidators, epoch, bytesconverter -import config, filepaths, onionrcrypto + def validate_metadata(metadata, block_data) -> bool: """Validate metadata meets onionr spec (does not validate proof value computation), take in either dictionary or json string"""