mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-17 02:47:51 +01:00
Minor cleanup
This commit is contained in:
@@ -25,7 +25,7 @@ var transferSequenceTimeout = time.Minute * 10
|
||||
// startFileTransferUDT starts a file transfer to a remote peer.
|
||||
// It creates a virtual UDT client to transfer data to a remote peer. Counterintuitively, this will be the "file server" peer.
|
||||
func (peer *PeerInfo) startFileTransferUDT(hash []byte, offset, limit uint64, sequenceNumber uint32) (err error) {
|
||||
virtualConnection := newVirtualPacketConn(peer, 0, hash, offset, limit, false)
|
||||
virtualConnection := newVirtualPacketConn(peer, 0, hash, offset, limit)
|
||||
|
||||
// register the sequence since packets are sent bi-directional
|
||||
virtualConnection.sequenceNumber = sequenceNumber
|
||||
@@ -47,7 +47,7 @@ func (peer *PeerInfo) startFileTransferUDT(hash []byte, offset, limit uint64, se
|
||||
|
||||
// RequestFileTransferUDT creates a UDT server listening for incoming data transfer and requests a file transfer from a remote peer.
|
||||
func (peer *PeerInfo) RequestFileTransferUDT(hash []byte, offset, limit uint64) (udtConn net.Conn, err error) {
|
||||
virtualConnection := newVirtualPacketConn(peer, 0, hash, offset, limit, true)
|
||||
virtualConnection := newVirtualPacketConn(peer, 0, hash, offset, limit)
|
||||
|
||||
// new sequence
|
||||
sequence := networks.Sequences.NewSequenceBi(peer.PublicKey, &peer.messageSequence, virtualConnection, transferSequenceTimeout, virtualConnection.sequenceTerminate)
|
||||
|
||||
@@ -19,9 +19,6 @@ import (
|
||||
type virtualPacketConn struct {
|
||||
peer *PeerInfo
|
||||
|
||||
// isListenMode puts this connection into listening mode (counterintuitively, a server).
|
||||
isListenMode bool
|
||||
|
||||
// Transfer settings
|
||||
transferProtocol uint8 // 0 = UDT
|
||||
hash []byte // The requested hash.
|
||||
@@ -43,14 +40,13 @@ type virtualPacketConn struct {
|
||||
}
|
||||
|
||||
// newVirtualPacketConn creates a new virtual connection (both incomign and outgoing).
|
||||
func newVirtualPacketConn(peer *PeerInfo, protocol uint8, hash []byte, offset, limit uint64, isListen bool) (v *virtualPacketConn) {
|
||||
func newVirtualPacketConn(peer *PeerInfo, protocol uint8, hash []byte, offset, limit uint64) (v *virtualPacketConn) {
|
||||
v = &virtualPacketConn{
|
||||
transferProtocol: protocol,
|
||||
peer: peer,
|
||||
transferProtocol: protocol,
|
||||
hash: hash,
|
||||
offset: offset,
|
||||
limit: limit,
|
||||
isListenMode: isListen,
|
||||
incomingData: make(chan []byte),
|
||||
outgoingData: make(chan []byte),
|
||||
terminateChan: make(chan struct{}),
|
||||
|
||||
Reference in New Issue
Block a user