From ee99709e8d68f3fb9da737d0bbeed8ad05a4081a Mon Sep 17 00:00:00 2001 From: jbhusson <jonah@elixxir.io> Date: Tue, 13 Sep 2022 14:09:17 -0400 Subject: [PATCH] Swap to integer for period --- bindings/fileTransfer.go | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/bindings/fileTransfer.go b/bindings/fileTransfer.go index 4c3c05a4b..e41405602 100644 --- a/bindings/fileTransfer.go +++ b/bindings/fileTransfer.go @@ -268,12 +268,9 @@ func (f *FileTransfer) CloseSend(tidBytes []byte) error { // Parameters: // - tidBytes - file transfer ID // - callback - callback that reports file reception progress -// - period - duration to wait between progress callbacks triggering, -// formatted as a string containing a decimal number followed by unit -// specification such as "300ms", "-1.5h" or "2h45m". -// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". +// - period - duration (in ms) to wait between progress callbacks triggering func (f *FileTransfer) RegisterSentProgressCallback(tidBytes []byte, - callback FileTransferSentProgressCallback, period string) error { + callback FileTransferSentProgressCallback, period int) error { cb := func(completed bool, arrived, total uint16, st fileTransfer.SentTransfer, t fileTransfer.FilePartTracker, err error) { prog := &Progress{ @@ -285,10 +282,7 @@ func (f *FileTransfer) RegisterSentProgressCallback(tidBytes []byte, pm, err := json.Marshal(prog) callback.Callback(pm, &FilePartTracker{t}, err) } - p, err := time.ParseDuration(period) - if err != nil { - return err - } + p := time.Millisecond * time.Duration(period) tid := ftCrypto.UnmarshalTransferID(tidBytes) return f.w.RegisterSentProgressCallback(&tid, cb, p) @@ -302,12 +296,9 @@ func (f *FileTransfer) RegisterSentProgressCallback(tidBytes []byte, // Parameters: // - tidBytes - file transfer ID // - callback - callback that reports file reception progress -// - period - duration to wait between progress callbacks triggering, -// formatted as a string containing a decimal number followed by unit -// specification such as "300ms", "-1.5h" or "2h45m". -// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". +// - period - duration (in ms) to wait between progress callbacks triggering func (f *FileTransfer) RegisterReceivedProgressCallback(tidBytes []byte, - callback FileTransferReceiveProgressCallback, period string) error { + callback FileTransferReceiveProgressCallback, period int) error { cb := func(completed bool, received, total uint16, rt fileTransfer.ReceivedTransfer, t fileTransfer.FilePartTracker, err error) { prog := &Progress{ @@ -319,10 +310,8 @@ func (f *FileTransfer) RegisterReceivedProgressCallback(tidBytes []byte, pm, err := json.Marshal(prog) callback.Callback(pm, &FilePartTracker{t}, err) } - p, err := time.ParseDuration(period) - if err != nil { - return err - } + p := time.Millisecond * time.Duration(period) + tid := ftCrypto.UnmarshalTransferID(tidBytes) return f.w.RegisterReceivedProgressCallback(&tid, cb, p) } -- GitLab