1 // Copyright (c) 2015-2022 Clearmatics Technologies Ltd
3 // SPDX-License-Identifier: LGPL-3.0+
5 #ifndef __ZECALE_CORE_APPLICATION_POOL_TCC__
6 #define __ZECALE_CORE_APPLICATION_POOL_TCC__
8 #include "libzecale/core/application_pool.hpp"
13 template<typename nppT, typename nsnarkT, size_t NumProofs>
14 application_pool<nppT, nsnarkT, NumProofs>::application_pool(
15 const std::string &name, const typename nsnarkT::verification_key &vk)
16 : _name(name), _verification_key(vk), _tx_pool()
20 template<typename nppT, typename nsnarkT, size_t NumProofs>
21 const std::string &application_pool<nppT, nsnarkT, NumProofs>::name() const
26 template<typename nppT, typename nsnarkT, size_t NumProofs>
27 const typename nsnarkT::verification_key &application_pool<
30 NumProofs>::verification_key() const
32 return _verification_key;
35 template<typename nppT, typename nsnarkT, size_t NumProofs>
36 void application_pool<nppT, nsnarkT, NumProofs>::add_tx(
37 const nested_transaction<nppT, nsnarkT> &tx)
42 template<typename nppT, typename nsnarkT, size_t NumProofs>
43 size_t application_pool<nppT, nsnarkT, NumProofs>::tx_pool_size() const
45 return _tx_pool.size();
48 template<typename nppT, typename nsnarkT, size_t NumProofs>
49 size_t application_pool<nppT, nsnarkT, NumProofs>::get_next_batch(
50 std::array<nested_transaction<nppT, nsnarkT>, NumProofs> &batch)
52 // TODO: For now, only return whole batches (to avoid nasty errors where
53 // elements in the array are not initialized properly). Later, clean up the
54 // data structures to support partial-batches in a safe way.
55 if (_tx_pool.size() < NumProofs) {
58 for (size_t entry_idx = 0; entry_idx < NumProofs; ++entry_idx) {
59 batch[entry_idx] = _tx_pool.top();
65 } // namespace libzecale
67 #endif // __ZECALE_CORE_APPLICATION_POOL_TCC__