cp before pse
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"math/big"
|
||||
|
||||
"6.5840/labrpc"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Clerk struct {
|
||||
@@ -38,13 +39,18 @@ func MakeClerk(server *labrpc.ClientEnd) *Clerk {
|
||||
// must match the declared types of the RPC handler function's
|
||||
// arguments. and reply must be passed as a pointer.
|
||||
func (ck *Clerk) Get(key string) string {
|
||||
id := uuid.New()
|
||||
args := GetArgs{
|
||||
Key: key,
|
||||
Key: key,
|
||||
Uuid: id,
|
||||
}
|
||||
reply := GetReply{}
|
||||
ok := false
|
||||
for !ok {
|
||||
ok = ck.server.Call("KVServer.Get", &args, &reply)
|
||||
if !ok {
|
||||
log.Println("RPC call failed: GET op")
|
||||
}
|
||||
}
|
||||
// You will have to modify this function.
|
||||
return reply.Value
|
||||
@@ -60,15 +66,19 @@ func (ck *Clerk) Get(key string) string {
|
||||
// arguments. and reply must be passed as a pointer.
|
||||
func (ck *Clerk) PutAppend(key string, value string, op string) string {
|
||||
// You will have to modify this function.
|
||||
id := uuid.New()
|
||||
args := PutAppendArgs{
|
||||
Key: key,
|
||||
Value: value,
|
||||
Uuid: id,
|
||||
}
|
||||
reply := PutAppendReply{}
|
||||
ok := ck.server.Call("KVServer."+op, &args, &reply)
|
||||
|
||||
if !ok {
|
||||
log.Fatalf("RPC call failed: %s op", op)
|
||||
ok := false
|
||||
for !ok {
|
||||
ok := ck.server.Call("KVServer."+op, &args, &reply)
|
||||
if !ok {
|
||||
log.Printf("RPC call failed: %s op\n", op)
|
||||
}
|
||||
}
|
||||
|
||||
return reply.Value
|
||||
|
||||
@@ -7,6 +7,7 @@ type PutAppendArgs struct {
|
||||
// You'll have to add definitions here.
|
||||
// Field names must start with capital letters,
|
||||
// otherwise RPC will break.
|
||||
Uuid string
|
||||
}
|
||||
|
||||
type PutAppendReply struct {
|
||||
@@ -16,6 +17,7 @@ type PutAppendReply struct {
|
||||
type GetArgs struct {
|
||||
Key string
|
||||
// You'll have to add definitions here.
|
||||
Uuid string
|
||||
}
|
||||
|
||||
type GetReply struct {
|
||||
|
||||
@@ -17,6 +17,7 @@ func DPrintf(format string, a ...interface{}) (n int, err error) {
|
||||
type KVServer struct {
|
||||
mu sync.Mutex
|
||||
KVStore map[string]string
|
||||
OpLog map[string]bool
|
||||
// Your definitions here.
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user