update lab4

This commit is contained in:
kenctrl
2024-03-05 10:48:41 -05:00
3 changed files with 7 additions and 4 deletions

View File

@@ -43,7 +43,7 @@ func (ck *Clerk) Get(key string) string {
// shared by Put and Append. // shared by Put and Append.
// //
// you can send an RPC with code like this: // you can send an RPC with code like this:
// ok := ck.servers[i].Call("KVServer.PutAppend", &args, &reply) // ok := ck.servers[i].Call("KVServer."+op, &args, &reply)
// //
// the types of args and reply (including whether they are pointers) // the types of args and reply (including whether they are pointers)
// must match the declared types of the RPC handler function's // must match the declared types of the RPC handler function's

View File

@@ -12,7 +12,6 @@ type Err string
type PutAppendArgs struct { type PutAppendArgs struct {
Key string Key string
Value string Value string
Op string // "Put" or "Append"
// You'll have to add definitions here. // You'll have to add definitions here.
// Field names must start with capital letters, // Field names must start with capital letters,
// otherwise RPC will break. // otherwise RPC will break.

View File

@@ -43,7 +43,11 @@ func (kv *KVServer) Get(args *GetArgs, reply *GetReply) {
// unlike in lab 2, neither Put nor Append should return a value. // unlike in lab 2, neither Put nor Append should return a value.
// this is already reflected in the PutAppendReply struct. // this is already reflected in the PutAppendReply struct.
func (kv *KVServer) PutAppend(args *PutAppendArgs, reply *PutAppendReply) { func (kv *KVServer) Put(args *PutAppendArgs, reply *PutAppendReply) {
// Your code here.
}
func (kv *KVServer) Append(args *PutAppendArgs, reply *PutAppendReply) {
// Your code here. // Your code here.
} }
@@ -82,7 +86,7 @@ func StartKVServer(servers []*labrpc.ClientEnd, me int, persister *raft.Persiste
// call labgob.Register on structures you want // call labgob.Register on structures you want
// Go's RPC library to marshall/unmarshall. // Go's RPC library to marshall/unmarshall.
labgob.Register(Op{}) labgob.Register(Op{})
kv := new(KVServer) kv := new(KVServer)
kv.me = me kv.me = me
kv.maxraftstate = maxraftstate kv.maxraftstate = maxraftstate