// read bytes from the io.Reader passed in and account them
read bytes from the io.Reader passed in and account them
// read bytes from the io . Reader passed in and account them
func (acc *Account) read(in io.Reader, p []byte) (n int, err error) {
	acc.statmu.Lock()
	if acc.max >= 0 && Stats.GetBytes() >= acc.max {
		acc.statmu.Unlock()
		return 0, ErrorMaxTransferLimitReached
	}
	if acc.start.IsZero() {
		acc.start = time.Now()
	}
	acc.statmu.Unlock()
	n, err = in.Read(p)
	acc.statmu.Lock()
	acc.lpBytes += n
	acc.bytes += int64(n)
	acc.statmu.Unlock()
	Stats.Bytes(int64(n))
	limitBandwidth(n)
	return
}
func ( acc * Account ) read ( in io . Reader , p [ ] byte ) ( n int , err error ) { acc . statmu . Lock ( ) if acc . max >= 0 && Stats . GetBytes ( ) >= acc . max { acc . statmu . Unlock ( ) return 0 , ErrorMaxTransferLimitReached } if acc . start . IsZero ( ) { acc . start = time . Now ( ) } acc . statmu . Unlock ( ) n , err = in . Read ( p ) acc . statmu . Lock ( ) acc . lpBytes += n acc . bytes += int64 ( n ) acc . statmu . Unlock ( ) Stats . Bytes ( int64 ( n ) ) limitBandwidth ( n ) return }
read bytes from the io.Reader passed in and account them
read bytes from the io . Reader passed in and account them
// Set start time. // Update Stats