pathchain 1.0.7 → 1.0.8
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.
- package/README.md +127 -0
- package/maker.js +2 -2
- package/package.json +1 -1
- package/proto/moment.proto +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# pathchain [](https://badge.fury.io/js/pathchain) [](http://github.com/rockstarallegue/pathoschain.git)
|
|
2
|
+

|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
Pathchain is a tool to build path-shaped data structures that are chained one to another from the moment the tool was initialized. The data behaves like a tree where you can track the very origin of your data by tracking the SHA-256 hashname origin of the files. Pathchain uses Google's Protocol Buffers to encode and decode the data structures optimally.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
# Pathchain documentation
|
|
9
|
+
|
|
10
|
+
## Makers
|
|
11
|
+
Maker functions recieve new data to encode into the chain.
|
|
12
|
+
|
|
13
|
+
| Function | Parameters |
|
|
14
|
+
| --------------------------- | --------------------------------------- |
|
|
15
|
+
| [`makeMoment()`](#Moment) | datetime, lat, lon, x, y, z, format |
|
|
16
|
+
| [`makePioneer()`](#Pioneer) | format |
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Moments
|
|
21
|
+
|
|
22
|
+
A moment is the mimimum representation of the pathoschain data structures. Moments are the trunk of any path. They're represented by default with a `MM DD YYYY HH:mm:SSS [GMT]Z` datetime format for `time` and a planet earth representation (0, 0, 0) in general as `space`.
|
|
23
|
+
|
|
24
|
+
`<moment>` :: space and time data ::= { `<“moment/”>` + sha256(`<moment>`) }
|
|
25
|
+
|
|
26
|
+
#### Protocol Buffer file:
|
|
27
|
+
|
|
28
|
+
``` proto
|
|
29
|
+
syntax = "proto3";
|
|
30
|
+
|
|
31
|
+
message moment {
|
|
32
|
+
message space {
|
|
33
|
+
message position {
|
|
34
|
+
optional double x = 1;
|
|
35
|
+
optional double y = 2;
|
|
36
|
+
optional double z = 3;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
optional float lat = 1;
|
|
40
|
+
optional float lon = 2;
|
|
41
|
+
optional position xyz = 3;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
message time {
|
|
45
|
+
optional int32 Y = 1;
|
|
46
|
+
optional int32 M = 2;
|
|
47
|
+
optional int32 D = 3;
|
|
48
|
+
optional int32 H = 4;
|
|
49
|
+
optional int32 A = 5;
|
|
50
|
+
optional int32 h = 6;
|
|
51
|
+
optional int32 m = 7;
|
|
52
|
+
optional int32 s = 8;
|
|
53
|
+
optional int32 S = 9;
|
|
54
|
+
optional int32 Z = 10;
|
|
55
|
+
optional int32 _index = 11;
|
|
56
|
+
optional int32 _length = 12;
|
|
57
|
+
optional int32 _match = 13;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
optional space coordinates = 1;
|
|
61
|
+
optional time datetime = 2;
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Moment maker
|
|
66
|
+
|
|
67
|
+
Parameter rules:
|
|
68
|
+
|Parameter |Required |
|
|
69
|
+
|-------------------------|----------|
|
|
70
|
+
|{string} datetime |(optional)|
|
|
71
|
+
|{float} lat |(optional)|
|
|
72
|
+
|{float} lon |(optional)|
|
|
73
|
+
|{float} x |(optional)|
|
|
74
|
+
|{float} y |(optional)|
|
|
75
|
+
|{float} z |(optional)|
|
|
76
|
+
|{string} format |(optional)|
|
|
77
|
+
|
|
78
|
+
Summoning `makeMoment(datetime, lat, lon, x, y, z, format)`:
|
|
79
|
+
```javascript
|
|
80
|
+
const pathchain = require("pathchain"); // Summoning pathchain
|
|
81
|
+
|
|
82
|
+
const moment_pb = pathchain.makeMoment(); // Making moment
|
|
83
|
+
console.log("Moment buffer: ", moment); // Printing
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Console:
|
|
87
|
+
``` bash
|
|
88
|
+
Moment buffer: c0f9d300e1b28253455e1835f13ca18d000333152a6a9a9b106d0407612980a8
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### Moment getter
|
|
92
|
+
|
|
93
|
+
Parameter rules:
|
|
94
|
+
|Parameter |Required |
|
|
95
|
+
|-------------------------|----------|
|
|
96
|
+
|{string} xauthor |(optional)|
|
|
97
|
+
|{string} xmoment |(required)|
|
|
98
|
+
|
|
99
|
+
Summoning `getMomentObj(xauthor, xmoment)`
|
|
100
|
+
```
|
|
101
|
+
const pathchain = require("pathchain"); // Summoning pathchain
|
|
102
|
+
|
|
103
|
+
const moment_pb = pathchain.makeMoment(); // Moment creation
|
|
104
|
+
var moment_obj = pathchain.getMomentObj(moment_buff); // Printing
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Console:
|
|
108
|
+
``` bash
|
|
109
|
+
Moment object: {
|
|
110
|
+
coordinates: { lat: 0, lon: 0, xyz: { x: 0, y: 0, z: 0 } },
|
|
111
|
+
datetime: {
|
|
112
|
+
Y: 2023,
|
|
113
|
+
M: 11,
|
|
114
|
+
D: 8,
|
|
115
|
+
H: 3,
|
|
116
|
+
A: 0,
|
|
117
|
+
h: 0,
|
|
118
|
+
m: 17,
|
|
119
|
+
s: 0,
|
|
120
|
+
S: 175,
|
|
121
|
+
Z: 360,
|
|
122
|
+
_index: 29,
|
|
123
|
+
_length: 29,
|
|
124
|
+
_match: 7
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
package/maker.js
CHANGED
|
@@ -14,7 +14,7 @@ const checker = require("./checker");
|
|
|
14
14
|
* @param {float} x (optional)
|
|
15
15
|
* @param {float} y (optional)
|
|
16
16
|
* @param {float} z (optional)
|
|
17
|
-
*
|
|
17
|
+
* @param {string} format (optional)
|
|
18
18
|
*
|
|
19
19
|
* @return {string} moment_buffer
|
|
20
20
|
*/
|
|
@@ -90,7 +90,7 @@ function secret(author, format) {
|
|
|
90
90
|
fs.writeFileSync("files/secrets/" + secret_hash, buffer);
|
|
91
91
|
fs.writeFileSync("files/"+ author +"/secrets/" + secret_hash, buffer);
|
|
92
92
|
|
|
93
|
-
return
|
|
93
|
+
return secret_hash;
|
|
94
94
|
}
|
|
95
95
|
// The pioneer already exists
|
|
96
96
|
else{
|
package/package.json
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
message moment {
|
|
4
|
+
message space {
|
|
5
|
+
message position {
|
|
6
|
+
optional double x = 1;
|
|
7
|
+
optional double y = 2;
|
|
8
|
+
optional double z = 3;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
optional float lat = 1;
|
|
12
|
+
optional float lon = 2;
|
|
13
|
+
optional position xyz = 3;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
message time {
|
|
17
|
+
optional int32 Y = 1;
|
|
18
|
+
optional int32 M = 2;
|
|
19
|
+
optional int32 D = 3;
|
|
20
|
+
optional int32 H = 4;
|
|
21
|
+
optional int32 A = 5;
|
|
22
|
+
optional int32 h = 6;
|
|
23
|
+
optional int32 m = 7;
|
|
24
|
+
optional int32 s = 8;
|
|
25
|
+
optional int32 S = 9;
|
|
26
|
+
optional int32 Z = 10;
|
|
27
|
+
optional int32 _index = 11;
|
|
28
|
+
optional int32 _length = 12;
|
|
29
|
+
optional int32 _match = 13;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
optional space coordinates = 1;
|
|
33
|
+
optional time datetime = 2;
|
|
34
|
+
}
|