lib.rs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* This file is part of DarkFi (https://dark.fi)
  2. *
  3. * Copyright (C) 2020-2024 Dyne.org foundation
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Affero General Public License as
  7. * published by the Free Software Foundation, either version 3 of the
  8. * License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Affero General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. use darkfi::event_graph::Event;
  19. use darkfi_serial::{
  20. async_trait, deserialize_async, serialize_async, Encodable, SerialDecodable, SerialEncodable,
  21. };
  22. use std::sync::Arc;
  23. pub const PROTOCOL_VERSION: u32 = 1;
  24. pub struct LocalEventGraph {
  25. pub unref_tips: Vec<(u64, blake3::Hash)>,
  26. }
  27. impl LocalEventGraph {
  28. pub fn new() -> Self {
  29. Self { unref_tips: vec![] }
  30. }
  31. }
  32. #[derive(Debug, Clone, SerialEncodable, SerialDecodable)]
  33. pub struct VersionMessage {
  34. pub protocol_version: u32,
  35. }
  36. impl VersionMessage {
  37. pub fn new() -> Self {
  38. Self { protocol_version: PROTOCOL_VERSION }
  39. }
  40. }
  41. #[derive(Debug, Clone, SerialEncodable, SerialDecodable)]
  42. pub struct FetchEventsMessage {
  43. unref_tips: Vec<(u64, blake3::Hash)>,
  44. }
  45. impl FetchEventsMessage {
  46. pub fn new(unref_tips: Vec<(u64, blake3::Hash)>) -> Self {
  47. Self { unref_tips }
  48. }
  49. }
  50. pub const MSG_EVENT: u8 = 1;
  51. pub const MSG_FETCHEVENTS: u8 = 2;