plebble
calendar.h
Go to the documentation of this file.
1 /*
2 -------------------------------------------------------------------------------
3  PLEBBLE
4 -------------------------------------------------------------------------------
5  Copyright (C) 2019-2020 KATLAS Technology. (http://katlastechnology.com)
6  Copyright (C) 2017-2020 Marcos Mayorga. (mm@mm-studios.com)
7 
8  This file is part of our Plebble(R) Platform.
9 
10  The code below cannot be copied, used for any purpose other than the one
11  agreed and/or distributed without the express permission of
12  KATLAS Technology.
13 -------------------------------------------------------------------------------
14 
15 
16 */
17 #ifndef USGOV_6110ca70156c39f06bccb0b02bb98b63bef265d6284d970e13ddddb69c4a633b
18 #define USGOV_6110ca70156c39f06bccb0b02bb98b63bef265d6284d970e13ddddb69c4a633b
19 
20 #include <set>
21 #include <mutex>
22 #include <chrono>
23 #include <atomic>
24 #include <condition_variable>
25 #include "evidence.h"
26 
27 namespace us{ namespace gov {
28 namespace engine {
29  using namespace std;
30 
31  //struct evidence;
32  struct app;
33  struct calndx final {
34  calndx(evidence*e);
35  bool operator < (const calndx& other) const;
37  };
38 
39  struct calendar_t:set<calndx> {
40  static constexpr chrono::seconds cycle_period {60};
41  static constexpr chrono::seconds idle_wakeup {1};
42  static constexpr chrono::seconds relay_interval {15}; //Tx execution is delayed this many seconds to account for propagation.
45  calendar_t(const calendar_t&)=delete;
46  calendar_t& operator =(const calendar_t&)=delete;
47  void clear_until(uint64_t);
48  //void on_finish();
49  int schedule(evidence* e); //0-accepted; 1-invalid-expired; 2-invalid-late; 3-dup
50  mutable mutex mx;
51  //mutable condition_variable cv;
52  uint64_t block_opening;
53  uint64_t block_closure;
54  uint64_t last_processed;
55  //mutable atomic<short> resume{0};
56  };
57 
58 }
59 }}
60 
61 #endif
62 
63 
64 
app.h
evidence.h
us::gov::engine::calendar_t::~calendar_t
~calendar_t()
us::gov::engine::calendar_t::mx
mutex mx
Definition: calendar.h:50
us
Definition: daemon.h:22
unlikely
#define unlikely(x)
Definition: likely.h:30
us::gov::engine::calendar_t::block_opening
uint64_t block_opening
Definition: calendar.h:52
us::gov::engine::calendar_t::last_processed
uint64_t last_processed
Definition: calendar.h:54
us::gov::engine::calndx::calndx
calndx(evidence *e)
Definition: calendar.cpp:80
us::gov::relay::evidence::compute_hash
virtual hash_t compute_hash() const =0
us::gov::engine::calndx::operator<
bool operator<(const calndx &other) const
Definition: calendar.cpp:83
c
us::gov::engine::calendar_t c
Definition: calendar.cpp:28
us::gov::engine::calndx::e
evidence * e
Definition: calendar.h:36
us::gov::engine::calendar_t
Definition: calendar.h:39
us::gov::engine::calendar_t::block_closure
uint64_t block_closure
Definition: calendar.h:53
us::gov::relay::evidence::ts
uint64_t ts
Definition: evidence.h:53
calendar.h
us::gov::engine::calendar_t::schedule
int schedule(evidence *e)
us::gov::engine::calendar_t::clear_until
void clear_until(uint64_t)
us::gov::relay::evidence::expires
uint64_t expires
Definition: evidence.h:54
likely
#define likely(x)
Definition: likely.h:29
us::gov::engine
Definition: hmi.h:32
std
Definition: app.h:380
us::gov::engine::calendar_t::calendar_t
calendar_t()
us::gov::engine::calndx
Definition: calendar.h:33
us::gov::relay::evidence
Definition: evidence.h:31
gov.h
us::gov::engine::calendar_t::calendar_t
calendar_t(const calendar_t &)=delete
log
#define log
Definition: gov.h:83