Skip to content

Commit

Permalink
more logging in grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
Evanfeenstra committed May 12, 2020
1 parent 645654c commit fc11432
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
notes.md
todo.md

sphinx.db

# just for testing
binaries/nodeapp-macos
binaries/nodeapp-alpine
Expand Down
22 changes: 19 additions & 3 deletions api/grpc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ async function parseAndVerifyPayload(data){
payload.sender = payload.sender||{}
payload.sender.pub_key=v.pubkey
return payload
} else {
console.error('[GRPC] invalid payload signature')
}
}
} catch(e) {
console.error('[GRPC] failed to parse msg')
return null
}
}
Expand All @@ -36,16 +39,27 @@ async function parseKeysendInvoice(i, actions){
const buf = recs && recs[SPHINX_CUSTOM_RECORD_KEY]
const data = buf && buf.toString()
const value = i && i.value && parseInt(i.value)
if(!data) return
if(!data) {
console.error('[GRPC] no keysend data received')
return
}

let payload
if(data[0]==='{'){
try {
payload = await parseAndVerifyPayload(data)
} catch(e){}
} catch(e){
console.error('[GRPC] failed to parse and verify payload')
}
} else {
const threads = weave(data)
if(threads) payload = await parseAndVerifyPayload(threads)
if(threads) {
try {
payload = await parseAndVerifyPayload(threads)
} catch(e){
console.error('[GRPC] failed to parse and verify payload II')
}
}
}
if(payload){
const dat = payload.content || payload
Expand All @@ -57,6 +71,8 @@ async function parseKeysendInvoice(i, actions){
} else {
console.log('Incorrect payload type:', payload.type)
}
} else {
console.error('[GRPC] no payload')
}
}

Expand Down
2 changes: 1 addition & 1 deletion config/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"development": {
"dialect": "sqlite",
"storage": "./sphinx.db"
"storage": "/Users/Shared/sphinx.db"
},
"docker_development": {
"dialect": "sqlite",
Expand Down
25 changes: 21 additions & 4 deletions dist/api/grpc/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/api/grpc/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fc11432

Please sign in to comment.