You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
state SendWriteTransaction {
entry {
currTransaction = ChooseRandomTransaction(id * 100 + N /* hack for creating unique transaction id*/);
send coordinator, eWriteTransReq, (client = this, trans = currTransaction);
}
on eWriteTransResp goto ConfirmTransaction;
}
state ConfirmTransaction {
entry (writeResp: tWriteTransResp) {
// assert that if write transaction was successful then value read is the value written.
if(writeResp.status == SUCCESS)
{
send coordinator, eReadTransReq, (client= this, key = currTransaction.key);
// await response from the participant
receive {
case eReadTransResp: (readResp: tReadTransResp) {
assert readResp.key == currTransaction.key && readResp.val == currTransaction.val,
format ("Record read is not same as what was written by the client:: read - {0}, written - {1}",
readResp.val, currTransaction.val);
}
}
}
In the above code, Function ChooseRandomTransaction is P foreign code and the implementation of the ChooseRandomTransaction is available in ForeignCode.cs。
I really appreciate your answer about why can we use currTransaction.val and currTransaction.key?
In ForeignCode.cs ChooseRandomTransaction return type is PrtNamedTuple but we'd better to use this type with .fieldNames and .fieldValues, this is the part that really confused me. Thank you so much for helping!
The text was updated successfully, but these errors were encountered:
……\P-master\Tutorial\2_TwoPhaseCommit\PTst\Client.P
state SendWriteTransaction {
entry {
currTransaction = ChooseRandomTransaction(id * 100 + N /* hack for creating unique transaction id*/);
send coordinator, eWriteTransReq, (client = this, trans = currTransaction);
}
on eWriteTransResp goto ConfirmTransaction;
}
state ConfirmTransaction {
entry (writeResp: tWriteTransResp) {
// assert that if write transaction was successful then value read is the value written.
if(writeResp.status == SUCCESS)
{
send coordinator, eReadTransReq, (client= this, key = currTransaction.key);
// await response from the participant
receive {
case eReadTransResp: (readResp: tReadTransResp) {
assert readResp.key == currTransaction.key && readResp.val == currTransaction.val,
format ("Record read is not same as what was written by the client:: read - {0}, written - {1}",
readResp.val, currTransaction.val);
}
}
}
In the above code, Function ChooseRandomTransaction is P foreign code and the implementation of the ChooseRandomTransaction is available in ForeignCode.cs。
I really appreciate your answer about why can we use currTransaction.val and currTransaction.key?
In ForeignCode.cs ChooseRandomTransaction return type is PrtNamedTuple but we'd better to use this type with .fieldNames and .fieldValues, this is the part that really confused me. Thank you so much for helping!
The text was updated successfully, but these errors were encountered: