-
Notifications
You must be signed in to change notification settings - Fork 27
/
chain.html
195 lines (129 loc) · 5.59 KB
/
chain.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
<!DOCTYPE html>
<html>
<head>
<title>chain.js</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To …</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page_wrapper">
<div id="jump_page">
<a class="source" href="app.html">
app.js
</a>
<a class="source" href="bitcoin.html">
bitcoin.js
</a>
<a class="source" href="blockchain.html">
blockchain.js
</a>
<a class="source" href="chain.html">
chain.js
</a>
<a class="source" href="cli.html">
cli.js
</a>
<a class="source" href="collection.html">
collection.js
</a>
<a class="source" href="fabric.html">
fabric.js
</a>
<a class="source" href="game.html">
game.js
</a>
<a class="source" href="heartbeat.html">
heartbeat.js
</a>
<a class="source" href="http.html">
http.js
</a>
<a class="source" href="index.html">
index.js
</a>
<a class="source" href="network.html">
network.js
</a>
<a class="source" href="oracle.html">
oracle.js
</a>
<a class="source" href="p2pkh.html">
p2pkh.js
</a>
<a class="source" href="relay.html">
relay.js
</a>
<a class="source" href="service.html">
service.js
</a>
<a class="source" href="store.html">
store.js
</a>
<a class="source" href="swarm.html">
swarm.js
</a>
<a class="source" href="witness.html">
witness.js
</a>
</div>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>chain.js</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">¶</a>
</div>
</div>
<div class="content">
<div class='highlight'>
<pre><span class="hljs-meta">'use strict'</span>;</pre>
</div>
</div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">¶</a>
</div>
<p>Fabric Dependencies</p>
</div>
<div class="content">
<div class='highlight'>
<pre><span class="hljs-keyword">const</span> <span class="hljs-title class_">Chain</span> = <span class="hljs-built_in">require</span>(<span class="hljs-string">'../types/chain'</span>);
<span class="hljs-keyword">const</span> chain = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Chain</span>();
<span class="hljs-keyword">async</span> <span class="hljs-keyword">function</span> <span class="hljs-title function_">main</span> () {
<span class="hljs-keyword">await</span> chain.<span class="hljs-property">storage</span>.<span class="hljs-title function_">open</span>();
chain.<span class="hljs-title function_">on</span>(<span class="hljs-string">'block'</span>, <span class="hljs-keyword">function</span> (<span class="hljs-params">block</span>) {
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">'[CHAIN]'</span>, <span class="hljs-string">'new block:'</span>, block);
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">'[CHAIN]'</span>, <span class="hljs-string">'chain:'</span>, chain);
});
chain.<span class="hljs-title function_">append</span>({ <span class="hljs-attr">test</span>: <span class="hljs-string">'foo'</span> });
chain.<span class="hljs-title function_">append</span>({ <span class="hljs-attr">test</span>: <span class="hljs-string">'bar'</span> });
<span class="hljs-keyword">await</span> chain.<span class="hljs-property">storage</span>.<span class="hljs-title function_">close</span>();
<span class="hljs-keyword">return</span> <span class="hljs-variable language_">this</span>;
}
<span class="hljs-title function_">main</span>().<span class="hljs-title function_">catch</span>(<span class="hljs-function">(<span class="hljs-params">exception</span>) =></span> {
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">error</span>(<span class="hljs-string">'[EXAMPLES:CHAIN]'</span>, <span class="hljs-string">'Main Process Exception:'</span>, exception);
});</pre>
</div>
</div>
</li>
</ul>
</div>
</body>
</html>