Skip to content

Commit

Permalink
fix: Allow autobases w/o localOutput to use debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
lejeunerenard committed Mar 21, 2023
1 parent bc644cf commit 41c1242
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ export class AutobaseManager extends EventEmitter {
const allowedKeys = msgs.filter((msg, i) => allowedKeysComputed[i])
if (allowedKeys.length) {
DEBUG && console.log('[' +
b4a.toString(self.base.localOutput.key, 'hex').slice(-6) +
(self.base.localOutput ? b4a.toString(self.base.localOutput.key, 'hex').slice(-6) : 'N/A') +
'] inputs allowedKeys ', allowedKeys.map((key) => key.slice(-6)))

// Check if any are new
const newKeys = difference(allowedKeys, self._inputKeys)
if (newKeys.size > 0) {
DEBUG && console.log('[' +
b4a.toString(self.base.localOutput.key, 'hex').slice(-6) +
(self.base.localOutput ? b4a.toString(self.base.localOutput.key, 'hex').slice(-6) : 'N/A') +
'] new inputs', [...newKeys].map((key) => key.slice(-6)))

await self._addKeys(newKeys, 'input')
Expand All @@ -96,13 +96,13 @@ export class AutobaseManager extends EventEmitter {
const allowedKeys = msgs.filter((msg, i) => allowedKeysComputed[i])
if (allowedKeys.length) {
DEBUG && console.log('[' +
b4a.toString(self.base.localOutput.key, 'hex').slice(-6) +
(self.base.localOutput ? b4a.toString(self.base.localOutput.key, 'hex').slice(-6) : 'N/A') +
'] outputs allowedKeys ', allowedKeys.map((key) => key.slice(-6)))
// Check if any are new
const newKeys = difference(allowedKeys, self._outputKeys)
if (newKeys.size > 0) {
DEBUG && console.log('[' +
b4a.toString(self.base.localOutput.key, 'hex').slice(-6) +
(self.base.localOutput ? b4a.toString(self.base.localOutput.key, 'hex').slice(-6) : 'N/A') +
'] new outputs ', [...newKeys].map((key) => key.slice(-6)))
await self._addKeys(newKeys, 'output')
await self.updateStorageKeys()
Expand All @@ -126,15 +126,15 @@ export class AutobaseManager extends EventEmitter {
const keys = this.base.inputs.map((core) => b4a.toString(core.key, 'hex'))
if (keys.length) {
DEBUG && console.log('[' +
b4a.toString(this.base.localOutput.key, 'hex').slice(-6) +
(this.base.localOutput ? b4a.toString(this.base.localOutput.key, 'hex').slice(-6) : 'N/A') +
'] announce keys', keys.map((key) => key.slice(-6)))
stream.inputAnnouncer.send(keys)
}

const outputKeys = this.base.outputs.map((core) => b4a.toString(core.key, 'hex'))
if (outputKeys.length) {
DEBUG && console.log('[' +
b4a.toString(this.base.localOutput.key, 'hex').slice(-6) +
(this.base.localOutput ? b4a.toString(this.base.localOutput.key, 'hex').slice(-6) : 'N/A') +
'] announce outputKeys', outputKeys.map((key) => key.slice(-6)))
stream.outputAnnouncer.send(outputKeys)
}
Expand Down

0 comments on commit 41c1242

Please sign in to comment.