Refactored stage sync logic. (#86)

* Cleaned up stage time sync logic and avoided extra missed rounds.
* Moved stage sync time logic to beginning of consensus stage.
* Removed check_majority_stage.
* Re-organised lcl sync flow.
This commit is contained in:
Ravin Perera
2020-02-10 14:27:37 +01:00
committed by GitHub
parent 8cf869cf9e
commit 4fefb7ca71
14 changed files with 216 additions and 246 deletions

1
examples/random_contract/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
rnd_contract

View File

@@ -15,7 +15,6 @@
int main(int argc, char **argv)
{
if (argc != 3)
return fprintf(stderr, "usage %s <file path to randomly edit> <max no. of block modifications>\n", argv[0]);
@@ -23,12 +22,14 @@ int main(int argc, char **argv)
char buf[128];
read(STDIN_FILENO, buf, 128);
// Read timestamp mentioned in contract args json.
char tsbuf[14];
memcpy(tsbuf, &buf[100], 13);
tsbuf[13] = '\0';
int ts = atoi(tsbuf);
//printf("args input: %.13s\n", tsbuf);
// Use contract args timestamp to initialize random seed.
srand(ts);
FILE *f = fopen(argv[1], "rb+");
@@ -71,7 +72,7 @@ int main(int argc, char **argv)
int end_block = (offset + bytestowrite) / (4 * 1024 * 1024);
for (int i = start_block; i <= end_block; ++i)
{
//printf("@@@ pid %d wrote to block %d ... %d bytes\n", pid, i, n);
// printf("@@@ pid %d wrote to block %d ... %d bytes\n", pid, i, n);
fflush(stdout);
}
}
@@ -79,4 +80,5 @@ int main(int argc, char **argv)
// done!
fclose(f);
return 0;
}