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
|
{-# LANGUAGE OverloadedStrings #-}
module Shared
(echoM, echoBytes, unitM, swapM, reverseM, shiftR
) where
import Data.ByteString (ByteString)
import Remote.KRPC
unitM :: Method () ()
unitM = method "unit" [] []
echoM :: Method Int Int
echoM = method "echo" ["x"] ["x"]
echoBytes :: Method ByteString ByteString
echoBytes = method "echoBytes" ["x"] ["x"]
reverseM :: Method [Int] [Int]
reverseM = method "reverse" ["xs"] ["ys"]
swapM :: Method (Int, Int) (Int, Int)
swapM = method "swap" ["x", "y"] ["b", "a"]
shiftR :: Method ((), Int, [Int]) ([Int], (), Int)
shiftR = method "shiftR" ["x", "y", "z"] ["a", "b", "c"]
{-
type NodeId = Int
type InfoHashe = Int
type NodeAddr = Int
type Token = Int
type
ping :: Method NodeId NodeId
ping = method "ping" ["id"] ["id"]
find_node :: Method (NodeId, NodeId) (NodeId, NodeAddr)
find_node = method "find_node" ["id", "target"] ["id", "nodes"]
get_peers :: Method (NodeId :*: InfoHash) (NodeId, Token, NodeAddr :|: NodeAddr)
get_peers = method "get_peers"
("id", "target")
("id", "token", view ("values" :|: "nodes"))
view :: BEncodable -> Maybe BEncodable
view = undefined
announce_peer :: Method (NodeId, InfoHash, PortNumber, Token) NodeId
announce_peer = undefined
-}
|