mirror of
https://github.com/ap-pauloafonso/ratio-spoof.git
synced 2026-01-11 20:10:22 +00:00
round rename
This commit is contained in:
parent
840525eb32
commit
f05c12bb19
4 changed files with 5 additions and 5 deletions
|
|
@ -19,7 +19,7 @@ func TestNewEmulation(t *testing.T) {
|
|||
peerId := e.PeerIdGenerator.PeerId()
|
||||
key := e.KeyGenerator.Key()
|
||||
|
||||
d, u, l := e.RoudingGenerator.NextAmountReport(2*1024*1024*1024, 1024*1024*1024, 3*1024*1024*1024, 1024)
|
||||
d, u, l := e.RoudingGenerator.Round(2*1024*1024*1024, 1024*1024*1024, 3*1024*1024*1024, 1024)
|
||||
|
||||
if peerId == "" {
|
||||
t.Errorf("%s.json should be able to generate PeerId", code)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package generator
|
||||
|
||||
type RoundingGenerator interface {
|
||||
NextAmountReport(downloadCandidateNextAmount, uploadCandidateNextAmount, leftCandidateNextAmount, pieceSize int) (downloaded, uploaded, left int)
|
||||
Round(downloadCandidateNextAmount, uploadCandidateNextAmount, leftCandidateNextAmount, pieceSize int) (downloaded, uploaded, left int)
|
||||
}
|
||||
|
||||
func NewRoundingGenerator(code string) (RoundingGenerator, error) {
|
||||
|
|
@ -11,7 +11,7 @@ func NewRoundingGenerator(code string) (RoundingGenerator, error) {
|
|||
|
||||
type DefaultRoundingGenerator struct{}
|
||||
|
||||
func (d *DefaultRoundingGenerator) NextAmountReport(downloadCandidateNextAmount, uploadCandidateNextAmount, leftCandidateNextAmount, pieceSize int) (downloaded, uploaded, left int) {
|
||||
func (d *DefaultRoundingGenerator) Round(downloadCandidateNextAmount, uploadCandidateNextAmount, leftCandidateNextAmount, pieceSize int) (downloaded, uploaded, left int) {
|
||||
|
||||
down := downloadCandidateNextAmount
|
||||
up := uploadCandidateNextAmount - (uploadCandidateNextAmount % (16 * 1024))
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import "testing"
|
|||
func TestNextAmountReport(t *testing.T) {
|
||||
r, _ := NewRoundingGenerator("")
|
||||
|
||||
d, u, l := r.NextAmountReport(656497856, 46479878, 7879879, 1024)
|
||||
d, u, l := r.Round(656497856, 46479878, 7879879, 1024)
|
||||
//same
|
||||
if d != 656497856 {
|
||||
t.Errorf("[download]got %v want %v", d, 656497856)
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ func (R *RatioSpoof) generateNextAnnounce() {
|
|||
|
||||
leftCandidate := calculateBytesLeft(downloadCandidate, R.TorrentInfo.TotalSize)
|
||||
|
||||
d, u, l := R.BitTorrentClient.RoudingGenerator.NextAmountReport(downloadCandidate, uploadCandidate, leftCandidate, R.TorrentInfo.PieceSize)
|
||||
d, u, l := R.BitTorrentClient.RoudingGenerator.Round(downloadCandidate, uploadCandidate, leftCandidate, R.TorrentInfo.PieceSize)
|
||||
|
||||
R.addAnnounce(d, u, l, (float32(d)/float32(R.TorrentInfo.TotalSize))*100)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue