From 9b3098c3676d25d1ab4346d1f9c7632e45634ab8 Mon Sep 17 00:00:00 2001 From: Sanjit Bhat Date: Mon, 7 Oct 2024 14:30:05 -0400 Subject: [PATCH] make goose happy --- kt/auditor.go | 25 +++++++++++++++---------- kt/client.go | 4 +--- kt/serde_misc.go | 2 +- kt/test.go | 2 -- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/kt/auditor.go b/kt/auditor.go index b3d3039..32d98d9 100644 --- a/kt/auditor.go +++ b/kt/auditor.go @@ -15,22 +15,27 @@ type Auditor struct { histInfo []*AdtrEpochInfo } +func (a *Auditor) checkOneUpd(nextEpoch uint64, mapLabel, mapVal []byte) bool { + getReply := a.keyMap.Get([]byte(mapLabel)) + if getReply.Error || getReply.ProofTy { + return true + } + // as long as we store the entire mapVal, don't think it matters + // if it has more bytes past the MapValPre. + valPre, _, err1 := MapValPreDecode(mapVal) + if err1 || valPre.Epoch != nextEpoch { + return true + } + return false +} + // checkUpd checks that updates are okay to apply, and errors on fail. func (a *Auditor) checkUpd(upd map[string][]byte) bool { nextEpoch := uint64(len(a.histInfo)) var err0 bool for mapLabel, mapVal := range upd { - getReply := a.keyMap.Get([]byte(mapLabel)) - if getReply.Error || getReply.ProofTy { - err0 = true - break - } - // as long as we store the entire mapVal, don't think it matters - // if it has more bytes past the MapValPre. - valPre, _, err1 := MapValPreDecode(mapVal) - if err1 || valPre.Epoch != nextEpoch { + if a.checkOneUpd(nextEpoch, []byte(mapLabel), mapVal) { err0 = true - break } } return err0 diff --git a/kt/client.go b/kt/client.go index 89ba627..58afd22 100644 --- a/kt/client.go +++ b/kt/client.go @@ -82,7 +82,6 @@ func (c *Client) checkHist(uid uint64, dig []byte, membs []*MembHide) bool { ver := uint64(ver0) if c.checkMembHide(uid, ver, dig, memb) { err0 = true - break } } return err0 @@ -120,7 +119,7 @@ func (c *Client) Put(pk []byte) (uint64, *Evid, bool) { if c.checkNonMemb(c.uid, c.nextVer+1, dig.Dig, bound) { return 0, nil, true } - c.nextVer++ + c.nextVer += 1 return dig.Epoch, nil, false } @@ -217,7 +216,6 @@ func (c *Client) Audit(adtrAddr uint64, adtrPk cryptoffi.PublicKey) (*Evid, bool if err2 { evid0 = evid1 err1 = true - break } } return evid0, err1 diff --git a/kt/serde_misc.go b/kt/serde_misc.go index 492abf0..7392951 100644 --- a/kt/serde_misc.go +++ b/kt/serde_misc.go @@ -19,7 +19,7 @@ func MembHideSlice1DDecode(b0 []byte) ([]*MembHide, []byte, bool) { if err1 { return nil, nil, true } - loopO := make([]*MembHide, 0, length) + var loopO = make([]*MembHide, 0, length) var loopErr bool var loopB = b1 for i := uint64(0); i < length; i++ { diff --git a/kt/test.go b/kt/test.go index 8044928..3893a8d 100644 --- a/kt/test.go +++ b/kt/test.go @@ -128,9 +128,7 @@ func GetTimeSeries(o []*TimeSeriesEntry, epoch uint64) (bool, []byte) { if e.Epoch <= epoch { isReg = true val = e.TSVal - continue } - break } return isReg, val }