Skip to content

Instantly share code, notes, and snippets.

@yidongw
Created December 20, 2018 23:03
Show Gist options
  • Save yidongw/3ad945fc1c04d9d03f91c52b5918eec0 to your computer and use it in GitHub Desktop.
Save yidongw/3ad945fc1c04d9d03f91c52b5918eec0 to your computer and use it in GitHub Desktop.
Perun9
function VCCloseFinal(uint vid, uint cash1A, uint cash2A, uint versionA, bytes sigA, bytes sigAB,
uint cash1B, uint cash2B, uint versionB, bytes sigB, bytes sigBA) AliceOrBob public {
VirtualContract memory vc = virtual[vid];
require(msg.sender == vc.Ingrid && (vc.status == VCStatus.WaitingToClose || vc.status == VCStatus.Closing));
require(CheckVersion(vc.p1, vc.p2, vid, vc, versionA, sigA, sigAB));
require(CheckVersion(vc.p2, vc.p1, vid, vc, versionB, sigB, sigBA));
if (versionA >= versionB) {
vc.cashFinal1 = cash1A;
vc.cashFinal2 = cash2A;
}
else {
vc.cashFinal1 = cash1B;
vc.cashFinal2 = cash2B;
}
vc.status = VCStatus.ClosingFinal;
vc.timeout = now + closingTime;
virtual[vid] = vc;
EventVCCloseFinal(vid, cash1A, cash2A, versionA, sigA, sigAB, cash1B, cash2B, versionB, sigB, sigBA);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment