This repository has been archived by the owner on Sep 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
teos.watcher.html
793 lines (632 loc) · 54.1 KB
/
teos.watcher.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>teos.watcher — pyton-teos documentation</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="common package" href="common.html" />
<link rel="prev" title="teos.users_dbm" href="teos.users_dbm.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home" alt="Documentation Home"> pyton-teos
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="teos.html">teos package</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="teos.html#subpackages">Subpackages</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="teos.html#submodules">Submodules</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="teos.api.html">teos.api</a></li>
<li class="toctree-l3"><a class="reference internal" href="teos.appointments_dbm.html">teos.appointments_dbm</a></li>
<li class="toctree-l3"><a class="reference internal" href="teos.block_processor.html">teos.block_processor</a></li>
<li class="toctree-l3"><a class="reference internal" href="teos.builder.html">teos.builder</a></li>
<li class="toctree-l3"><a class="reference internal" href="teos.carrier.html">teos.carrier</a></li>
<li class="toctree-l3"><a class="reference internal" href="teos.chain_monitor.html">teos.chain_monitor</a></li>
<li class="toctree-l3"><a class="reference internal" href="teos.cleaner.html">teos.cleaner</a></li>
<li class="toctree-l3"><a class="reference internal" href="teos.extended_appointment.html">teos.extended_appointment</a></li>
<li class="toctree-l3"><a class="reference internal" href="teos.gatekeeper.html">teos.gatekeeper</a></li>
<li class="toctree-l3"><a class="reference internal" href="teos.inspector.html">teos.inspector</a></li>
<li class="toctree-l3"><a class="reference internal" href="teos.internal_api.html">teos.internal_api</a></li>
<li class="toctree-l3"><a class="reference internal" href="teos.lightning_server.html">teos.lightning_server</a></li>
<li class="toctree-l3"><a class="reference internal" href="teos.logger.html">teos.logger</a></li>
<li class="toctree-l3"><a class="reference internal" href="teos.responder.html">teos.responder</a></li>
<li class="toctree-l3"><a class="reference internal" href="teos.rpc.html">teos.rpc</a></li>
<li class="toctree-l3"><a class="reference internal" href="teos.teosd.html">teos.teosd</a></li>
<li class="toctree-l3"><a class="reference internal" href="teos.tools.html">teos.tools</a></li>
<li class="toctree-l3"><a class="reference internal" href="teos.users_dbm.html">teos.users_dbm</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">teos.watcher</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="common.html">common package</a></li>
<li class="toctree-l1"><a class="reference internal" href="contrib.html">contrib package</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">pyton-teos</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home"></a> »</li>
<li><a href="teos.html">teos package</a> »</li>
<li>teos.watcher</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/teos.watcher.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="module-teos.watcher">
<span id="teos-watcher"></span><h1>teos.watcher<a class="headerlink" href="#module-teos.watcher" title="Permalink to this headline">¶</a></h1>
<dl class="py exception">
<dt id="teos.watcher.AppointmentAlreadyTriggered">
<em class="property">exception </em><code class="sig-name descname">AppointmentAlreadyTriggered</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">msg</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#AppointmentAlreadyTriggered"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.AppointmentAlreadyTriggered" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="common.exceptions.html#common.exceptions.BasicException" title="common.exceptions.BasicException"><code class="xref py py-class docutils literal notranslate"><span class="pre">common.exceptions.BasicException</span></code></a></p>
<p>Raised when an appointment is sent to the Watcher but that same data has already been sent to the <code class="xref py py-obj docutils literal notranslate"><span class="pre">Responder</span></code>.</p>
</dd></dl>
<dl class="py exception">
<dt id="teos.watcher.AppointmentLimitReached">
<em class="property">exception </em><code class="sig-name descname">AppointmentLimitReached</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">msg</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#AppointmentLimitReached"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.AppointmentLimitReached" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="common.exceptions.html#common.exceptions.BasicException" title="common.exceptions.BasicException"><code class="xref py py-class docutils literal notranslate"><span class="pre">common.exceptions.BasicException</span></code></a></p>
<p>Raised when the tower maximum appointment count has been reached.</p>
</dd></dl>
<dl class="py exception">
<dt id="teos.watcher.AppointmentNotFound">
<em class="property">exception </em><code class="sig-name descname">AppointmentNotFound</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">msg</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#AppointmentNotFound"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.AppointmentNotFound" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="common.exceptions.html#common.exceptions.BasicException" title="common.exceptions.BasicException"><code class="xref py py-class docutils literal notranslate"><span class="pre">common.exceptions.BasicException</span></code></a></p>
<p>Raised when an appointment is not found on the tower.</p>
</dd></dl>
<dl class="py class">
<dt id="teos.watcher.LocatorCache">
<em class="property">class </em><code class="sig-name descname">LocatorCache</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">blocks_in_cache</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#LocatorCache"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.LocatorCache" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>The <a class="reference internal" href="#teos.watcher.LocatorCache" title="teos.watcher.LocatorCache"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LocatorCache</span></code></a> keeps the data about the last <code class="docutils literal notranslate"><span class="pre">cache_size</span></code> blocks around so appointments can be checked
against it. The data is indexed by locator and it’s mainly built during the normal <a class="reference internal" href="#teos.watcher.Watcher" title="teos.watcher.Watcher"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Watcher</span></code></a> operation so no
extra steps are normally needed.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>blocks_in_cache</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">int</span></code>) – the numbers of blocks to keep in the cache.</p>
</dd>
</dl>
<dl class="py attribute">
<dt id="teos.watcher.LocatorCache.logger">
<code class="sig-name descname">logger</code><a class="headerlink" href="#teos.watcher.LocatorCache.logger" title="Permalink to this definition">¶</a></dt>
<dd><p>The logger for this component.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">Logger</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="teos.watcher.LocatorCache.cache">
<code class="sig-name descname">cache</code><a class="headerlink" href="#teos.watcher.LocatorCache.cache" title="Permalink to this definition">¶</a></dt>
<dd><p>A dictionary of <code class="docutils literal notranslate"><span class="pre">locator:dispute_txid</span></code> pairs that received appointments are checked
against.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">dict</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="teos.watcher.LocatorCache.blocks">
<code class="sig-name descname">blocks</code><a class="headerlink" href="#teos.watcher.LocatorCache.blocks" title="Permalink to this definition">¶</a></dt>
<dd><p>An ordered dictionary of the last <code class="docutils literal notranslate"><span class="pre">blocks_in_cache</span></code> blocks
(<code class="docutils literal notranslate"><span class="pre">block_hash:locators</span></code>). Used to keep track of what data belongs to what block, so data can be pruned
accordingly. Also needed to rebuild the cache in case of reorgs.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">OrderedDict</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="teos.watcher.LocatorCache.cache_size">
<code class="sig-name descname">cache_size</code><a class="headerlink" href="#teos.watcher.LocatorCache.cache_size" title="Permalink to this definition">¶</a></dt>
<dd><p>The size of the cache in blocks.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">int</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.LocatorCache.fix">
<code class="sig-name descname">fix</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">last_known_block</span></em>, <em class="sig-param"><span class="n">block_processor</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#LocatorCache.fix"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.LocatorCache.fix" title="Permalink to this definition">¶</a></dt>
<dd><p>Fixes the cache after a reorg has been detected by feeding the most recent <code class="docutils literal notranslate"><span class="pre">cache_size</span></code> blocks to it.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>last_known_block</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">str</span></code>) – the last known block hash after the reorg.</p></li>
<li><p><strong>block_processor</strong> (<a class="reference internal" href="teos.block_processor.html#teos.block_processor.BlockProcessor" title="teos.block_processor.BlockProcessor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BlockProcessor</span></code></a>) – a block processor instance.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.LocatorCache.get_txid">
<code class="sig-name descname">get_txid</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">locator</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#LocatorCache.get_txid"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.LocatorCache.get_txid" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets a txid from the locator cache.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>locator</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">str</span></code>) – the locator to lookup in the cache.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The txid linked to the given locator if found. None otherwise.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">str</span></code> or <code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.LocatorCache.init">
<code class="sig-name descname">init</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">last_known_block</span></em>, <em class="sig-param"><span class="n">block_processor</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#LocatorCache.init"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.LocatorCache.init" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets the initial state of the locator cache.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>last_known_block</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">str</span></code>) – the last known block by the <a class="reference internal" href="#teos.watcher.Watcher" title="teos.watcher.Watcher"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Watcher</span></code></a>.</p></li>
<li><p><strong>block_processor</strong> (<a class="reference internal" href="teos.block_processor.html#teos.block_processor.BlockProcessor" title="teos.block_processor.BlockProcessor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BlockProcessor</span></code></a>) – a block processor instance.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.LocatorCache.is_full">
<code class="sig-name descname">is_full</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#LocatorCache.is_full"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.LocatorCache.is_full" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns whether the cache is full or not.</p>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.LocatorCache.remove_oldest_block">
<code class="sig-name descname">remove_oldest_block</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#LocatorCache.remove_oldest_block"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.LocatorCache.remove_oldest_block" title="Permalink to this definition">¶</a></dt>
<dd><p>Removes the oldest block from the cache.</p>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.LocatorCache.update">
<code class="sig-name descname">update</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">block_hash</span></em>, <em class="sig-param"><span class="n">locator_txid_map</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#LocatorCache.update"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.LocatorCache.update" title="Permalink to this definition">¶</a></dt>
<dd><p>Updates the cache with data from a new block. Removes the oldest block if the cache is full after the addition.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>block_hash</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">str</span></code>) – the hash of the new block.</p></li>
<li><p><strong>locator_txid_map</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">dict</span></code>) – the dictionary of locators (locator:txid) derived from a list of transaction
ids.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt id="teos.watcher.Watcher">
<em class="property">class </em><code class="sig-name descname">Watcher</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">db_manager</span></em>, <em class="sig-param"><span class="n">gatekeeper</span></em>, <em class="sig-param"><span class="n">block_processor</span></em>, <em class="sig-param"><span class="n">responder</span></em>, <em class="sig-param"><span class="n">sk</span></em>, <em class="sig-param"><span class="n">max_appointments</span></em>, <em class="sig-param"><span class="n">blocks_in_cache</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#Watcher"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.Watcher" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>The <a class="reference internal" href="#teos.watcher.Watcher" title="teos.watcher.Watcher"><code class="xref py py-class docutils literal notranslate"><span class="pre">Watcher</span></code></a> is in charge of watching for channel breaches for the appointments accepted by the tower.</p>
<p>The <a class="reference internal" href="#teos.watcher.Watcher" title="teos.watcher.Watcher"><code class="xref py py-class docutils literal notranslate"><span class="pre">Watcher</span></code></a> keeps track of the accepted appointments in <code class="docutils literal notranslate"><span class="pre">appointments</span></code> and, for new received blocks,
checks if any breach has happened by comparing the txids with the appointment locators. If a breach is seen, the
<code class="docutils literal notranslate"><span class="pre">encrypted_blob</span></code> of the corresponding appointment is decrypted and the data is passed to the
<a class="reference internal" href="teos.responder.html#teos.responder.Responder" title="teos.responder.Responder"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Responder</span></code></a>.</p>
<p>If an appointment reaches its end with no breach, the data is simply deleted.</p>
<p>The <a class="reference internal" href="#teos.watcher.Watcher" title="teos.watcher.Watcher"><code class="xref py py-class docutils literal notranslate"><span class="pre">Watcher</span></code></a> receives information about new received blocks via the <code class="docutils literal notranslate"><span class="pre">block_queue</span></code> that is populated by the
<a class="reference internal" href="teos.chain_monitor.html#teos.chain_monitor.ChainMonitor" title="teos.chain_monitor.ChainMonitor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ChainMonitor</span></code></a>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>db_manager</strong> (<a class="reference internal" href="teos.appointments_dbm.html#teos.appointments_dbm.AppointmentsDBM" title="teos.appointments_dbm.AppointmentsDBM"><code class="xref py py-obj docutils literal notranslate"><span class="pre">AppointmentsDBM</span></code></a>) – an instance of the appointment
database manager to interact with the database.</p></li>
<li><p><strong>block_processor</strong> (<a class="reference internal" href="teos.block_processor.html#teos.block_processor.BlockProcessor" title="teos.block_processor.BlockProcessor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BlockProcessor</span></code></a>) – a block processor instance to
get block from bitcoind.</p></li>
<li><p><strong>responder</strong> (<a class="reference internal" href="teos.responder.html#teos.responder.Responder" title="teos.responder.Responder"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Responder</span></code></a>) – a responder instance.</p></li>
<li><p><strong>sk</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">PrivateKey</span></code>) – a private key used to sign accepted appointments.</p></li>
<li><p><strong>max_appointments</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">int</span></code>) – the maximum amount of appointments accepted by the <a class="reference internal" href="#teos.watcher.Watcher" title="teos.watcher.Watcher"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Watcher</span></code></a> at the same
time.</p></li>
<li><p><strong>blocks_in_cache</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">int</span></code>) – the number of blocks to keep in cache so recently triggered appointments can be
covered.</p></li>
</ul>
</dd>
</dl>
<dl class="py attribute">
<dt id="teos.watcher.Watcher.appointments">
<code class="sig-name descname">appointments</code><a class="headerlink" href="#teos.watcher.Watcher.appointments" title="Permalink to this definition">¶</a></dt>
<dd><p>A dictionary containing a summary of the appointments (<a class="reference internal" href="teos.extended_appointment.html#teos.extended_appointment.ExtendedAppointment" title="teos.extended_appointment.ExtendedAppointment"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ExtendedAppointment</span></code></a> instances) accepted by the tower (<code class="docutils literal notranslate"><span class="pre">locator</span></code> and
<code class="docutils literal notranslate"><span class="pre">user_id</span></code>). It’s populated trough <code class="docutils literal notranslate"><span class="pre">add_appointment</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">dict</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="teos.watcher.Watcher.locator_uuid_map">
<code class="sig-name descname">locator_uuid_map</code><a class="headerlink" href="#teos.watcher.Watcher.locator_uuid_map" title="Permalink to this definition">¶</a></dt>
<dd><p>A <code class="docutils literal notranslate"><span class="pre">locator:uuid</span></code> map used to allow the <a class="reference internal" href="#teos.watcher.Watcher" title="teos.watcher.Watcher"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Watcher</span></code></a> to deal with several
appointments with the same <code class="docutils literal notranslate"><span class="pre">locator</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">dict</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="teos.watcher.Watcher.block_queue">
<code class="sig-name descname">block_queue</code><a class="headerlink" href="#teos.watcher.Watcher.block_queue" title="Permalink to this definition">¶</a></dt>
<dd><p>A queue used by the <a class="reference internal" href="#teos.watcher.Watcher" title="teos.watcher.Watcher"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Watcher</span></code></a> to receive block hashes from <code class="docutils literal notranslate"><span class="pre">bitcoind</span></code>. It is
populated by the <a class="reference internal" href="teos.chain_monitor.html#teos.chain_monitor.ChainMonitor" title="teos.chain_monitor.ChainMonitor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ChainMonitor</span></code></a>.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">Queue</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="teos.watcher.Watcher.db_manager">
<code class="sig-name descname">db_manager</code><a class="headerlink" href="#teos.watcher.Watcher.db_manager" title="Permalink to this definition">¶</a></dt>
<dd><p>An instance of the appointment
database manager to interact with the database.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><a class="reference internal" href="teos.appointments_dbm.html#teos.appointments_dbm.AppointmentsDBM" title="teos.appointments_dbm.AppointmentsDBM"><code class="xref py py-obj docutils literal notranslate"><span class="pre">AppointmentsDBM</span></code></a></p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="teos.watcher.Watcher.gatekeeper">
<code class="sig-name descname">gatekeeper</code><a class="headerlink" href="#teos.watcher.Watcher.gatekeeper" title="Permalink to this definition">¶</a></dt>
<dd><p>A gatekeeper instance in charge to control the
user access and subscription expiry.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><a class="reference internal" href="teos.gatekeeper.html#teos.gatekeeper.Gatekeeper" title="teos.gatekeeper.Gatekeeper"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Gatekeeper</span></code></a></p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="teos.watcher.Watcher.block_processor">
<code class="sig-name descname">block_processor</code><a class="headerlink" href="#teos.watcher.Watcher.block_processor" title="Permalink to this definition">¶</a></dt>
<dd><p>A block processor instance to
get block from bitcoind.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><a class="reference internal" href="teos.block_processor.html#teos.block_processor.BlockProcessor" title="teos.block_processor.BlockProcessor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BlockProcessor</span></code></a></p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="teos.watcher.Watcher.responder">
<code class="sig-name descname">responder</code><a class="headerlink" href="#teos.watcher.Watcher.responder" title="Permalink to this definition">¶</a></dt>
<dd><p>A responder instance.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><a class="reference internal" href="teos.responder.html#teos.responder.Responder" title="teos.responder.Responder"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Responder</span></code></a></p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="teos.watcher.Watcher.signing_key">
<code class="sig-name descname">signing_key</code><a class="headerlink" href="#teos.watcher.Watcher.signing_key" title="Permalink to this definition">¶</a></dt>
<dd><p>A private key used to sign accepted appointments.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">PrivateKey</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="teos.watcher.Watcher.max_appointments">
<code class="sig-name descname">max_appointments</code><a class="headerlink" href="#teos.watcher.Watcher.max_appointments" title="Permalink to this definition">¶</a></dt>
<dd><p>The maximum amount of appointments accepted by the <a class="reference internal" href="#teos.watcher.Watcher" title="teos.watcher.Watcher"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Watcher</span></code></a> at the same
time.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">int</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="teos.watcher.Watcher.last_known_block">
<code class="sig-name descname">last_known_block</code><a class="headerlink" href="#teos.watcher.Watcher.last_known_block" title="Permalink to this definition">¶</a></dt>
<dd><p>The last block known by the <a class="reference internal" href="#teos.watcher.Watcher" title="teos.watcher.Watcher"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Watcher</span></code></a>.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">str</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="teos.watcher.Watcher.locator_cache">
<code class="sig-name descname">locator_cache</code><a class="headerlink" href="#teos.watcher.Watcher.locator_cache" title="Permalink to this definition">¶</a></dt>
<dd><p>A cache of locators for the last <code class="docutils literal notranslate"><span class="pre">blocks_in_cache</span></code> blocks.</p>
<dl class="field-list simple">
<dt class="field-odd">Type</dt>
<dd class="field-odd"><p><a class="reference internal" href="#teos.watcher.LocatorCache" title="teos.watcher.LocatorCache"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LocatorCache</span></code></a></p>
</dd>
</dl>
</dd></dl>
<dl class="field-list simple">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><a class="reference internal" href="common.exceptions.html#common.exceptions.InvalidKey" title="common.exceptions.InvalidKey"><strong>InvalidKey</strong></a> – if teos sk cannot be loaded.</p>
</dd>
</dl>
<dl class="py method">
<dt id="teos.watcher.Watcher.add_appointment">
<code class="sig-name descname">add_appointment</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">appointment</span></em>, <em class="sig-param"><span class="n">user_signature</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#Watcher.add_appointment"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.Watcher.add_appointment" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a new appointment to the <code class="docutils literal notranslate"><span class="pre">appointments</span></code> dictionary if <code class="docutils literal notranslate"><span class="pre">max_appointments</span></code> has not been reached.</p>
<p><code class="docutils literal notranslate"><span class="pre">add_appointment</span></code> is the entry point of the <a class="reference internal" href="#teos.watcher.Watcher" title="teos.watcher.Watcher"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Watcher</span></code></a>. Upon receiving a new appointment it will start
monitoring the blockchain (<code class="docutils literal notranslate"><span class="pre">do_watch</span></code>) until <code class="docutils literal notranslate"><span class="pre">appointments</span></code> is empty.</p>
<p>Once a breach is seen on the blockchain, the <a class="reference internal" href="#teos.watcher.Watcher" title="teos.watcher.Watcher"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Watcher</span></code></a> will decrypt the corresponding <code class="docutils literal notranslate"><span class="pre">encrypted_blob</span></code>
and pass the information to the <a class="reference internal" href="teos.responder.html#teos.responder.Responder" title="teos.responder.Responder"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Responder</span></code></a>.</p>
<p>The tower may store multiple appointments with the same <code class="docutils literal notranslate"><span class="pre">locator</span></code> to avoid DoS attacks based on data
rewriting. <cite>locators`</cite> should be derived from the <code class="docutils literal notranslate"><span class="pre">dispute_txid</span></code>, but that task is performed by the user, and
the tower has no way of verifying whether or not they have been properly derived. Therefore, appointments are
identified by <code class="docutils literal notranslate"><span class="pre">uuid</span></code> and stored in <code class="docutils literal notranslate"><span class="pre">appointments</span></code> and <code class="docutils literal notranslate"><span class="pre">locator_uuid_map</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>appointment</strong> (<a class="reference internal" href="common.appointment.html#common.appointment.Appointment" title="common.appointment.Appointment"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Appointment</span></code></a>) – the appointment to be added to the
<a class="reference internal" href="#teos.watcher.Watcher" title="teos.watcher.Watcher"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Watcher</span></code></a>.</p></li>
<li><p><strong>user_signature</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">str</span></code>) – the user’s appointment signature (hex-encoded).</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The tower response as a dict, containing: <code class="docutils literal notranslate"><span class="pre">locator</span></code>, <code class="docutils literal notranslate"><span class="pre">signature</span></code>, <code class="docutils literal notranslate"><span class="pre">available_slots</span></code> and
<code class="docutils literal notranslate"><span class="pre">subscription_expiry</span></code>.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">dict</span></code></p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><ul class="simple">
<li><p><a class="reference internal" href="#teos.watcher.AppointmentLimitReached" title="teos.watcher.AppointmentLimitReached"><strong>AppointmentLimitReached</strong></a> – If the tower cannot hold more appointments (cap reached).</p></li>
<li><p><a class="reference internal" href="teos.gatekeeper.html#teos.gatekeeper.AuthenticationFailure" title="teos.gatekeeper.AuthenticationFailure"><strong>AuthenticationFailure</strong></a> – If the user cannot be authenticated.</p></li>
<li><p><a class="reference internal" href="teos.gatekeeper.html#teos.gatekeeper.NotEnoughSlots" title="teos.gatekeeper.NotEnoughSlots"><strong>NotEnoughSlots</strong></a> – If the user does not have enough available slots, so the appointment is rejected.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.Watcher.awake">
<code class="sig-name descname">awake</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#Watcher.awake"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.Watcher.awake" title="Permalink to this definition">¶</a></dt>
<dd><p>Starts a new thread to monitor the blockchain for channel breaches. The thread will run until the
<code class="xref py py-obj docutils literal notranslate"><span class="pre">ChainMonitor</span></code> adds the <code class="docutils literal notranslate"><span class="pre">"END"</span></code> message to the queue.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>The thread object that was just created and is already running.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">Thread</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.Watcher.check_breach">
<code class="sig-name descname">check_breach</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">uuid</span></em>, <em class="sig-param"><span class="n">appointment</span></em>, <em class="sig-param"><span class="n">dispute_txid</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#Watcher.check_breach"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.Watcher.check_breach" title="Permalink to this definition">¶</a></dt>
<dd><p>Checks if a breach is valid. Valid breaches should decrypt to a valid transaction.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>uuid</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">str</span></code>) – the uuid of the appointment that was triggered by the breach.</p></li>
<li><p><strong>appointment</strong> (<a class="reference internal" href="teos.extended_appointment.html#teos.extended_appointment.ExtendedAppointment" title="teos.extended_appointment.ExtendedAppointment"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ExtendedAppointment</span></code></a>) – the appointment
data.</p></li>
<li><p><strong>dispute_txid</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">str</span></code>) – the id of the transaction that triggered the breach.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A tuple containing the penalty txid and the raw penalty tx.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">tuple</span></code></p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><ul class="simple">
<li><p><a class="reference internal" href="common.exceptions.html#common.exceptions.EncryptionError" title="common.exceptions.EncryptionError"><strong>EncryptionError</strong></a> – if the encrypted blob from the provided appointment cannot be decrypted with the
key derived from the breach transaction id.</p></li>
<li><p><a class="reference internal" href="teos.block_processor.html#teos.block_processor.InvalidTransactionFormat" title="teos.block_processor.InvalidTransactionFormat"><strong>InvalidTransactionFormat</strong></a> – if the decrypted data does not have a valid transaction format.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.Watcher.do_watch">
<code class="sig-name descname">do_watch</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#Watcher.do_watch"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.Watcher.do_watch" title="Permalink to this definition">¶</a></dt>
<dd><p>Monitors the blockchain for channel breaches.</p>
<p>This is the main method of the <a class="reference internal" href="#teos.watcher.Watcher" title="teos.watcher.Watcher"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Watcher</span></code></a> and the one in charge to pass appointments to the
<a class="reference internal" href="teos.responder.html#teos.responder.Responder" title="teos.responder.Responder"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Responder</span></code></a> upon detecting a breach.</p>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.Watcher.filter_breaches">
<code class="sig-name descname">filter_breaches</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">breaches</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#Watcher.filter_breaches"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.Watcher.filter_breaches" title="Permalink to this definition">¶</a></dt>
<dd><p>Filters the valid from the invalid channel breaches.</p>
<p>The <a class="reference internal" href="#teos.watcher.Watcher" title="teos.watcher.Watcher"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Watcher</span></code></a> cannot know if an <code class="docutils literal notranslate"><span class="pre">encrypted_blob</span></code> contains a valid transaction until a breach is seen.
Blobs that contain arbitrary data are dropped and not sent to the <a class="reference internal" href="teos.responder.html#teos.responder.Responder" title="teos.responder.Responder"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Responder</span></code></a>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>breaches</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">dict</span></code>) – a dictionary containing channel breaches (<code class="docutils literal notranslate"><span class="pre">locator:txid</span></code>).</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><p>A dictionary and a list. The former contains the valid breaches, while the latter contain the
invalid ones.</p>
<p>The valid breaches dictionary has the following structure:</p>
<p><code class="docutils literal notranslate"><span class="pre">{locator,</span> <span class="pre">dispute_txid,</span> <span class="pre">penalty_txid,</span> <span class="pre">penalty_rawtx}</span></code></p>
</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">tuple</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.Watcher.get_all_responder_trackers">
<code class="sig-name descname">get_all_responder_trackers</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#Watcher.get_all_responder_trackers"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.Watcher.get_all_responder_trackers" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a dictionary with all the trackers stored in the db for the responder.</p>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.Watcher.get_all_watcher_appointments">
<code class="sig-name descname">get_all_watcher_appointments</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#Watcher.get_all_watcher_appointments"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.Watcher.get_all_watcher_appointments" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a dictionary with all the appointment stored in the db for the watcher.</p>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.Watcher.get_appointment">
<code class="sig-name descname">get_appointment</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">locator</span></em>, <em class="sig-param"><span class="n">user_signature</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#Watcher.get_appointment"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.Watcher.get_appointment" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets information about an appointment.</p>
<p>The appointment can either be in the watcher, the responder, or not found.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>locator</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">str</span></code>) – a 16-byte hex-encoded value used by the tower to detect channel breaches.</p></li>
<li><p><strong>user_signature</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">str</span></code>) – the signature of the request by the user.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A tuple containing the appointment data and the status (either <code class="docutils literal notranslate"><span class="pre">"being_watched"</span></code> or
<code class="docutils literal notranslate"><span class="pre">"dispute_responded"</span></code>).</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">tuple</span></code></p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><a class="reference internal" href="#teos.watcher.AppointmentNotFound" title="teos.watcher.AppointmentNotFound"><strong>AppointmentNotFound</strong></a> – if the appointment is not found in the tower.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.Watcher.get_breaches">
<code class="sig-name descname">get_breaches</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">locator_txid_map</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#Watcher.get_breaches"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.Watcher.get_breaches" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets a dictionary of channel breaches given a map of <code class="docutils literal notranslate"><span class="pre">locator:dispute_txid</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>locator_txid_map</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">dict</span></code>) – the dictionary of locators (locator:txid) derived from a list of
transaction ids.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A dictionary (<code class="docutils literal notranslate"><span class="pre">locator:txid</span></code>) with all the breaches found. An empty dictionary if none are
found.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">dict</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.Watcher.get_registered_user_ids">
<code class="sig-name descname">get_registered_user_ids</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#Watcher.get_registered_user_ids"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.Watcher.get_registered_user_ids" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the list of user ids of all the registered users.</p>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.Watcher.get_user_info">
<code class="sig-name descname">get_user_info</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">user_id</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#Watcher.get_user_info"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.Watcher.get_user_info" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the data hold by the tower about the user given an <code class="docutils literal notranslate"><span class="pre">user_id</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>user_id</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">str</span></code>) – the id of the requested user.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The user data if found. <code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code> if not found, or
the <code class="docutils literal notranslate"><span class="pre">user_id</span></code> is invalid.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">UserInfo</span> <span class="pre"><teos.gatekeeper.UserInfo></span> <span class="pre">or</span> <span class="pre">:obj:`None</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.Watcher.n_registered_users">
<em class="property">property </em><code class="sig-name descname">n_registered_users</code><a class="headerlink" href="#teos.watcher.Watcher.n_registered_users" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the number of users currently registered to the tower.</p>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.Watcher.n_responder_trackers">
<em class="property">property </em><code class="sig-name descname">n_responder_trackers</code><a class="headerlink" href="#teos.watcher.Watcher.n_responder_trackers" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the total number of trackers in the responder.</p>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.Watcher.n_watcher_appointments">
<em class="property">property </em><code class="sig-name descname">n_watcher_appointments</code><a class="headerlink" href="#teos.watcher.Watcher.n_watcher_appointments" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the total number of appointments stored in the watcher.</p>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.Watcher.register">
<code class="sig-name descname">register</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">user_id</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/teos/watcher.html#Watcher.register"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#teos.watcher.Watcher.register" title="Permalink to this definition">¶</a></dt>
<dd><p>Registers a user.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>user_id</strong> (<code class="xref py py-obj docutils literal notranslate"><span class="pre">str</span></code>) – the public key that identifies the user (33-bytes hex str).</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A tuple containing the available slots, the subscription expiry, and the signature of the
registration receipt by the Watcher.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">tuple</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="teos.watcher.Watcher.tower_id">
<em class="property">property </em><code class="sig-name descname">tower_id</code><a class="headerlink" href="#teos.watcher.Watcher.tower_id" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the id of this tower, as a hex string.</p>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="common.html" class="btn btn-neutral float-right" title="common package" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="teos.users_dbm.html" class="btn btn-neutral float-left" title="teos.users_dbm" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2019, Talaia Labs
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>