struct protocol_pkt_welcome *make_welcome(const tal_t *ctx, const struct state *state, const struct protocol_net_address *a) { struct protocol_pkt_welcome *w; w = tal_packet(ctx, struct protocol_pkt_welcome, PROTOCOL_PKT_WELCOME); w->version = cpu_to_le32(current_version()); memset(w->moniker, 0, sizeof(w->moniker)); strncpy(w->moniker, "ICBINB! " VERSION, sizeof(w->moniker)); w->uuid = state->uuid; w->you = *a; w->listen_port = cpu_to_le16(state->listen_port); memcpy(w->interests, state->interests, sizeof(w->interests)); /* This is the best block we can tell them about. */ if (state->longest_knowns[0] != genesis_block(state)) tal_packet_append_block(&w, &state->longest_knowns[0]->bi); return w; }
bool bdb_blockchain::setup(const std::string& prefix) { async_service fake_service; bdb_blockchain handle(fake_service); if (!handle.initialize(prefix)) return false; handle.db_blocks_->truncate(nullptr, 0, 0); handle.db_txs_->truncate(nullptr, 0, 0); handle.db_spends_->truncate(nullptr, 0, 0); handle.db_address_->truncate(nullptr, 0, 0); // Save genesis block txn_guard_ptr txn = std::make_shared<txn_guard>(handle.env_); if (!handle.common_->save_block(txn, 0, genesis_block())) { txn->abort(); return false; } txn->commit(); handle.shutdown(); return true; }