Skip to content

Commit 495a313

Browse files
committed
Squashed 'depend/bitcoin/' changes from fdc9f98cae..7bcb122e6e
7bcb122e6e kernel: Fix bitcoin-chainstate for windows 11ee368897 kernel: Add Purpose section to header documentation 97b95e882d kernel: Allowing reducing exports 8d9a0d084e kernel: Add pure kernel bitcoin-chainstate cfd60cce20 kernel: Add functions to get the block hash from a block 53d1f4d41e kernel: Add block index utility functions to C header 9107931eac kernel: Add function to read block undo data from disk to C header f9a0874d05 kernel: Add functions to read block from disk to C header 57a40f9cb0 kernel: Add function for copying block data to C header caef1a99b8 kernel: Add functions for the block validation state to C header 4222f094ad kernel: Add validation interface to C header f7d1d13cdd kernel: Add interrupt function to C header 0a9569d877 kernel: Add import blocks function to C header 3c626eff1f kernel: Add chainstate load options for in-memory dbs in C header 26feeed52a kernel: Add options for reindexing in C header 52de33e178 kernel: Add block validation to C header f2e65149d5 kernel: Add chainstate loading when instantiating a ChainstateManager 956a76341d kernel: Add chainstate manager option for setting worker threads bd00646958 kernel: Add chainstate manager object to C header 7fb35504c3 kernel: Add notifications context option to C header 521b5d918c kernel: Add chain params context option to C header c752672060 kernel: Add kernel library context object ff4979b22d kernel: Add logging to kernel library C header b41eaedf91 kernel: Introduce initial kernel C header API REVERT: fdc9f98cae kernel: Fix bitcoin-chainstate for windows REVERT: 23d43c4e79 kernel: Add Purpose section to header documentation REVERT: 7924a86ccf kernel: Allowing reducing exports REVERT: 98234b1443 kernel: Add pure kernel bitcoin-chainstate REVERT: bcacaf9f7d kernel: Add functions to get the block hash from a block REVERT: 69d457909f kernel: Add block index utility functions to C header REVERT: 15ab14d841 kernel: Add function to read block undo data from disk to C header REVERT: f156e36930 kernel: Add functions to read block from disk to C header REVERT: ec46b7d770 kernel: Add function for copying block data to C header REVERT: 91d9e14286 kernel: Add functions for the block validation state to C header REVERT: 41b77072d3 kernel: Add validation interface to C header REVERT: 96bdab979e kernel: Add interrupt function to C header REVERT: 2989cb0fa4 kernel: Add import blocks function to C header REVERT: 1063846417 kernel: Add chainstate load options for in-memory dbs in C header REVERT: 809e0c2441 kernel: Add options for reindexing in C header REVERT: a1b6632702 kernel: Add block validation to C header REVERT: 35d1e2dfbf kernel: Add chainstate loading when instantiating a ChainstateManager REVERT: 824a5d549e kernel: Add chainstate manager option for setting worker threads REVERT: c3bb19aaf4 kernel: Add chainstate manager object to C header REVERT: 0d2cbf47d6 kernel: Add notifications context option to C header REVERT: df43fd0151 kernel: Add chain params context option to C header REVERT: 02e0874a91 kernel: Add kernel library context object REVERT: de9bc8e47b kernel: Add logging to kernel library C header REVERT: a771ea573b kernel: Introduce initial kernel C header API git-subtree-dir: depend/bitcoin git-subtree-split: 7bcb122e6e55339f25238a44433cc5aadc4526f1
1 parent 6899765 commit 495a313

File tree

4 files changed

+212
-62
lines changed

4 files changed

+212
-62
lines changed

src/kernel/bitcoinkernel.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -413,18 +413,18 @@ btck_Transaction* btck_transaction_create(const void* raw_transaction, size_t ra
413413
}
414414
}
415415

416-
uint64_t btck_transaction_count_outputs(const btck_Transaction* transaction)
416+
size_t btck_transaction_count_outputs(const btck_Transaction* transaction)
417417
{
418418
return transaction->m_tx->vout.size();
419419
}
420420

421-
btck_TransactionOutput* btck_transaction_get_output_at(const btck_Transaction* transaction, uint64_t output_index)
421+
btck_TransactionOutput* btck_transaction_get_output_at(const btck_Transaction* transaction, size_t output_index)
422422
{
423423
assert(output_index < transaction->m_tx->vout.size());
424424
return new btck_TransactionOutput{&transaction->m_tx->vout[output_index], false};
425425
}
426426

427-
uint64_t btck_transaction_count_inputs(const btck_Transaction* transaction)
427+
size_t btck_transaction_count_inputs(const btck_Transaction* transaction)
428428
{
429429
return transaction->m_tx->vin.size();
430430
}
@@ -935,12 +935,12 @@ btck_Block* btck_block_copy(const btck_Block* block)
935935
return new btck_Block{block->m_block};
936936
}
937937

