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

Function dev_save_plugin_io

lightningd/plugin.c:2633–2663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2631}
2632
2633static void dev_save_plugin_io(struct plugins *plugins,
2634 const char *type,
2635 const char *name,
2636 const char *buf, size_t len)
2637{
2638 static size_t counter;
2639 static u64 starttime;
2640 const char *file;
2641 int fd;
2642
2643 if (!plugins->dev_save_io)
2644 return;
2645
2646 /* If we reexec, we still want unique names */
2647 if (!starttime) {
2648 struct timemono start = time_mono();
2649 starttime = start.ts.tv_sec * 1000000 + start.ts.tv_nsec / 1000;
2650 }
2651
2652 file = path_join(tmpctx, plugins->dev_save_io,
2653 take(tal_fmt(NULL, "%s-%s-%u-%"PRIu64"-%zu",
2654 type, name,
2655 (unsigned int)getpid(),
2656 starttime,
2657 counter++)));
2658 fd = open(file, O_CREAT|O_EXCL|O_WRONLY, 0600);
2659 if (fd < 0 || !write_all(fd, buf, len))
2660 fatal("Writing --dev-save-plugin-io %s: %s",
2661 file, strerror(errno));
2662 close(fd);
2663}
2664
2665void dev_save_plugin_io_in(struct plugins *plugins,
2666 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