Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about P Foreign Interface #732

Open
nichanggong opened this issue May 22, 2024 · 0 comments
Open

Question about P Foreign Interface #732

nichanggong opened this issue May 22, 2024 · 0 comments

Comments

@nichanggong
Copy link

……\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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant