git ssb

1+

kieran / horcrux-schemas-and-thoughts



Commit 1d4f9cd9020ce76b4a4488ca3351ccb6bd630812

begin rewrite flume view

Kieran committed on 4/13/2018, 8:10:12 PM
Parent: c26dc1720fa3afa9fcb4e2894da3c1e6e4e2baf4

Files changed

README.mdchanged
index.jschanged
README.mdView
@@ -47,8 +47,10 @@
4747 api.secrets.invites.get(rootId, callback)
4848 api.secrets.invites.stream(rootId)
4949 ```
5050
51 +NOTE: Responses are not needed? Can it not be simply a branch of the invite with accept: true. The flume view could then sort that?
52 +
5153 ### 2. Responses
5254
5355 Each ally recieves a `secret_invite` and, if they're a dependable evil ally, they can send back a `secret_response` to either `accept` or `reject` the trust that Abaddon has placed in them. If they're not a regular scuttler, its likely they might not respond in time before Abaddon makes his final decision to share his soul.
5456
index.jsView
@@ -3,9 +3,9 @@
33 const get = require('lodash/get')
44 const extend = require('xtend')
55 const pry = require('pryjs')
66
7-const FLUME_VIEW_VERSION = 1.01111111111
7 +const FLUME_VIEW_VERSION = 1.011111111111
88 const FLUME_VIEW_NAME = "secrets"
99
1010 const MODULE_NAME = "secrets"
1111 const MSG_TYPES = ["root", "invite", "response", "contract", "secret", "announcement"]
@@ -17,20 +17,49 @@
1717 get: 'async',
1818 stream: 'source'
1919 },
2020 init: function (server, config) {
21- const db = server._flumeUse(
22- FLUME_VIEW_NAME,
23- flumeView(FLUME_VIEW_VERSION, reduce, map, null, {})
24- )
21 + const root = server._flumeUse("root", flumeView(FLUME_VIEW_VERSION, reduce, () => {
2522
23 + }, null, {}))
24 +
25 + const invites = server._flumeUse("invite", flumeView(FLUME_VIEW_VERSION, reduce, () => {
26 +
27 + }, null, {}))
28 +
29 + const responses = server._flumeUse("response", flumeView(FLUME_VIEW_VERSION, reduce, () => {
30 +
31 + }, null, {}))
32 +
33 + const contract = server._flumeUse("contract", flumeView(FLUME_VIEW_VERSION, reduce, () => {
34 +
35 + }, null, {}))
36 +
37 + const secrets= server._flumeUse("secret", flumeView(FLUME_VIEW_VERSION, reduce, () => {
38 +
39 + }, null, {}))
40 +
2641 return {
27- get: db.get,
28- stream: db.stream
42 + root: (opts: {}, cb: ()) => {
43 + root.get(opts, cb)
44 + },
45 + invites: (opts: {}, cb: ()) => {
46 + invites.get(opts, cb)
47 + },
48 + responses: (opts: {}, cb: ()) => {
49 + responses.get(opts, cb)
50 + },
51 + contract: (opts: {}, cb: ()) => {
52 + contract.get(opts, cb)
53 + },
54 + secrets: (opts: {}, cb: ()) => {
55 + secrets.get(opts, cb)
56 + }
2957 }
3058
3159 function reduce (accumulator, item) {
3260 var accumulator = accumulator || {}
61 + eval(pry.it)
3362 const { root, author, invite, response, contract } = item
3463 var rootNode = get(accumulator, [root], {})
3564 if (invite.recp) {
3665 hasInvite = rootNode.invites.filter(invite => invite.id === invite.recp.id).length > 0
@@ -58,8 +87,13 @@
5887 ? recp !== data.author
5988 : recp.id !== data.author
6089 })
6190 : null
91 + if (data.type === "invite") {
92 + return {
93 +
94 + }
95 + }
6296 return {
6397 root: data.root || msg.key,
6498 author: author,
6599 invite: {

Built with git-ssb-web