wao 0.2.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,53 @@
1
+ local drive = { _version = "0.0.1" }
2
+
3
+ function drive.getBlock(height)
4
+ local block = io.open("/block/" .. height)
5
+ if not block then
6
+ return nil, "Block Header not found!"
7
+ end
8
+ local headers = require('json').decode(
9
+ block:read(
10
+ block:seek('end')
11
+ )
12
+ )
13
+ block:close()
14
+ return headers
15
+ end
16
+
17
+ function drive.getTx(txId)
18
+ local file = io.open('/tx/' .. txId)
19
+ if not file then
20
+ return nil, "File not found!"
21
+ end
22
+ local contents = require('json').decode(
23
+ file:read(
24
+ file:seek('end')
25
+ )
26
+ )
27
+ file:close()
28
+ return contents
29
+ end
30
+
31
+ function drive.getData(txId)
32
+ local file = io.open('/data/' .. txId)
33
+ if not file then
34
+ return nil, "File not found!"
35
+ end
36
+ local contents = file:read(
37
+ file:seek('end')
38
+ )
39
+ file:close()
40
+ return contents
41
+ end
42
+
43
+ function drive.getDataItem(txId)
44
+ local file = io.open('/tx2/' .. txId)
45
+ if not file then
46
+ return nil, "File not found!"
47
+ end
48
+ local contents = file:read(
49
+ file:seek('end')
50
+ )
51
+ file:close()
52
+ return contents
53
+ end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.2.4",
3
+ "version": "0.3.0",
4
4
  "description": "",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",