static int txdb_add_to_hashtable(struct txdb *txdb, const void *buf, size_t len, const uint256 *txHash, const uint256 *blkHash, uint64 timestamp, struct tx_entry **txePtr) { struct tx_entry *txe; struct buff b; int res; bool s; buff_init(&b, (char *)buf, len); txe = safe_malloc(sizeof *txe); if (blkHash) { memcpy(&txe->blkHash, blkHash, sizeof *blkHash); } else { memset(&txe->blkHash, 0, sizeof txe->blkHash); } txe->relevant = 0; /* for now */ txe->timestamp = timestamp; // only really useful for 'relevant' ones. res = deserialize_tx(&b, &txe->tx); ASSERT(res == 0); s = hashtable_insert(txdb->hash_tx, txHash, sizeof *txHash, txe); ASSERT(s); *txePtr = txe; return 0; }
int deserialize_block(struct buff *buf, btc_msg_block *blk) { uint64 i; int res; res = deserialize_blockheader(buf, &blk->header); btcmsg_print_header(&blk->header); res |= deserialize_varint(buf, &blk->txCount); Warning("numTx=%llu\n", blk->txCount); blk->tx = safe_malloc(blk->txCount * sizeof *blk->tx); for (i = 0; i < blk->txCount; i++) { res |= deserialize_tx(buf, blk->tx + i); } Warning("sz: %zu vs %zu\n", buff_curlen(buf), buff_maxlen(buf)); ASSERT(buff_space_left(buf) == 0); return res; }
chain::transaction transaction_result::transaction() const { BITCOIN_ASSERT(slab_ != nullptr); // return deserialize_tx(slab_ + 8, size_limit_ - 8); return deserialize_tx(slab_ + 8); }