]> Sergey Matveev's repositories - btrtrc.git/blobdiff - tracker/udp/protocol.go
Some tidying in tracker/udp
[btrtrc.git] / tracker / udp / protocol.go
index 4a8dc6681512f14710023f5992647b001b124ec4..f6beb4c6d55c3e495730fcac1caebfc23c717d4e 100644 (file)
@@ -13,9 +13,11 @@ const (
        ActionAnnounce
        ActionScrape
        ActionError
+)
 
-       ConnectRequestConnectionId = 0x41727101980
+const ConnectRequestConnectionId = 0x41727101980
 
+const (
        // BEP 41
        optionTypeEndOfOptions = 0
        optionTypeNOP          = 1
@@ -57,7 +59,7 @@ type InfoHash = [20]byte
 
 func marshal(data interface{}) (b []byte, err error) {
        var buf bytes.Buffer
-       err = binary.Write(&buf, binary.BigEndian, data)
+       err = Write(&buf, data)
        b = buf.Bytes()
        return
 }
@@ -70,6 +72,7 @@ func mustMarshal(data interface{}) []byte {
        return b
 }
 
+// This is for fixed-size, builtin types only I think.
 func Write(w io.Writer, data interface{}) error {
        return binary.Write(w, binary.BigEndian, data)
 }