938-
uint64_t btck_block_count_transactions(const btck_Block* block)
938+
size_t btck_block_count_transactions(const btck_Block* block)
939939
{
940940
return block->m_block->vtx.size();
941941
}
942942

943-
btck_Transaction* btck_block_get_transaction_at(const btck_Block* block, uint64_t index)
943+
btck_Transaction* btck_block_get_transaction_at(const btck_Block* block, size_t index)
944944
{
945945
assert(index < block->m_block->vtx.size());
946946
return new btck_Transaction{block->m_block->vtx[index]};
@@ -1043,12 +1043,12 @@ btck_BlockSpentOutputs* btck_block_spent_outputs_copy(const btck_BlockSpentOutpu
10431043
return new btck_BlockSpentOutputs{block_spent_outputs->m_block_undo};
10441044
}
10451045

1046-
uint64_t btck_block_spent_outputs_size(const btck_BlockSpentOutputs* block_spent_outputs)
1046+
size_t btck_block_spent_outputs_count(const btck_BlockSpentOutputs* block_spent_outputs)
10471047
{
10481048
return block_spent_outputs->m_block_undo->vtxundo.size();
10491049
}
10501050

1051-
btck_TransactionSpentOutputs* btck_block_spent_outputs_get_transaction_spent_outputs_at(const btck_BlockSpentOutputs* block_spent_outputs, uint64_t transaction_index)
1051+
btck_TransactionSpentOutputs* btck_block_spent_outputs_get_transaction_spent_outputs_at(const btck_BlockSpentOutputs* block_spent_outputs, size_t transaction_index)
10521052
{
10531053
assert(transaction_index < block_spent_outputs->m_block_undo->vtxundo.size());
10541054
const auto* tx_undo{&block_spent_outputs->m_block_undo->vtxundo.at(transaction_index)};
@@ -1067,7 +1067,7 @@ btck_TransactionSpentOutputs* btck_transaction_spent_outputs_copy(const btck_Tra
10671067
return new btck_TransactionSpentOutputs{new CTxUndo{*transaction_spent_outputs->m_tx_undo}, true};
10681068
}
10691069

1070-
uint64_t btck_transaction_spent_outputs_size(const btck_TransactionSpentOutputs* transaction_spent_outputs)
1070+
size_t btck_transaction_spent_outputs_count(const btck_TransactionSpentOutputs* transaction_spent_outputs)
10711071
{
10721072
return transaction_spent_outputs->m_tx_undo->vprevout.size();
10731073
}
@@ -1082,7 +1082,7 @@ void btck_transaction_spent_outputs_destroy(btck_TransactionSpentOutputs* transa
10821082
transaction_spent_outputs = nullptr;
10831083
}
10841084

1085-
btck_Coin* btck_transaction_spent_outputs_get_coin_at(const btck_TransactionSpentOutputs* transaction_spent_outputs, uint64_t coin_index)
1085+
btck_Coin* btck_transaction_spent_outputs_get_coin_at(const btck_TransactionSpentOutputs* transaction_spent_outputs, size_t coin_index)
10861086
{
10871087
assert(coin_index < transaction_spent_outputs->m_tx_undo->vprevout.size());
10881088
const Coin* coin{&transaction_spent_outputs->m_tx_undo->vprevout.at(coin_index)};
@@ -1151,10 +1151,7 @@ btck_BlockTreeEntry* btck_chain_get_genesis(const btck_Chain* chain)
11511151
btck_BlockTreeEntry* btck_chain_get_by_height(const btck_Chain* chain, int height)
11521152
{
11531153
LOCK(::cs_main);
1154-
if (height < 0 || height > chain->m_chain->Height()) {
1155-
LogDebug(BCLog::KERNEL, "Block height is out of range.");
1156-
return nullptr;
1157-
}
1154+
assert(height >= 0 && height <= chain->m_chain->Height());
11581155
return new btck_BlockTreeEntry{(*chain->m_chain)[height]};
11591156
}
11601157

src/kernel/bitcoinkernel.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ BITCOINKERNEL_API int btck_transaction_to_bytes(
478478
* @param[in] transaction Non-null.
479479
* @return The number of outputs.
480480
*/
481-
BITCOINKERNEL_API uint64_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_count_outputs(
481+
BITCOINKERNEL_API size_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_count_outputs(
482482
const btck_Transaction* transaction
483483
) BITCOINKERNEL_ARG_NONNULL(1);
484484

@@ -492,7 +492,7 @@ BITCOINKERNEL_API uint64_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_cou
492492
* @return The transaction output
493493
*/
494494
BITCOINKERNEL_API btck_TransactionOutput* BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_get_output_at(
495-
const btck_Transaction* transaction, uint64_t output_index
495+
const btck_Transaction* transaction, size_t output_index
496496
) BITCOINKERNEL_ARG_NONNULL(1);
497497

498498
/**
@@ -501,7 +501,7 @@ BITCOINKERNEL_API btck_TransactionOutput* BITCOINKERNEL_WARN_UNUSED_RESULT btck_
501501
* @param[in] transaction Non-null.
502502
* @return The number of inputs.
503503
*/
504-
BITCOINKERNEL_API uint64_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_count_inputs(
504+
BITCOINKERNEL_API size_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_count_inputs(
505505
const btck_Transaction* transaction
506506
) BITCOINKERNEL_ARG_NONNULL(1);
507507

@@ -1079,7 +1079,7 @@ BITCOINKERNEL_API btck_Block* BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_copy(
10791079
* @param[in] block Non-null.
10801080
* @return The number of transactions in the block.
10811081
*/
1082-
BITCOINKERNEL_API uint64_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_count_transactions(
1082+
BITCOINKERNEL_API size_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_count_transactions(
10831083
const btck_Block* block
10841084
) BITCOINKERNEL_ARG_NONNULL(1);
10851085

@@ -1092,7 +1092,7 @@ BITCOINKERNEL_API uint64_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_count_tra
10921092
* @return The transaction.
10931093
*/
10941094
BITCOINKERNEL_API btck_Transaction* BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_get_transaction_at(
1095-
const btck_Block* block, uint64_t transaction_index
1095+
const btck_Block* block, size_t transaction_index
10961096
) BITCOINKERNEL_ARG_NONNULL(1);
10971097

10981098
/*
@@ -1207,8 +1207,7 @@ BITCOINKERNEL_API btck_BlockTreeEntry* BITCOINKERNEL_WARN_UNUSED_RESULT btck_cha
12071207
*
12081208
* @param[in] chain Non-null.
12091209
* @param[in] block_height Height in the chain of the to be retrieved block tree entry.
1210-
* @return The block tree entry at a certain height in the currently active chain,
1211-
* or null if the height is out of bounds.
1210+
* @return The block tree entry at a certain height in the currently active chain.
12121211
*/
12131212
BITCOINKERNEL_API btck_BlockTreeEntry* BITCOINKERNEL_WARN_UNUSED_RESULT btck_chain_get_by_height(
12141213
const btck_Chain* chain,
@@ -1285,7 +1284,7 @@ BITCOINKERNEL_API btck_BlockSpentOutputs* BITCOINKERNEL_WARN_UNUSED_RESULT btck_
12851284
* @param[in] block_spent_outputs Non-null.
12861285
* @return The number of transaction spent outputs data in the block spent outputs.
12871286
*/
1288-
BITCOINKERNEL_API uint64_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_spent_outputs_size(
1287+
BITCOINKERNEL_API size_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_spent_outputs_count(
12891288
const btck_BlockSpentOutputs* block_spent_outputs
12901289
) BITCOINKERNEL_ARG_NONNULL(1);
12911290

@@ -1300,7 +1299,7 @@ BITCOINKERNEL_API uint64_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_spent_out
13001299
*/
13011300
BITCOINKERNEL_API btck_TransactionSpentOutputs* BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_spent_outputs_get_transaction_spent_outputs_at(
13021301
const btck_BlockSpentOutputs* block_spent_outputs,
1303-
uint64_t transaction_spent_outputs_index) BITCOINKERNEL_ARG_NONNULL(1);
1302+
size_t transaction_spent_outputs_index) BITCOINKERNEL_ARG_NONNULL(1);
13041303

13051304
/**
13061305
* Destroy the block spent outputs.
@@ -1331,7 +1330,7 @@ BITCOINKERNEL_API btck_TransactionSpentOutputs* BITCOINKERNEL_WARN_UNUSED_RESULT
13311330
* @param[in] transaction_spent_outputs Non-null
13321331
* @return The number of spent transaction outputs for the transaction.
13331332
*/
1334-
BITCOINKERNEL_API uint64_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_spent_outputs_size(
1333+
BITCOINKERNEL_API size_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_spent_outputs_count(
13351334
const btck_TransactionSpentOutputs* transaction_spent_outputs
13361335
) BITCOINKERNEL_ARG_NONNULL(1);
13371336

@@ -1347,7 +1346,7 @@ BITCOINKERNEL_API uint64_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_spe
13471346
*/
13481347
BITCOINKERNEL_API btck_Coin* BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_spent_outputs_get_coin_at(
13491348
const btck_TransactionSpentOutputs* transaction_spent_outputs,
1350-
uint64_t coin_index) BITCOINKERNEL_ARG_NONNULL(1);
1349+
size_t coin_index) BITCOINKERNEL_ARG_NONNULL(1);
13511350

13521351
/**
13531352
* Destroy the transaction spent outputs.

0 commit comments

Comments
 (0)