From 18bf2264a382ffc88f9d133205808fabb62f48a0 Mon Sep 17 00:00:00 2001 From: Sanjit Bhat Date: Thu, 20 Jun 2024 19:54:09 -0400 Subject: [PATCH] make linter happy --- ktmerkle/ktmerkle.go | 5 +++- ktmerkle/rpc.go | 7 +++++ ktmerkle/rpc.out.go | 70 -------------------------------------------- ktmerkle/rpc_misc.go | 38 +++++++++++++----------- 4 files changed, 32 insertions(+), 88 deletions(-) diff --git a/ktmerkle/ktmerkle.go b/ktmerkle/ktmerkle.go index 01ec6d1..0d429d6 100644 --- a/ktmerkle/ktmerkle.go +++ b/ktmerkle/ktmerkle.go @@ -12,7 +12,6 @@ import ( type epochTy = uint64 type linkTy = []byte type errorTy = bool -type okTy = bool const ( errNone errorTy = false @@ -186,6 +185,7 @@ func (s *serv) getIdAt(id merkle.Id, epoch epochTy) *servGetIdAtReply { return &servGetIdAtReply{prevLink: prevLink, dig: reply.Digest, sig: sig, val: reply.Val, proofTy: reply.ProofTy, proof: reply.Proof, error: reply.Error} } +/* func (s *serv) getIdNow(id merkle.Id) *servGetIdNowReply { s.mu.Lock() epoch := uint64(len(s.trees)) - 1 @@ -195,6 +195,7 @@ func (s *serv) getIdNow(id merkle.Id) *servGetIdNowReply { s.mu.Unlock() return &servGetIdNowReply{epoch: epoch, prevLink: prevLink, dig: reply.Digest, sig: sig, val: reply.Val, proofTy: reply.ProofTy, proof: reply.Proof, error: reply.Error} } +*/ func (s *serv) getLink(epoch epochTy) *servGetLinkReply { s.mu.Lock() @@ -427,6 +428,7 @@ func (c *client) getAt(id merkle.Id, epoch epochTy) (merkle.Val, *evidServLink, return reply.val, nil, errNone } +/* // getNow fetches the latest key for a particular id. func (c *client) getNow(id merkle.Id) (epochTy, merkle.Val, *evidServLink, errorTy) { reply := callServGetIdNow(c.serv, id) @@ -445,6 +447,7 @@ func (c *client) getNow(id merkle.Id) (epochTy, merkle.Val, *evidServLink, error } return reply.epoch, reply.val, nil, errNone } +*/ func (c *client) fetchLink(epoch epochTy) (*evidServLink, errorTy) { _, ok0 := c.links[epoch] diff --git a/ktmerkle/rpc.go b/ktmerkle/rpc.go index f77f7b4..00a75ac 100644 --- a/ktmerkle/rpc.go +++ b/ktmerkle/rpc.go @@ -9,12 +9,14 @@ import ( // rpc: no decode needed. type chainSepNone struct { + //lint:ignore U1000 a const is still inserted into the rpc msg. // rpc: invariant: const 0. tag byte } // rpc: no decode needed. type chainSepSome struct { + //lint:ignore U1000 a const is still inserted into the rpc msg. // rpc: invariant: const 1. tag byte epoch epochTy @@ -25,6 +27,7 @@ type chainSepSome struct { // rpc: no decode needed. type adtrSepLink struct { + //lint:ignore U1000 a const is still inserted into the rpc msg. // rpc: invariant: const 0. tag byte // rpc: invariant: len 32. @@ -33,6 +36,7 @@ type adtrSepLink struct { // rpc: no decode needed. type servSepLink struct { + //lint:ignore U1000 a const is still inserted into the rpc msg. // rpc: invariant: const 0. tag byte // rpc: invariant: len 32. @@ -41,6 +45,7 @@ type servSepLink struct { // rpc: no decode needed. type servSepPut struct { + //lint:ignore U1000 a const is still inserted into the rpc msg. // rpc: invariant: const 1. tag byte epoch epochTy @@ -87,6 +92,7 @@ type servGetIdAtReply struct { error errorTy } +/* type servGetIdNowArg struct { // rpc: invariant: len 32. id merkle.Id @@ -105,6 +111,7 @@ type servGetIdNowReply struct { proof merkle.Proof error errorTy } +*/ type servGetLinkArg struct { epoch epochTy diff --git a/ktmerkle/rpc.out.go b/ktmerkle/rpc.out.go index 0baeb97..615f2ed 100644 --- a/ktmerkle/rpc.out.go +++ b/ktmerkle/rpc.out.go @@ -174,76 +174,6 @@ func (o *servGetIdAtReply) decode(b0 []byte) ([]byte, errorTy) { o.error = error return b, errNone } -func (o *servGetIdNowArg) encode() []byte { - var b = make([]byte, 0) - b = marshal.WriteBytes(b, o.id) - return b -} -func (o *servGetIdNowArg) decode(b0 []byte) ([]byte, errorTy) { - var b = b0 - id, b, err := marshalutil.ReadBytes(b, 32) - if err { - return nil, err - } - o.id = id - return b, errNone -} -func (o *servGetIdNowReply) encode() []byte { - var b = make([]byte, 0) - b = marshal.WriteInt(b, o.epoch) - b = marshal.WriteBytes(b, o.prevLink) - b = marshal.WriteBytes(b, o.dig) - b = marshal.WriteBytes(b, o.sig) - b = marshalutil.WriteSlice1D(b, o.val) - b = marshal.WriteBool(b, o.proofTy) - b = marshalutil.WriteSlice3D(b, o.proof) - b = marshal.WriteBool(b, o.error) - return b -} -func (o *servGetIdNowReply) decode(b0 []byte) ([]byte, errorTy) { - var b = b0 - epoch, b, err := marshalutil.ReadInt(b) - if err { - return nil, err - } - prevLink, b, err := marshalutil.ReadBytes(b, 32) - if err { - return nil, err - } - dig, b, err := marshalutil.ReadBytes(b, 32) - if err { - return nil, err - } - sig, b, err := marshalutil.ReadBytes(b, 64) - if err { - return nil, err - } - val, b, err := marshalutil.ReadSlice1D(b) - if err { - return nil, err - } - proofTy, b, err := marshalutil.ReadBool(b) - if err { - return nil, err - } - proof, b, err := marshalutil.ReadSlice3D(b) - if err { - return nil, err - } - error, b, err := marshalutil.ReadBool(b) - if err { - return nil, err - } - o.epoch = epoch - o.prevLink = prevLink - o.dig = dig - o.sig = sig - o.val = val - o.proofTy = proofTy - o.proof = proof - o.error = error - return b, errNone -} func (o *servGetLinkArg) encode() []byte { var b = make([]byte, 0) b = marshal.WriteInt(b, o.epoch) diff --git a/ktmerkle/rpc_misc.go b/ktmerkle/rpc_misc.go index 68ed5d5..0edd8f7 100644 --- a/ktmerkle/rpc_misc.go +++ b/ktmerkle/rpc_misc.go @@ -15,11 +15,11 @@ const ( rpcServUpdateEpoch uint64 = 1 rpcServPut uint64 = 2 rpcServGetIdAt uint64 = 3 - rpcServGetIdNow uint64 = 4 - rpcServGetDig uint64 = 5 - rpcServGetLink uint64 = 6 - rpcAdtrPut uint64 = 7 - rpcAdtrGet uint64 = 8 + // rpcServGetIdNow uint64 = 4 + rpcServGetDig uint64 = 5 + rpcServGetLink uint64 = 6 + rpcAdtrPut uint64 = 7 + rpcAdtrGet uint64 = 8 ) func callServUpdateEpoch(cli *urpc.Client) { @@ -59,6 +59,7 @@ func callServGetIdAt(cli *urpc.Client, id merkle.Id, epoch epochTy) *servGetIdAt return reply } +/* func callServGetIdNow(cli *urpc.Client, id merkle.Id) *servGetIdNowReply { argB := (&servGetIdNowArg{id: id}).encode() replyB := make([]byte, 0) @@ -73,6 +74,7 @@ func callServGetIdNow(cli *urpc.Client, id merkle.Id) *servGetIdNowReply { } return reply } +*/ func callServGetLink(cli *urpc.Client, epoch epochTy) *servGetLinkReply { argB := (&servGetLinkArg{epoch: epoch}).encode() @@ -123,18 +125,20 @@ func (s *serv) start(addr grove_ffi.Address) { *enc_reply = s.getIdAt(args.id, args.epoch).encode() } - handlers[rpcServGetIdNow] = - func(enc_args []byte, enc_reply *[]byte) { - args := &servGetIdNowArg{} - _, err0 := args.decode(enc_args) - if err0 { - reply := &servGetIdNowReply{} - reply.error = errSome - *enc_reply = reply.encode() - return - } - *enc_reply = s.getIdNow(args.id).encode() - } + /* + handlers[rpcServGetIdNow] = + func(enc_args []byte, enc_reply *[]byte) { + args := &servGetIdNowArg{} + _, err0 := args.decode(enc_args) + if err0 { + reply := &servGetIdNowReply{} + reply.error = errSome + *enc_reply = reply.encode() + return + } + *enc_reply = s.getIdNow(args.id).encode() + } + */ handlers[rpcServGetLink] = func(enc_args []byte, enc_reply *[]byte) {