diff options
author | joe <joe@jerkface.net> | 2017-07-13 18:42:20 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-07-13 18:42:20 -0400 |
commit | adc30fe62736d1f4f539a971db681b0a5c552871 (patch) | |
tree | 411c9235f55bfe1b192b73c2a6cb7524a7e3a152 /src/Network/DatagramServer | |
parent | 36562749e2204da4500742c7f62676c19f0ce999 (diff) |
Removed type argument clutter from Routing table.
Diffstat (limited to 'src/Network/DatagramServer')
-rw-r--r-- | src/Network/DatagramServer/Types.hs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Network/DatagramServer/Types.hs b/src/Network/DatagramServer/Types.hs index 6aa7aeaa..68aa9212 100644 --- a/src/Network/DatagramServer/Types.hs +++ b/src/Network/DatagramServer/Types.hs | |||
@@ -326,25 +326,25 @@ genNodeId = either error id . S.decode <$> getEntropy nodeIdSize | |||
326 | -- is for the current deepest bucket in our routing table: | 326 | -- is for the current deepest bucket in our routing table: |
327 | -- | 327 | -- |
328 | -- > sample <- genBucketSample nid (bucketRange index is_last) | 328 | -- > sample <- genBucketSample nid (bucketRange index is_last) |
329 | genBucketSample :: ( FiniteBits (NodeId dht) | 329 | genBucketSample :: ( FiniteBits nid |
330 | , Serialize (NodeId dht) | 330 | , Serialize nid |
331 | ) => NodeId dht -> (Int,Word8,Word8) -> IO (NodeId dht) | 331 | ) => nid -> (Int,Word8,Word8) -> IO nid |
332 | genBucketSample n qmb = genBucketSample' getEntropy n qmb | 332 | genBucketSample n qmb = genBucketSample' getEntropy n qmb |
333 | 333 | ||
334 | -- | Generalizion of 'genBucketSample' that accepts a byte generator | 334 | -- | Generalizion of 'genBucketSample' that accepts a byte generator |
335 | -- function to use instead of the system entropy. | 335 | -- function to use instead of the system entropy. |
336 | genBucketSample' :: forall m dht. | 336 | genBucketSample' :: forall m dht nid. |
337 | ( Applicative m | 337 | ( Applicative m |
338 | , FiniteBits (NodeId dht) | 338 | , FiniteBits nid |
339 | , Serialize (NodeId dht) | 339 | , Serialize nid |
340 | ) => | 340 | ) => |
341 | (Int -> m ByteString) -> NodeId dht -> (Int,Word8,Word8) -> m (NodeId dht) | 341 | (Int -> m ByteString) -> nid -> (Int,Word8,Word8) -> m nid |
342 | genBucketSample' gen self (q,m,b) | 342 | genBucketSample' gen self (q,m,b) |
343 | | q <= 0 = either error id . S.decode <$> gen nodeIdSize | 343 | | q <= 0 = either error id . S.decode <$> gen nodeIdSize |
344 | | q >= nodeIdSize = pure self | 344 | | q >= nodeIdSize = pure self |
345 | | otherwise = either error id . S.decode . build <$> gen (nodeIdSize - q + 1) | 345 | | otherwise = either error id . S.decode . build <$> gen (nodeIdSize - q + 1) |
346 | where | 346 | where |
347 | nodeIdSize = finiteBitSize (undefined :: NodeId dht) `div` 8 | 347 | nodeIdSize = finiteBitSize (undefined :: nid) `div` 8 |
348 | build tl = BS.init hd <> BS.cons (h .|. t) (BS.tail tl) | 348 | build tl = BS.init hd <> BS.cons (h .|. t) (BS.tail tl) |
349 | where | 349 | where |
350 | hd = BS.take q $ S.encode self | 350 | hd = BS.take q $ S.encode self |