Skip to content

Commit d396f72

Browse files
author
Robert Kiel
committed
🐛 payment channel opening blocks until transaction persists in database
1 parent ee931bb commit d396f72

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/handlers/packet.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ module.exports = (node, options) => {
3535
pull.once(packet.toBuffer()),
3636
lp.encode(),
3737
conn,
38-
lp.decode({
39-
maxLength: Acknowledgement.SIZE
40-
}),
38+
lp.decode({ maxLength: Acknowledgement.SIZE }),
39+
pull.filter((data) => data.length === Acknowledgement.SIZE),
4140
pull.take(1),
4241
pull.map(data => Acknowledgement.fromBuffer(data)),
4342
pull.drain((data) => cb(null, data))
@@ -86,15 +85,17 @@ module.exports = (node, options) => {
8685
currentValue: record.tx.value,
8786
//index: tx.index,
8887
tx: record.tx
89-
}, channelId)
88+
}, { channelId: channelId })
9089
}
9190
], cb)
9291
}
9392

9493
node.handle(PROTOCOL_STRING, (protocol, conn) => {
9594
pull(
9695
conn,
97-
lp.decode(),
96+
lp.decode({
97+
maxLength: Packet.SIZE
98+
}),
9899
pull.filter(data => data.length == Packet.SIZE),
99100
paramap((data, cb) => {
100101
const packet = Packet.fromBuffer(data)

src/packet/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class Packet {
114114
return node.paymentChannels.setChannel({
115115
currentValue: this.transaction.value,
116116
index: this.transaction.index
117-
}, channelId, cb)
117+
}, { channelId: channelId }, cb)
118118
},
119119
(cb) => {
120120
log(node.peerInfo.id, `Payment channel exists. Requested SHA256 pre-image of '${Challenge.deriveHashedKey(this.header.derivedSecret).toString('base64')}' is derivable.`)

src/paymentChannels/open.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ module.exports = (self) => (to, cb) => {
7070
totalBalance: (new BN(restoreTx.value)).imuln(2).toBuffer('be', Transaction.VALUE_LENGTH)
7171
}
7272

73-
return self.setChannel(newRecord, (err) => {
73+
return self.setChannel(newRecord, { sync: true }, (err) => {
7474
if (err)
7575
return cb(err)
7676

0 commit comments

Comments
 (0)