-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmod.rs
55 lines (53 loc) · 2.05 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (C) 2024 [Kulpreet Singh]
//
// This file is part of P2Poolv2
//
// P2Poolv2 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 (at your option)
// any later version.
//
// P2Poolv2 is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// P2Poolv2. If not, see <https://www.gnu.org/licenses/>.
use crate::node::messages::Message;
use crate::shares::miner_message::MinerWorkbase;
use crate::shares::ShareBlock;
use std::error::Error;
use tokio::sync::oneshot;
/// Commands for communication between node handle and actor
/// We allow large enum variants because we want to avoid heap allocations for these frequently used messages
/// We know that the size difference is large, and we are willing to accept it
#[derive(Debug)]
#[allow(dead_code)]
#[allow(clippy::large_enum_variant)]
pub enum Command {
/// Command telling node's event loop to send share to network
SendGossip(
Vec<u8>,
oneshot::Sender<Result<(), Box<dyn Error + Send + Sync>>>,
),
/// Command telling node's event loop to send message to a specific peer
SendToPeer(
libp2p::PeerId,
Message,
oneshot::Sender<Result<(), Box<dyn Error + Send + Sync>>>,
),
/// Command to get a list of connected peers
GetPeers(oneshot::Sender<Vec<libp2p::PeerId>>),
/// Command to shutdown node
Shutdown(oneshot::Sender<()>),
/// Command to add share to the chain
AddShare(
ShareBlock,
oneshot::Sender<Result<(), Box<dyn Error + Send + Sync>>>,
),
/// Command to store workbase in the node's database
StoreWorkbase(
MinerWorkbase,
oneshot::Sender<Result<(), Box<dyn Error + Send + Sync>>>,
),
}