]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/tx.go
Simpler copy
[nncp.git] / src / tx.go
index 73fbe4ec12bfa118d7d7ff1ab15c6f1ed2667fa1..14f73d23c627313102100a8d340d0aae0e92ed0d 100644 (file)
--- a/src/tx.go
+++ b/src/tx.go
@@ -36,7 +36,6 @@ import (
        xdr "github.com/davecgh/go-xdr/xdr2"
        "github.com/dustin/go-humanize"
        "github.com/klauspost/compress/zstd"
-       "golang.org/x/crypto/blake2b"
        "golang.org/x/crypto/chacha20poly1305"
 )
 
@@ -186,7 +185,7 @@ func throughTmpFile(r io.Reader) (
                return
        }
        nonce := make([]byte, aead.NonceSize())
-       written, err := aeadProcess(aead, nonce, true, r, tmpW)
+       written, err := aeadProcess(aead, nonce, nil, true, r, tmpW)
        if err != nil {
                rerr = err
                return
@@ -202,7 +201,7 @@ func throughTmpFile(r io.Reader) (
        }
        r, w := io.Pipe()
        go func() {
-               if _, err := aeadProcess(aead, nonce, false, bufio.NewReader(src), w); err != nil {
+               if _, err := aeadProcess(aead, nonce, nil, false, bufio.NewReader(src), w); err != nil {
                        w.CloseWithError(err) // #nosec G104
                }
        }()
@@ -406,13 +405,13 @@ func (ctx *Ctx) TxFile(
 
        leftSize := fileSize
        metaPkt := ChunkedMeta{
-               Magic:     MagicNNCPMv1,
+               Magic:     MagicNNCPMv2.B,
                FileSize:  uint64(fileSize),
                ChunkSize: uint64(chunkSize),
-               Checksums: make([][32]byte, 0, (fileSize/chunkSize)+1),
+               Checksums: make([][MTHSize]byte, 0, (fileSize/chunkSize)+1),
        }
        for i := int64(0); i < (fileSize/chunkSize)+1; i++ {
-               hsh := new([32]byte)
+               hsh := new([MTHSize]byte)
                metaPkt.Checksums = append(metaPkt.Checksums, *hsh)
        }
        var sizeToSend int64
@@ -431,10 +430,7 @@ func (ctx *Ctx) TxFile(
                if err != nil {
                        return err
                }
-               hsh, err = blake2b.New256(nil)
-               if err != nil {
-                       return err
-               }
+               hsh = MTHNew(0, 0)
                _, err = ctx.Tx(
                        node,
                        pkt,