From b93f519931b5d50e4d978ce854de2caf0e41f8e2 Mon Sep 17 00:00:00 2001 From: Dmitry Zuikov Date: Wed, 15 Feb 2023 15:03:15 +0300 Subject: [PATCH] wip --- hbs2-peer/app/PeerMain.hs | 17 ++++++++++------- nix/peer/flake.lock | 6 +++--- nix/peer/flake.nix | 1 + 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/hbs2-peer/app/PeerMain.hs b/hbs2-peer/app/PeerMain.hs index 9446616b..d44e18a5 100644 --- a/hbs2-peer/app/PeerMain.hs +++ b/hbs2-peer/app/PeerMain.hs @@ -398,12 +398,16 @@ runPeer opts = Exception.handle myException $ do addPeers @e pl ps subscribe @e PeerAnnounceEventKey $ \(PeerAnnounceEvent pip nonce) -> do - unless (nonce == pnonce) $ do - debug $ "Got peer announce!" <+> pretty pip - pd <- find (KnownPeerKey pip) id -- <&> isJust - banned <- maybe (pure False) (peerBanned pip) pd - let known = isJust pd && not banned - unless known $ sendPing pip + unless (nonce == pnonce) $ do + debug $ "Got peer announce!" <+> pretty pip + pd <- find (KnownPeerKey pip) id -- <&> isJust + banned <- maybe (pure False) (peerBanned pip) pd + let known = isJust pd && not banned + unless known $ sendPing pip + + subscribe @e BlockAnnounceInfoKey $ \(BlockAnnounceEvent p bi no) -> do + pa <- toPeerAddr p + liftIO $ atomically $ writeTQueue rpcQ (CHECK no pa (view biHash bi)) subscribe @e AnyKnownPeerEventKey $ \(KnownPeerEvent p d) -> do @@ -599,7 +603,6 @@ runPeer opts = Exception.handle myException $ do self <- ownPeer @e subscribe @e BlockAnnounceInfoKey $ \(BlockAnnounceEvent p bi no) -> do - debug "Peer announce wtf?" unless (p == self) do pa <- toPeerAddr p liftIO $ atomically $ writeTQueue rpcQ (CHECK no pa (view biHash bi)) diff --git a/nix/peer/flake.lock b/nix/peer/flake.lock index 72c685b8..d4183139 100644 --- a/nix/peer/flake.lock +++ b/nix/peer/flake.lock @@ -236,11 +236,11 @@ "suckless-conf": "suckless-conf_2" }, "locked": { - "lastModified": 1676454454, - "narHash": "sha256-d6SjaJIwYwuwsCh+Ed6Mjyx12LY48hRqbWkcXpyQ35w=", + "lastModified": 1676462171, + "narHash": "sha256-erKiiQmbFLnoDLCT3FckSIBTnLpdS8qbW+YhSG+9yYI=", "owner": "voidlizard", "repo": "hbs2", - "rev": "b6af96db6c41c5bec176e892a9716a4161c9049c", + "rev": "0bbe002fff364bf5cc4f8675c5c43b07833255f3", "type": "github" }, "original": { diff --git a/nix/peer/flake.nix b/nix/peer/flake.nix index 62ded14b..635d40fb 100644 --- a/nix/peer/flake.nix +++ b/nix/peer/flake.nix @@ -90,6 +90,7 @@ rpc "127.0.0.1:13331" key "./key" storage "/root/hbs2" accept-block-announce "AAh9rjcgg2Zfmd9c8xAhVPBEmUCyYM7wHGxjjqYDZYRb" +accept-block-announce "FA9ZptS3esbGYqrKTXJKTGbctGkQTSsz1ZePQHJzRAQ3" ''; };