Scorum
process_contracts_expiration.cpp
Go to the documentation of this file.
2 
6 
7 namespace scorum {
8 namespace chain {
9 namespace database_ns {
10 
12 {
13  debug_log(ctx.get_block_info(), "process_contracts_expiration BEGIN");
14 
15  data_service_factory_i& services = ctx.services();
16  atomicswap_service_i& atomicswap_service = services.atomicswap_service();
17  dynamic_global_property_service_i& dyn_prop_service = services.dynamic_global_property_service();
18 
19  auto contracts = atomicswap_service.get_contracts();
20  const auto& props = dyn_prop_service.get();
21 
22  for (const atomicswap_contract_object& contract : contracts)
23  {
24  if (props.time >= contract.deadline)
25  {
26  if (contract.secret.empty())
27  {
28  auto owner = contract.owner;
29  auto refund_amount = contract.amount;
30 
31  // only for initiator or not redeemed participant contracts
32  atomicswap_service.refund_contract(contract);
33 
35  }
36  else
37  {
38  atomicswap_service.remove(contract);
39  }
40  }
41  }
42 
43  debug_log(ctx.get_block_info(), "process_contracts_expiration END");
44 }
45 }
46 }
47 }
data_service_factory_i & services() const
Definition: block_tasks.hpp:25
virtual void push_virtual_operation(const operation &op)
Definition: block_tasks.cpp:22
#define debug_log(CTX, FORMAT,...)
Definition: debug_log.hpp:3
Definition: asset.cpp:15
virtual void refund_contract(const atomicswap_contract_object &contract)=0
virtual atomicswap_contracts_refs_type get_contracts() const =0
virtual const object_type & get() const =0