kunt

golang IRC bot
git clone git://git.2f30.org/kunt.git
Log | Files | Refs | LICENSE

commit ea3b094dbc60551708a3824c754ad495a733e269
parent 2e800e2b8d361de08879acce20185db0ea4c344c
Author: sin <sin@2f30.org>
Date:   Tue Apr 30 12:33:10 +0100

rename funcs in mapfs

Diffstat:
src/mapfs/mapfs.go | 16+++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/src/mapfs/mapfs.go b/src/mapfs/mapfs.go @@ -182,7 +182,7 @@ func (m *Mapfs) CountMatches(buf []byte) int { i := 0 raw := buf if m.encrypt { - ct := m.encryptbuf(buf) + ct := m.encryptBuf(buf) raw = ct } for _, v := range m.dict { @@ -204,7 +204,7 @@ func (m *Mapfs) Put(key int, buf []byte) error { return fmt.Errorf("Key %d already in use", key) } if m.encrypt { - ct := m.encryptbuf(buf) + ct := m.encryptBuf(buf) m.dict[key] = mapfsVal{true, ct} return nil } @@ -217,12 +217,11 @@ func (m *Mapfs) Append(buf []byte) (int, error) { m.lock.Lock() defer m.lock.Unlock() if m.encrypt { - ct := m.encryptbuf(buf) + ct := m.encryptBuf(buf) key := len(m.dict) m.dict[key] = mapfsVal{true, ct} return key, nil } - key := len(m.dict) m.dict[key] = mapfsVal{true, buf} return key, nil @@ -240,7 +239,7 @@ func (m *Mapfs) Get(key int) ([]byte, error) { return nil, fmt.Errorf("No entry with key: %d", key) } if m.encrypt { - pt := m.decryptbuf(val.data) + pt := m.decryptBuf(val.data) return pt, nil } return val.data, nil @@ -255,7 +254,7 @@ func (m *Mapfs) Rand() ([]byte, int) { if i == idx { val := m.dict[k] if m.encrypt { - pt := m.decryptbuf(val.data) + pt := m.decryptBuf(val.data) return pt, k } return val.data, k @@ -280,8 +279,7 @@ func (m *Mapfs) Len() int { return len(m.dict) } -func (m *Mapfs) encryptbuf(a []byte) []byte { - //pad it +func (m *Mapfs) encryptBuf(a []byte) []byte { padded := a diff := len(a) % blowfish.BlockSize if diff != 0 { @@ -301,7 +299,7 @@ func (m *Mapfs) encryptbuf(a []byte) []byte { return ct } -func (m *Mapfs) decryptbuf(a []byte) []byte { +func (m *Mapfs) decryptBuf(a []byte) []byte { pt := make([]byte, len(a)) for i := 0; i < len(a); i += blowfish.BlockSize { m.cipher.Decrypt(pt[i:i+blowfish.BlockSize], a[i:i+blowfish.BlockSize])