git ssb

2+

mixmix / ticktack



Commit 69fecb32f29fb953037e1e0b67db4d89bb1cab8b

wip import with ssb-ebt data

mix irving committed on 5/23/2018, 9:00:58 AM
Parent: 45747ccda7b06223e42c0ead8833c062687d0d80

Files changed

app/html/app.jschanged
ftu/app.jschanged
package-lock.jsonchanged
package.jsonchanged
app/html/app.jsView
@@ -42,23 +42,24 @@
4242 }
4343 })
4444
4545 function getMySeq (server) {
46- server.ebt.remoteFeedSequence((err, data) => {
47- server.latestSequence(server.id, (err, seq) => {
48- console.log(`${count} mins`)
49- count = count + 1
50- console.log('actual seq:', seq)
51- console.log(JSON.stringify(data, null, 2))
52- console.log('ticktack pubs', [
53- '@7xMrWP8708+LDvaJrRMRQJEixWYp4Oipa9ohqY7+NyQ=.ed25519',
54- '@MflVZCcOBOUe6BLrm/8TyirkTu9/JtdnIJALcd8v5bc=.ed25519'
55- ])
56- console.log('------------------')
57- })
58- })
46+ console.log('REMOVE THIS')
47+ // server.ebt.peerStatus(server.id, err, data) => {
48+ // server.latestSequence(server.id, (err, seq) => {
49+ // console.log(`${count} mins`)
50+ // count = count + 1
51+ // console.log('actual seq:', seq)
52+ // console.log(JSON.stringify(data, null, 2))
53+ // console.log('ticktack pubs', [
54+ // '@7xMrWP8708+LDvaJrRMRQJEixWYp4Oipa9ohqY7+NyQ=.ed25519',
55+ // '@MflVZCcOBOUe6BLrm/8TyirkTu9/JtdnIJALcd8v5bc=.ed25519'
56+ // ])
57+ // console.log('------------------')
58+ // })
59+ // })
5960
60- setTimeout(() => getMySeq(server), 60000)
61+ // setTimeout(() => getMySeq(server), 60000)
6162 }
6263
6364 function renderLocation (loc) {
6465 var page = api.router.sync.router(loc)
ftu/app.jsView
@@ -23,15 +23,14 @@
2323 exports.gives = nest('ftu.app')
2424
2525 exports.needs = nest({
2626 'styles.css': 'reduce',
27- 'translations.sync.strings': 'first',
27+ 'translations.sync.strings': 'first'
2828 })
2929
3030 exports.create = (api) => {
3131 return nest({
32- 'ftu.app': function app() {
33-
32+ 'ftu.app': function app () {
3433 const strings = api.translations.sync.strings()
3534
3635 const css = values(api.styles.css()).join('\n')
3736 insertCss(css)
@@ -53,9 +52,9 @@
5352
5453 var importProcess = h('Page -ftu', [
5554 h('div.content', [
5655 h('h1', strings.backup.import.header),
57- h('p', [strings.backup.import.synchronizeMessage, state.currentSequence, '/', state.latestSequence]),
56+ h('p', [strings.backup.import.synchronizeMessage, state.currentSequence, '/', state.latestSequence])
5857 ])
5958 ])
6059
6160 // This watcher is responsible for switching from FTU to Ticktack main app
@@ -65,9 +64,9 @@
6564 electron.ipcRenderer.send('import-completed')
6665 }
6766 })
6867
69- if (fs.existsSync(path.join(configFolder, "secret"))) {
68+ if (fs.existsSync(path.join(configFolder, 'secret'))) {
7069 // somehow the FTU started but the identity is already in place.
7170 // treat it as a failed import and start importing...
7271 console.log('resuming import')
7372 let previousData = getImportData()
@@ -102,27 +101,24 @@
102101
103102 observeSequence()
104103 })
105104
106-
107-
108-function actionCreateNewOne() {
105+function actionCreateNewOne () {
109106 isBusy.set(true)
110- const manifest = JSON.parse(fs.readFileSync(path.join(__dirname, "../manifest.json")))
107+ const manifest = JSON.parse(fs.readFileSync(path.join(__dirname, '../manifest.json')))
111108 const manifestFile = path.join(configFolder, 'manifest.json')
112109 if (!fs.existsSync(configFolder)) {
113110 fs.mkdirSync(configFolder)
114111 }
115112 fs.writeFileSync(manifestFile, JSON.stringify(manifest))
116113
117-
118114 electron.ipcRenderer.send('create-new-identity')
119115 }
120116
121-function actionImportIdentity(strings) {
122- const peersFile = path.join(configFolder, "gossip.json")
123- const secretFile = path.join(configFolder, "secret")
124- const manifest = JSON.parse(fs.readFileSync(path.join(__dirname, "../manifest.json")))
117+function actionImportIdentity (strings) {
118+ const peersFile = path.join(configFolder, 'gossip.json')
119+ const secretFile = path.join(configFolder, 'secret')
120+ const manifest = JSON.parse(fs.readFileSync(path.join(__dirname, '../manifest.json')))
125121 const manifestFile = path.join(configFolder, 'manifest.json')
126122
127123 // place the other files first
128124 dialog.showOpenDialog(
@@ -132,19 +128,19 @@
132128 defaultPath: 'ticktack-identity.backup',
133129 properties: ['openFile']
134130 },
135131 (filenames) => {
136- if (typeof filenames !== "undefined") {
132+ if (typeof filenames !== 'undefined') {
137133 let filename = filenames[0]
138134 let data = JSON.parse(fs.readFileSync(filename))
139- if (data.hasOwnProperty("secret") && data.hasOwnProperty("peers") && data.hasOwnProperty("latestSequence")) {
135+ if (data.hasOwnProperty('secret') && data.hasOwnProperty('peers') && data.hasOwnProperty('latestSequence')) {
140136 if (!fs.existsSync(configFolder)) {
141137 fs.mkdirSync(configFolder)
142138 }
143139
144140 fs.writeFileSync(manifestFile, JSON.stringify(manifest))
145- fs.writeFileSync(peersFile, JSON.stringify(data.peers), "utf8")
146- fs.writeFileSync(secretFile, data.secret, "utf8")
141+ fs.writeFileSync(peersFile, JSON.stringify(data.peers), 'utf8')
142+ fs.writeFileSync(secretFile, data.secret, 'utf8')
147143 state.latestSequence.set(data.latestSequence)
148144 state.currentSequence.set(0)
149145 isPresentingOptions.set(false)
150146
@@ -154,18 +150,18 @@
154150 setImportData(data)
155151
156152 electron.ipcRenderer.send('import-identity')
157153 } else {
158- console.log("> bad export file")
154+ console.log('> bad export file')
159155 console.log(data)
160- alert("Bad Export File")
156+ alert('Bad Export File')
161157 }
162158 }
163159 }
164160 )
165161 }
166162
167-function windowControls() {
163+function windowControls () {
168164 if (process.platform === 'darwin') return
169165
170166 const window = remote.getCurrentWindow()
171167 const minimize = () => window.minimize()
@@ -190,15 +186,13 @@
190186 })
191187 ])
192188 }
193189
194-
195-function assetPath(name) {
190+function assetPath (name) {
196191 return path.join(__dirname, '../assets', name)
197192 }
198193
199-
200-function getImportData() {
194+function getImportData () {
201195 var importFile = path.join(configFolder, 'importing.json')
202196 if (fs.existsSync(importFile)) {
203197 let data = JSON.parse(fs.readFileSync(importFile))
204198 return data || false
@@ -206,14 +200,14 @@
206200 return false
207201 }
208202 }
209203
210-function setImportData(data) {
204+function setImportData (data) {
211205 var importFile = path.join(configFolder, 'importing.json')
212206 fs.writeFileSync(importFile, JSON.stringify(data))
213207 }
214208
215-function observeSequence() {
209+function observeSequence () {
216210 const pull = require('pull-stream')
217211 const Client = require('ssb-client')
218212 const config = require('../config').create().config.sync.load()
219213 const _ = require('lodash')
@@ -223,24 +217,73 @@
223217 console.error('problem starting client', err)
224218 } else {
225219 console.log('> sbot running!!!!')
226220
221+ ssbServer.gossip.peers((err, data) => {
222+ console.log('PEERS', err, data)
223+
224+ data.forEach(peer => {
225+ ssbServer.gossip.connect({
226+ 'host': peer.host,
227+ 'port': peer.port,
228+ 'key': peer.key
229+ }, function (err, v) {
230+ console.log('connected to ', peer.host)
231+ })
232+ })
233+ })
234+
235+ // ssbServer.gossip.connect({
236+ // 'host': '128.199.76.241',
237+ // 'port': 8008,
238+ // 'key': '@7xMrWP8708+LDvaJrRMRQJEixWYp4Oipa9ohqY7+NyQ=.ed25519'
239+ // }, function (err, v) {
240+ // console.log('connected to ticktack 1', err, v)
241+ // })
242+
243+ // ssbServer.gossip.connect({
244+ // 'host': '138.68.27.255',
245+ // 'port': 8008,
246+ // 'key': '@MflVZCcOBOUe6BLrm/8TyirkTu9/JtdnIJALcd8v5bc=.ed25519'
247+ // }, function (err, v) {
248+ // console.log('connected to ticktack 2', err, v)
249+ // })
250+
251+ // ssbServer.gossip.connect({
252+ // host: 'one.butt.nz',
253+ // key: '@VJM7w1W19ZsKmG2KnfaoKIM66BRoreEkzaVm/J//wl8=.ed25519',
254+ // port: 8008
255+ // }, function (err, v) {
256+ // console.log('connected to one.butt.nz', err, v)
257+ // checkPeers()
258+ // })
259+
260+ function checkPeers () {
261+ ssbServer.ebt.peerStatus(ssbServer.id, (err, data) => {
262+ console.log('PEER STATUS:')
263+ console.log(data.seq)
264+ console.log(data.peers)
265+ console.log('-------')
266+ })
267+
268+ setTimeout(checkPeers, 5000)
269+ }
270+
227271 var feedSource = ssbServer.createUserStream({
228272 live: true,
229273 id: ssbServer.id
230274 })
231275
232276 var valueLogger = pull.drain((msg) => {
233- let seq = _.get(msg, "value.sequence", false)
277+ let seq = _.get(msg, 'value.sequence', false)
234278 if (seq) {
235279 state.currentSequence.set(seq)
236280 }
237281 })
238282
239283 pull(
240284 feedSource,
241- valueLogger,
285+ valueLogger
242286 )
243-
244287 }
245288 })
246-}
289+}
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 289973 bytes
New file size: 289973 bytes
package.jsonView
@@ -65,9 +65,9 @@
6565 "ssb-backlinks": "^0.6.1",
6666 "ssb-blobs": "^1.1.4",
6767 "ssb-client": "4.5.2",
6868 "ssb-config": "^2.2.0",
69- "ssb-ebt": "^5.1.5",
69+ "ssb-ebt": "^5.2.0",
7070 "ssb-friends": "^2.3.5",
7171 "ssb-keys": "^7.0.10",
7272 "ssb-markdown": "^3.3.0",
7373 "ssb-mentions": "^0.4.0",

Built with git-ssb-web