Merge pull request #6168 from urbit/jb/replay-tools

vere: minor fixes for replay tools
This commit is contained in:
Joe Bryan 2022-12-16 00:42:02 -05:00 committed by GitHub
commit fb9037ac60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 67 additions and 42 deletions

View File

@ -1474,10 +1474,12 @@ _cw_queu(c3_i argc, c3_c* argv[])
{ {
c3_i ch_i, lid_i; c3_i ch_i, lid_i;
c3_w arg_w; c3_w arg_w;
c3_c* roc_c = 0;
static struct option lop_u[] = { static struct option lop_u[] = {
{ "loom", required_argument, NULL, c3__loom }, { "loom", required_argument, NULL, c3__loom },
{ "no-demand", no_argument, NULL, 6 }, { "no-demand", no_argument, NULL, 6 },
{ "replay-from", required_argument, NULL, 'r' },
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
@ -1500,6 +1502,10 @@ _cw_queu(c3_i argc, c3_c* argv[])
u3_Host.ops_u.lom_y = lom_w; u3_Host.ops_u.lom_y = lom_w;
} break; } break;
case 'r': {
roc_c = strdup(optarg);
} break;
case '?': { case '?': {
fprintf(stderr, "invalid argument\r\n"); fprintf(stderr, "invalid argument\r\n");
exit(1); exit(1);
@ -1507,9 +1513,13 @@ _cw_queu(c3_i argc, c3_c* argv[])
} }
} }
if ( !roc_c ) {
fprintf(stderr, "invalid command, -r $EVENT required\r\n");
exit(1);
}
// argv[optind] is always "queu" // argv[optind] is always "queu"
// //
if ( !u3_Host.dir_c ) { if ( !u3_Host.dir_c ) {
if ( optind + 1 < argc ) { if ( optind + 1 < argc ) {
u3_Host.dir_c = argv[optind + 1]; u3_Host.dir_c = argv[optind + 1];
@ -1527,11 +1537,10 @@ _cw_queu(c3_i argc, c3_c* argv[])
exit(1); exit(1);
} }
c3_c* eve_c;
c3_d eve_d; c3_d eve_d;
if ( 1 != sscanf(eve_c, "%" PRIu64 "", &eve_d) ) { if ( 1 != sscanf(roc_c, "%" PRIu64 "", &eve_d) ) {
fprintf(stderr, "urbit: queu: invalid number '%s'\r\n", eve_c); fprintf(stderr, "urbit: queu: invalid number '%s'\r\n", roc_c);
exit(1); exit(1);
} }
else { else {
@ -1885,16 +1894,21 @@ _cw_play(c3_i argc, c3_c* argv[])
} }
u3C.wag_w |= u3o_hashless; u3C.wag_w |= u3o_hashless;
u3m_boot(u3_Host.dir_c, (size_t)1 << u3_Host.ops_u.lom_y);
u3C.slog_f = _cw_play_slog;
if ( c3y == ful_o ) { if ( c3y == ful_o ) {
u3l_log("mars: preparing for full replay\r\n"); u3l_log("mars: preparing for full replay\r\n");
u3m_init((size_t)1 << u3_Host.ops_u.lom_y);
u3e_live(u3m_pier(u3_Host.dir_c));
u3e_yolo(); u3e_yolo();
u3m_pave(c3y); u3m_pave(c3y);
u3j_boot(c3y); u3j_boot(c3y);
u3A->eve_d = 0; u3A->eve_d = 0;
} }
else {
u3m_boot(u3_Host.dir_c, (size_t)1 << u3_Host.ops_u.lom_y);
}
u3C.slog_f = _cw_play_slog;
{ {
u3_mars mar_u = { u3_mars mar_u = {

View File

@ -8,6 +8,11 @@
c3_d c3_d
u3m_boot(c3_c* dir_c, size_t len_i); u3m_boot(c3_c* dir_c, size_t len_i);
/* u3m_pier(): make a pier.
*/
c3_c*
u3m_pier(c3_c* dir_c);
/* u3m_boot_lite(): start without checkpointing. /* u3m_boot_lite(): start without checkpointing.
*/ */
c3_d c3_d

View File

@ -1961,24 +1961,15 @@ u3m_stop()
c3_free(u3D.ray_u); c3_free(u3D.ray_u);
} }
/* u3m_boot(): start the u3 system. return next event, starting from 1. /* u3m_pier(): make a pier.
*/
c3_d
u3m_boot(c3_c* dir_c, size_t len_i)
{
c3_o nuu_o;
u3C.dir_c = dir_c;
/* Activate the loom.
*/
u3m_init(len_i);
/* Activate the storage system.
*/ */
c3_c*
u3m_pier(c3_c* dir_c)
{ {
c3_c ful_c[8193]; c3_c ful_c[8193];
u3C.dir_c = dir_c;
snprintf(ful_c, 8192, "%s", dir_c); snprintf(ful_c, 8192, "%s", dir_c);
if ( c3_mkdir(ful_c, 0700) ) { if ( c3_mkdir(ful_c, 0700) ) {
if ( EEXIST != errno ) { if ( EEXIST != errno ) {
@ -2003,9 +1994,24 @@ u3m_boot(c3_c* dir_c, size_t len_i)
} }
} }
nuu_o = u3e_live(strdup(ful_c)); return strdup(ful_c);
} }
/* u3m_boot(): start the u3 system. return next event, starting from 1.
*/
c3_d
u3m_boot(c3_c* dir_c, size_t len_i)
{
c3_o nuu_o;
/* Activate the loom.
*/
u3m_init(len_i);
/* Activate the storage system.
*/
nuu_o = u3e_live(u3m_pier(dir_c));
/* Activate tracing. /* Activate tracing.
*/ */
u3C.slog_f = 0; u3C.slog_f = 0;