diff --git a/bencode/iszero_go1.12.go b/bencode/iszero_go1.12.go index 1aef6ef..8b3e144 100644 --- a/bencode/iszero_go1.12.go +++ b/bencode/iszero_go1.12.go @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !go1.13 // +build !go1.13 package bencode diff --git a/bencode/iszero_go1.13.go b/bencode/iszero_go1.13.go index 5cf744b..0aeba6a 100644 --- a/bencode/iszero_go1.13.go +++ b/bencode/iszero_go1.13.go @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build go1.13 // +build go1.13 package bencode diff --git a/dht/dht_server.go b/dht/dht_server.go index b24d398..fbc576d 100644 --- a/dht/dht_server.go +++ b/dht/dht_server.go @@ -317,12 +317,12 @@ func (s *Server) Node6Num() int { return s.routingTable6.Len() } // AddNode adds the node into the routing table. // // The returned value: -// NodeAdded: The node is added successfully. -// NodeNotAdded: The node is not added and is discarded. -// NodeExistAndUpdated: The node has existed, and its status has been updated. -// NodeExistAndChanged: The node has existed, but the address is inconsistent. -// The current node will be discarded. // +// NodeAdded: The node is added successfully. +// NodeNotAdded: The node is not added and is discarded. +// NodeExistAndUpdated: The node has existed, and its status has been updated. +// NodeExistAndChanged: The node has existed, but the address is inconsistent. +// The current node will be discarded. func (s *Server) AddNode(node krpc.Node) int { // For IPv6 if node.Addr.IsIPv6() { diff --git a/dht/routing_table.go b/dht/routing_table.go index ce68c1a..6d8b95d 100644 --- a/dht/routing_table.go +++ b/dht/routing_table.go @@ -155,12 +155,12 @@ func (rt *routingTable) Stop() { // AddNode adds the node into the routing table. // // The returned value: -// NodeAdded: The node is added successfully. -// NodeNotAdded: The node is not added and is discarded. -// NodeExistAndUpdated: The node has existed, and its status has been updated. -// NodeExistAndChanged: The node has existed, but the address is inconsistent. -// The current node will be discarded. // +// NodeAdded: The node is added successfully. +// NodeNotAdded: The node is not added and is discarded. +// NodeExistAndUpdated: The node has existed, and its status has been updated. +// NodeExistAndChanged: The node has existed, but the address is inconsistent. +// The current node will be discarded. func (rt *routingTable) AddNode(n krpc.Node) (r int) { if n.ID == rt.root { // Don't add itself. return NodeNotAdded diff --git a/blockhandler/block_download_handler.go b/downloadhandler/block_download_handler.go similarity index 100% rename from blockhandler/block_download_handler.go rename to downloadhandler/block_download_handler.go diff --git a/metainfo/address.go b/metainfo/address.go index 3c52e17..1931f7d 100644 --- a/metainfo/address.go +++ b/metainfo/address.go @@ -270,7 +270,8 @@ func (a Address) String() string { } // Equal reports whether n is equal to o, which is equal to -// n.HasIPAndPort(o.IP, o.Port) +// +// n.HasIPAndPort(o.IP, o.Port) func (a Address) Equal(o Address) bool { return a.Port == o.Port && a.IP.String() == o.IP.String() } diff --git a/peerprotocol/fastset.go b/peerprotocol/fastset.go index 05f7b28..150fdd3 100644 --- a/peerprotocol/fastset.go +++ b/peerprotocol/fastset.go @@ -25,10 +25,11 @@ import ( // GenerateAllowedFastSet generates some allowed fast set of the torrent file. // // Argument: -// set: generated piece set, the length of which is the number to be generated. -// sz: the number of pieces in torrent. -// ip: the of the remote peer of the connection. -// infohash: infohash of torrent. +// +// set: generated piece set, the length of which is the number to be generated. +// sz: the number of pieces in torrent. +// ip: the of the remote peer of the connection. +// infohash: infohash of torrent. // // BEP 6 func GenerateAllowedFastSet(set []uint32, sz uint32, ip net.IP, infohash metainfo.Hash) { diff --git a/blockhandler/block_upload_handler.go b/uploadhandler/block_upload_handler.go similarity index 94% rename from blockhandler/block_upload_handler.go rename to uploadhandler/block_upload_handler.go index afce147..3fc9522 100644 --- a/blockhandler/block_upload_handler.go +++ b/uploadhandler/block_upload_handler.go @@ -31,9 +31,7 @@ type BlockUploadHandler struct { } // NewBlockUploadHandler returns a new BlockUploadHandler. -func NewBlockUploadHandler(info metainfo.Info, - onBlock func(pieceIndex, pieceOffset uint32, b []byte) error, - respondBlock func(c *pp.PeerConn) error) BlockUploadHandler { +func NewBlockUploadHandler(info metainfo.Info, onBlock func(pieceIndex, pieceOffset uint32, b []byte) error, respondBlock func(c *pp.PeerConn) error) BlockUploadHandler { return BlockUploadHandler{ Info: info, OnBlock: onBlock,