MCPcopy Create free account
hub / github.com/ElementsProject/lightning / dev_save_plugin_io

Function dev_save_plugin_io

lightningd/plugin.c:2621–2651  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2619}
2620
2621static void dev_save_plugin_io(struct plugins *plugins,
2622 const char *type,
2623 const char *name,
2624 const char *buf, size_t len)
2625{
2626 static size_t counter;
2627 static u64 starttime;
2628 const char *file;
2629 int fd;
2630
2631 if (!plugins->dev_save_io)
2632 return;
2633
2634 /* If we reexec, we still want unique names */
2635 if (!starttime) {
2636 struct timemono start = time_mono();
2637 starttime = start.ts.tv_sec * 1000000 + start.ts.tv_nsec / 1000;
2638 }
2639
2640 file = path_join(tmpctx, plugins->dev_save_io,
2641 take(tal_fmt(NULL, "%s-%s-%u-%"PRIu64"-%zu",
2642 type, name,
2643 (unsigned int)getpid(),
2644 starttime,
2645 counter++)));
2646 fd = open(file, O_CREAT|O_EXCL|O_WRONLY, 0600);
2647 if (fd < 0 || !write_all(fd, buf, len))
2648 fatal("Writing --dev-save-plugin-io %s: %s",
2649 file, strerror(errno));
2650 close(fd);
2651}
2652
2653void dev_save_plugin_io_in(struct plugins *plugins,
2654 const char *type,

Callers 2

dev_save_plugin_io_inFunction · 0.85
dev_save_plugin_io_outFunction · 0.85

Calls 4

time_monoFunction · 0.85
path_joinFunction · 0.85
fatalFunction · 0.70
write_allFunction · 0.50

Tested by

no test coverage detected