Skip to content

Commit

Permalink
Remove wallet events and added coins parser / handlers
Browse files Browse the repository at this point in the history
This log has been removed from chia in the most recent versions so it
serves no purpose to have the logic here. I've submitted a PR to re-add
the log back, if that happens we can revert this change.

Chia-Network/chia-blockchain#2720
  • Loading branch information
martomi committed Apr 25, 2021
1 parent de9b8c5 commit a23f068
Show file tree
Hide file tree
Showing 18 changed files with 5 additions and 214 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ helps with automated monitoring and sends you a mobile notification in case some
| Harvester | Experiencing networking issues? Harvester did not participate in any challenge for 120 seconds. It's now working again. | NORMAL |
| Harvester | Seeking plots took too long: 40 seconds! | NORMAL |
| Full Node | Experiencing networking issues? Skipped 42 signage points! | NORMAL |
| Wallet | Cha-ching! Just received 2.0 XCH ☘️ | LOW |
| Daily Stats | Hello farmer! 👋 Here's what happened in the last 24 hours: <br /><br /> Received ☘️: **2.00** XCH️<br /> Proofs 🧾: **2** found<br /> Search 🔍: **0.46**s average, **15.31**s max <br/> Plots 🌱: **42**, new: **2** <br /> Eligible plots 🥇: **0.08** average<br /> Skipped SPs ⚠️: 7 (0.01%) <br /> | LOW |
| Daily Stats | Hello farmer! 👋 Here's what happened in the last 24 hours: <br /><br /> Proofs 🧾: **2** found<br /> Search 🔍: **0.46**s average, **15.31**s max <br/> Plots 🌱: **42**, new: **2** <br /> Eligible plots 🥇: **0.08** average<br /> Skipped SPs ⚠️: 7 (0.01%) <br /> | LOW |

## How it works?

Expand Down
8 changes: 0 additions & 8 deletions config-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,22 @@ daily_stats:
# information. You can delete the sections which you aren't using.
# You can also enable more than one notifier and send different
# notifications to each of them. E.g. enable daily_stats only to E-mail.
# If you enable wallet_events you'll get notifications anytime your
# wallet receives some XCH (e.g. farming reward).
notifier:
pushover:
enable: false
daily_stats: true
wallet_events: true
credentials:
api_token: 'dummy_token'
user_key: 'dummy_key'
telegram:
enable: false
daily_stats: true
wallet_events: true
credentials:
bot_token: 'dummy_bot_token'
chat_id: 'dummy_chat_id'
smtp:
enable: false
daily_stats: true
wallet_events: true
credentials:
sender: '[email protected]'
sender_name: 'chiadog'
Expand All @@ -66,17 +61,14 @@ notifier:
script:
enable: false
daily_stats: true
wallet_events: true
script_path: 'tests/test_script.sh'
discord:
enable: false
daily_stats: true
wallet_events: true
credentials:
webhook_url: 'https://discord.com/api/webhooks/...'
slack:
enable: false
daily_stats: true
wallet_events: true
credentials:
webhook_url: 'https://hooks.slack.com/services/...'
7 changes: 0 additions & 7 deletions src/chia_log/handlers/daily_stats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# project
from ...parsers.finished_signage_point_parser import FinishedSignagePointMessage
from ...parsers.harvester_activity_parser import HarvesterActivityMessage
from ...parsers.wallet_added_coin_parser import WalletAddedCoinMessage


class FinishedSignageConsumer(ABC):
Expand All @@ -19,12 +18,6 @@ def consume(self, obj: HarvesterActivityMessage):
pass


class WalletAddedCoinConsumer(ABC):
@abstractmethod
def consume(self, obj: WalletAddedCoinMessage):
pass


class StatAccumulator(ABC):
@abstractmethod
def get_summary(self) -> str:
Expand Down

This file was deleted.

13 changes: 1 addition & 12 deletions src/chia_log/handlers/daily_stats/stats_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
from time import sleep

