From 584c06951fd91c6b63ecbb9383ab6f8b310f8691 Mon Sep 17 00:00:00 2001 From: ksrichard Date: Thu, 19 Dec 2024 15:09:06 +0100 Subject: [PATCH] impl almost done, needs extra error handling --- .../implementation/manager.rs | 85 ++++++++++---- .../template_manager/implementation/mod.rs | 3 +- .../implementation/service.rs | 111 ++++++++++-------- .../implementation/template_config.rs | 8 +- .../tari_indexer/src/json_rpc/handlers.rs | 12 +- .../src/p2p/rpc/service_impl.rs | 3 + dan_layer/p2p/proto/rpc.proto | 3 +- .../storage/src/global/backend_adapter.rs | 9 +- dan_layer/storage/src/global/template_db.rs | 24 ++-- .../src/global/backend_adapter.rs | 31 +++-- .../src/global/models/template.rs | 1 + 11 files changed, 193 insertions(+), 97 deletions(-) diff --git a/applications/tari_dan_app_utilities/src/template_manager/implementation/manager.rs b/applications/tari_dan_app_utilities/src/template_manager/implementation/manager.rs index 50b7b7387..5846158c5 100644 --- a/applications/tari_dan_app_utilities/src/template_manager/implementation/manager.rs +++ b/applications/tari_dan_app_utilities/src/template_manager/implementation/manager.rs @@ -20,9 +20,15 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use std::{collections::HashMap, convert::TryFrom, fs, sync::Arc}; +use std::{ + collections::HashMap, + convert::TryFrom, + fs, + sync::Arc, + time::{SystemTime, UNIX_EPOCH}, +}; -use chrono::Utc; +use chrono::{Duration, Utc}; use log::*; use tari_common_types::types::{FixedHash, PublicKey}; use tari_crypto::tari_utilities::ByteArray; @@ -48,7 +54,6 @@ use tari_template_builtin::{ FAUCET_TEMPLATE_ADDRESS, }; use tari_template_lib::{models::TemplateAddress, Hash}; -use tokio::sync::broadcast; use super::TemplateConfig; use crate::template_manager::{ @@ -60,6 +65,12 @@ const LOG_TARGET: &str = "tari::validator_node::template_manager"; const CONCURRENT_ACCESS_LIMIT: isize = 100; +#[derive(Debug, Clone)] +pub enum TemplateResult { + Template(Box