moving onionrutils over to ujson

master
Kevin Froman 2020-04-03 04:20:55 -05:00
parent 37913d544b
commit a8ab5d20f1
2 changed files with 20 additions and 19 deletions

View File

@ -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 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 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or 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 You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
''' """
import json
from onionrutils import bytesconverter
def get_block_metadata_from_data(block_data): def get_block_metadata_from_data(block_data):
''' """
accepts block contents as string, returns a tuple of accepts block contents as string, returns a tuple of
metadata, meta (meta being internal metadata, which will be metadata, meta (meta being internal metadata, which will be
returned as an encrypted base64 string if it is encrypted, dict if not). returned as an encrypted base64 string if it is encrypted, dict if not).
''' """
meta = {} meta = {}
metadata = {} metadata = {}
data = block_data data = block_data

View File

@ -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 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 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 You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
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: 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""" """Validate metadata meets onionr spec (does not validate proof value computation), take in either dictionary or json string"""