# project
from . import HarvesterActivityConsumer, WalletAddedCoinConsumer, FinishedSignageConsumer
from . import HarvesterActivityConsumer, FinishedSignageConsumer
from .stat_accumulators.eligible_plots_stats import EligiblePlotsStats
from .stat_accumulators.wallet_added_coin_stats import WalletAddedCoinStats
from .stat_accumulators.search_time_stats import SearchTimeStats
from .stat_accumulators.signage_point_stats import SignagePointStats
from .stat_accumulators.found_proof_stats import FoundProofStats
from .stat_accumulators.number_plots_stats import NumberPlotsStats
from src.chia_log.parsers.wallet_added_coin_parser import WalletAddedCoinMessage
from src.chia_log.parsers.harvester_activity_parser import HarvesterActivityMessage
from src.chia_log.parsers.finished_signage_point_parser import FinishedSignagePointMessage
from src.notifier.notify_manager import NotifyManager
Expand All @@ -40,7 +38,6 @@ def __init__(self, config: dict, notify_manager: NotifyManager):
logging.info("Enabled stats for daily notifications")
self._notify_manager = notify_manager
self._stat_accumulators = [
WalletAddedCoinStats(),
FoundProofStats(),
SearchTimeStats(),
NumberPlotsStats(),
Expand All @@ -58,14 +55,6 @@ def __init__(self, config: dict, notify_manager: NotifyManager):
self._thread = Thread(target=self._run_loop)
self._thread.start()

def consume_wallet_messages(self, objects: List[WalletAddedCoinMessage]):
if not self._enable:
return
for stat_acc in self._stat_accumulators:
if isinstance(stat_acc, WalletAddedCoinConsumer):
for obj in objects:
stat_acc.consume(obj)

def consume_harvester_messages(self, objects: List[HarvesterActivityMessage]):
if not self._enable:
return
Expand Down
42 changes: 0 additions & 42 deletions src/chia_log/handlers/wallet_added_coin_handler.py

This file was deleted.

3 changes: 1 addition & 2 deletions src/chia_log/log_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from src.chia_log.handlers.daily_stats.stats_manager import StatsManager
from src.chia_log.handlers.harvester_activity_handler import HarvesterActivityHandler
from src.chia_log.handlers.finished_signage_point_handler import FinishedSignagePointHandler
from src.chia_log.handlers.wallet_added_coin_handler import WalletAddedCoinHandler
from src.chia_log.log_consumer import LogConsumerSubscriber, LogConsumer
from src.notifier.notify_manager import NotifyManager

Expand All @@ -29,7 +28,7 @@ def __init__(
):
self._notify_manager = notify_manager
self._stats_manager = stats_manager
self._handlers = [HarvesterActivityHandler(), FinishedSignagePointHandler(), WalletAddedCoinHandler()]
self._handlers = [HarvesterActivityHandler(), FinishedSignagePointHandler()]
log_consumer.subscribe(self)

def consume_logs(self, logs: str):
Expand Down
49 changes: 0 additions & 49 deletions src/chia_log/parsers/wallet_added_coin_parser.py

This file was deleted.

5 changes: 1 addition & 4 deletions src/notifier/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class EventService(Enum):
HARVESTER = 0
FARMER = 1
FULL_NODE = 2
WALLET = 3
DAILY = 4
DAILY = 3


@dataclass
Expand Down Expand Up @@ -70,8 +69,6 @@ def __init__(self, title_prefix: str, config: dict):
if config["daily_stats"]:
self._notification_types.append(EventType.DAILY_STATS)
self._notification_services.append(EventService.DAILY)
if config["wallet_events"]:
self._notification_services.append(EventService.WALLET)
except KeyError as key:
logging.error(f"Invalid config.yaml. Missing key: {key}")

Expand Down
28 changes: 0 additions & 28 deletions tests/chia_log/handlers/test_wallet_added_coin_handler.py

This file was deleted.

6 changes: 0 additions & 6 deletions tests/chia_log/logs/wallet_added_coin/nominal.txt

This file was deleted.

27 changes: 0 additions & 27 deletions tests/chia_log/parsers/test_wallet_added_coin_parser.py

This file was deleted.

1 change: 0 additions & 1 deletion tests/notifier/test_discord_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def setUp(self) -> None:
config={
"enable": True,
"daily_stats": True,
"wallet_events": True,
"credentials": {"webhook_url": webhook_url},
},
)
Expand Down
1 change: 0 additions & 1 deletion tests/notifier/test_pushover_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def setUp(self) -> None:
config={
"enable": True,
"daily_stats": True,
"wallet_events": True,
"credentials": {"api_token": self.api_token, "user_key": self.user_key},
},
)
Expand Down
2 changes: 1 addition & 1 deletion tests/notifier/test_script_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TestScriptNotifier(unittest.TestCase):
def setUp(self) -> None:
self.notifier = ScriptNotifier(
title_prefix="Test",
config={"enable": True, "daily_stats": True, "wallet_events": True, "script_path": "tests/test_script.sh"},
config={"enable": True, "daily_stats": True, "script_path": "tests/test_script.sh"},
)

def testLowPriorityNotifications(self):
Expand Down
1 change: 0 additions & 1 deletion tests/notifier/test_slack_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def setUp(self) -> None:
config={
"enable": True,
"daily_stats": True,
"wallet_events": True,
"credentials": {"webhook_url": webhook_url},
},
)
Expand Down
1 change: 0 additions & 1 deletion tests/notifier/test_smtp_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def setUp(self) -> None:
config={
"enable": True,
"daily_stats": True,
"wallet_events": True,
"credentials": {
"sender": sender,
"sender_name": sender_name,
Expand Down
1 change: 0 additions & 1 deletion tests/notifier/test_telegram_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def setUp(self) -> None:
config={
"enable": True,
"daily_stats": True,
"wallet_events": True,
"credentials": {"bot_token": bot_token, "chat_id": chat_id},
},
)
Expand Down

0 comments on commit a23f068

Please sign in to comment.