From 9a462f9d87c82586996bd88a09c65d86e8550e10 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Sat, 28 Mar 2015 19:49:01 +0000 Subject: [PATCH] refactor: simplify NewNaClEncryptor - rely on default nil values on initialisation - inline --- router/crypto.go | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/router/crypto.go b/router/crypto.go index 9a883b7c..855a2c28 100644 --- a/router/crypto.go +++ b/router/crypto.go @@ -308,24 +308,14 @@ func (nd *NonDecryptor) ReceiveNonce(msg []byte) { } func NewNaClDecryptor(conn *LocalConnection) *NaClDecryptor { - inst := NaClDecryptorInstance{ - nonce: nil, - previousNonce: nil, - usedOffsets: bit.New(), - previousUsedOffsets: nil, - highestOffsetSeen: 0, - nonceChan: make(chan *[24]byte, ChannelSize)} - instDF := NaClDecryptorInstance{ - nonce: nil, - previousNonce: nil, - usedOffsets: bit.New(), - previousUsedOffsets: nil, - highestOffsetSeen: 0, - nonceChan: make(chan *[24]byte, ChannelSize)} return &NaClDecryptor{ NonDecryptor: *NewNonDecryptor(conn), - instance: &inst, - instanceDF: &instDF} + instance: &NaClDecryptorInstance{ + usedOffsets: bit.New(), + nonceChan: make(chan *[24]byte, ChannelSize)}, + instanceDF: &NaClDecryptorInstance{ + usedOffsets: bit.New(), + nonceChan: make(chan *[24]byte, ChannelSize)}} } func (nd *NaClDecryptor) Shutdown() {