Skip to content
Snippets Groups Projects
Select Git revision
  • 461a58e6a4e0622b852efd209c7e137946b5dd92
  • release default protected
  • XX-4719/announcementChannels
  • jonah/channelCodenames
  • master protected
  • XX-4601/HavenInvites
  • sihSize
  • project/HavenNotifications
  • hotfix/base8KeySizes
  • Anne/Project/DM
  • XX-4004_ownership_vector_test
  • XX-3566_constant_time_comparison
  • XX-4132-upgrade-channel-keying
  • XX-4133-rsa-to-private
  • XX-3958/ConnectionCLI
  • xx-3893/asymmetric
  • xx-3891/symmetric-integration
  • hotfix/groupChat
  • XX-3770/UpdateExternalDeps
  • dev
  • waitingRoundsRewrite
  • v0.0.9
  • v0.0.8
  • v0.0.7
  • v0.0.6
  • v0.0.5
  • v0.0.4
  • v0.0.3
  • v0.0.2
  • v0.0.1
30 results

int_test.go

Blame
  • partTracker.go 1.94 KiB
    ////////////////////////////////////////////////////////////////////////////////
    // Copyright © 2020 xx network SEZC                                           //
    //                                                                            //
    // Use of this source code is governed by a license that can be found in the  //
    // LICENSE file                                                               //
    ////////////////////////////////////////////////////////////////////////////////
    
    package fileTransfer
    
    import (
    	"gitlab.com/elixxir/client/storage/utility"
    )
    
    // sentFilePartTracker contains utility.StateVector that tracks which parts have
    // arrived. It adheres to the FilePartTracker interface.
    type sentFilePartTracker struct {
    	*utility.StateVector
    }
    
    // GetPartStatus returns the status of the sent file part with the given part
    // number.
    func (s *sentFilePartTracker) GetPartStatus(partNum uint16) FpStatus {
    	if uint32(partNum) >= s.GetNumKeys() {
    		return -1
    	}
    
    	switch s.Used(uint32(partNum)) {
    	case true:
    		return FpArrived
    	case false:
    		return FpUnsent
    	default:
    		return -1
    	}
    }
    
    // GetNumParts returns the total number of file parts in the transfer.
    func (s *sentFilePartTracker) GetNumParts() uint16 {
    	return uint16(s.GetNumKeys())
    }
    
    // receivedFilePartTracker contains utility.StateVector that tracks which parts
    // have been received. It adheres to the FilePartTracker interface.
    type receivedFilePartTracker struct {
    	*utility.StateVector
    }
    
    // GetPartStatus returns the status of the received file part with the given
    // part number.
    func (r *receivedFilePartTracker) GetPartStatus(partNum uint16) FpStatus {
    	if uint32(partNum) >= r.GetNumKeys() {
    		return -1
    	}
    
    	switch r.Used(uint32(partNum)) {
    	case true:
    		return FpReceived
    	case false:
    		return FpUnsent
    	default:
    		return -1
    	}
    }
    
    // GetNumParts returns the total number of file parts in the transfer.
    func (r *receivedFilePartTracker) GetNumParts() uint16 {
    	return uint16(r.GetNumKeys())
    }