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

Function init

plugins/bkpr/bookkeeper.c:1829–1853  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1827};
1828
1829static const char *init(struct plugin *p, const char *b, const jsmntok_t *t)
1830{
1831 /* Switch to bookkeeper-dir, if specified */
1832 if (datadir && chdir(datadir) != 0) {
1833 if (mkdir(datadir, 0700) != 0 && errno != EEXIST)
1834 plugin_err(p,
1835 "Unable to create 'bookkeeper-dir'=%s",
1836 datadir);
1837 if (chdir(datadir) != 0)
1838 plugin_err(p,
1839 "Unable to switch to 'bookkeeper-dir'=%s",
1840 datadir);
1841 }
1842
1843 /* No user suppled db_dsn, set one up here */
1844 if (!db_dsn)
1845 db_dsn = tal_fmt(NULL, "sqlite3://accounts.sqlite3");
1846
1847 plugin_log(p, LOG_DBG, "Setting up database at %s", db_dsn);
1848 /* Final flag tells us What's New, Pussycat. */
1849 db = notleak(db_setup(p, p, db_dsn, &tom_jones));
1850 db_dsn = tal_free(db_dsn);
1851
1852 return NULL;
1853}
1854
1855int main(int argc, char *argv[])
1856{

Callers

nothing calls this directly

Calls 4

tal_freeFunction · 0.85
db_setupFunction · 0.70
plugin_errFunction · 0.50
plugin_logFunction · 0.50

Tested by

no test coverage detected