]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/check.go
Fix constant name typo
[nncp.git] / src / check.go
index 4f0a081479c9e12b3e6a56beae33028ac12c7155..bd191034fe5191c5bf5136eabf377713792d7206 100644 (file)
@@ -1,6 +1,6 @@
 /*
 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-Copyright (C) 2016-2021 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2016-2022 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -37,7 +37,11 @@ func Check(
        showPrgrs bool,
 ) (bool, error) {
        hsh := MTHNew(size, 0)
-       if _, err := CopyProgressed(hsh, bufio.NewReaderSize(src, MTHSize), "check", les, showPrgrs); err != nil {
+       if _, err := CopyProgressed(
+               hsh,
+               bufio.NewReaderSize(src, MTHBlockSize),
+               "check", les, showPrgrs,
+       ); err != nil {
                return false, err
        }
        return bytes.Compare(hsh.Sum(nil), checksum) == 0, nil
@@ -62,7 +66,7 @@ func (ctx *Ctx) checkXxIsBad(nodeId *NodeId, xx TRxTx) bool {
                        return true
                }
                gut, err := Check(fd, job.Size, job.HshValue[:], les, ctx.ShowPrgrs)
-               fd.Close() // #nosec G104
+               fd.Close()
                if err != nil {
                        ctx.LogE("checking", les, err, logMsg)
                        return true
@@ -79,7 +83,7 @@ func (ctx *Ctx) Check(nodeId *NodeId) bool {
        return !(ctx.checkXxIsBad(nodeId, TRx) || ctx.checkXxIsBad(nodeId, TTx))
 }
 
-func (ctx *Ctx) CheckNoCK(nodeId *NodeId, hshValue *[MTHSize]byte, mth *MTH) (int64, error) {
+func (ctx *Ctx) CheckNoCK(nodeId *NodeId, hshValue *[MTHSize]byte, mth MTH) (int64, error) {
        dirToSync := filepath.Join(ctx.Spool, nodeId.String(), string(TRx))
        pktName := Base32Codec.EncodeToString(hshValue[:])
        pktPath := filepath.Join(dirToSync, pktName)
@@ -103,8 +107,10 @@ func (ctx *Ctx) CheckNoCK(nodeId *NodeId, hshValue *[MTHSize]byte, mth *MTH) (in
        if mth == nil {
                gut, err = Check(fd, size, hshValue[:], les, ctx.ShowPrgrs)
        } else {
-               mth.PktName = pktName
-               if _, err = mth.PrependFrom(bufio.NewReaderSize(fd, MTHSize)); err != nil {
+               if _, err = mth.PreaddFrom(
+                       bufio.NewReaderSize(fd, MTHBlockSize),
+                       pktName, ctx.ShowPrgrs,
+               ); err != nil {
                        return 0, err
                }
                if bytes.Compare(mth.Sum(nil), hshValue[:]) == 0 {