Skip to content
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
3 changes: 1 addition & 2 deletions src/aleph/chains/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
from aleph.network import check_message as check_message_fn
from aleph.permissions import check_sender_authorization
from aleph.storage import get_json, pin_hash, add_json, get_message_content
from aleph.types import UnknownHashError
from aleph.web import app
from aleph.exceptions import (
AlephStorageException,
InvalidContent,
ContentCurrentlyUnavailable,
ContentCurrentlyUnavailable, UnknownHashError,
)

LOGGER = logging.getLogger("chains.common")
Expand Down
12 changes: 12 additions & 0 deletions src/aleph/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from __future__ import annotations


class AlephException(Exception):
...

Expand Down Expand Up @@ -37,3 +40,12 @@ class ContentCurrentlyUnavailable(AlephStorageException):
synchronisation issue.
"""
...


class UnknownHashError(AlephException):
...


class InvalidMessageError(AlephException):
"""Error raised when an invalid message is processed"""
...
4 changes: 2 additions & 2 deletions src/aleph/handlers/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

from aleph.services.ipfs.common import get_ipfs_api
from aleph.storage import get_hash_content
from aleph.types import ItemType, UnknownHashError
from aleph.types import ItemType
from aleph.web import app
from aleph.exceptions import AlephStorageException
from aleph.exceptions import AlephStorageException, UnknownHashError

LOGGER = logging.getLogger("HANDLERS.STORAGE")

Expand Down
3 changes: 2 additions & 1 deletion src/aleph/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
from aleph.network import check_message
from aleph.services.ipfs.common import connect_ipfs_peer
from aleph.services.p2p import singleton
from aleph.types import ItemType, InvalidMessageError
from aleph.types import ItemType
from aleph.exceptions import InvalidMessageError
from aleph.logging import setup_logging

LOGGER = getLogger("JOBS")
Expand Down
3 changes: 2 additions & 1 deletion src/aleph/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

from aleph.register_chain import VERIFIER_REGISTER
from aleph.services.ipfs.pubsub import incoming_channel as incoming_ipfs_channel
from aleph.types import ItemType, InvalidMessageError
from aleph.types import ItemType
from aleph.exceptions import InvalidMessageError
from aleph.utils import get_sha256

LOGGER = logging.getLogger("NETWORK")
Expand Down
2 changes: 1 addition & 1 deletion src/aleph/services/ipfs/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import base58

from aleph.types import InvalidMessageError
from ...exceptions import InvalidMessageError
from .common import get_ipfs_api

LOGGER = logging.getLogger("IPFS.PUBSUB")
Expand Down
3 changes: 1 addition & 2 deletions src/aleph/services/p2p/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
from p2pclient.libp2p_stubs.peer.id import ID

from aleph import __version__
from aleph.exceptions import AlephStorageException
from aleph.exceptions import AlephStorageException, InvalidMessageError
from aleph.network import incoming_check
from aleph.services.utils import pubsub_msg_to_dict
from aleph.types import InvalidMessageError
from .pubsub import receive_pubsub_messages, subscribe

MAX_READ_LEN = 2 ** 32 - 1
Expand Down
9 changes: 1 addition & 8 deletions src/aleph/types.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from __future__ import annotations
from enum import Enum


class UnknownHashError(ValueError):
pass
from aleph.exceptions import UnknownHashError


class ItemType(str, Enum):
Expand All @@ -30,8 +28,3 @@ class Protocol(str, Enum):
"""P2P Protocol"""
IPFS = "ipfs"
P2P = "p2p"


class InvalidMessageError(Exception):
"""Error raised when an invalid message is processed"""
pass
4 changes: 2 additions & 2 deletions src/aleph/web/controllers/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from aiohttp import web
from aiohttp.http_exceptions import HttpBadRequest

from aleph.exceptions import AlephStorageException
from aleph.exceptions import AlephStorageException, UnknownHashError
from aleph.handlers.forget import count_file_references
from aleph.storage import add_json, get_hash_content, add_file
from aleph.types import ItemType, UnknownHashError
from aleph.types import ItemType
from aleph.utils import run_in_executor
from aleph.web import app

Expand Down
2 changes: 1 addition & 1 deletion tests/storage/test_store_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from aleph.handlers.storage import handle_new_storage
from aleph.storage import ContentSource, RawContent
import json
from aleph.types import UnknownHashError
from aleph.exceptions import UnknownHashError


@pytest.fixture
Expand Down
3 changes: 2 additions & 1 deletion tests/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

# Mandatory import, otherwise VERIFIER_REGISTER is not populated. TODO: improve the registration system.
import aleph.chains
from aleph.network import InvalidMessageError, check_message
from aleph.network import check_message
from aleph.exceptions import InvalidMessageError

__author__ = "Moshe Malawach"
__copyright__ = "Moshe Malawach"
Expand Down