Skip to content

Commit

Permalink
make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjit-bhat committed Jun 21, 2024
1 parent dc0badf commit 18bf226
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 88 deletions.
5 changes: 4 additions & 1 deletion ktmerkle/ktmerkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
type epochTy = uint64
type linkTy = []byte
type errorTy = bool
type okTy = bool

const (
errNone errorTy = false
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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]
Expand Down
7 changes: 7 additions & 0 deletions ktmerkle/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -87,6 +92,7 @@ type servGetIdAtReply struct {
error errorTy
}

/*
type servGetIdNowArg struct {
// rpc: invariant: len 32.
id merkle.Id
Expand All @@ -105,6 +111,7 @@ type servGetIdNowReply struct {
proof merkle.Proof
error errorTy
}
*/

type servGetLinkArg struct {
epoch epochTy
Expand Down
70 changes: 0 additions & 70 deletions ktmerkle/rpc.out.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 21 additions & 17 deletions ktmerkle/rpc_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 18bf226

Please sign in to comment.