Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Crown
bitcore-wallet-service-crown
Commits
fdea614d
Unverified
Commit
fdea614d
authored
7 years ago
by
Ivan Socolsky
Browse files
Options
Download
Email Patches
Plain Diff
storage fns for tx confirmation subs
parent
300102e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/storage.js
+41
-0
lib/storage.js
with
41 additions
and
0 deletions
+41
-0
lib/storage.js
View file @
fdea614d
...
...
@@ -25,6 +25,7 @@ var collections = {
TX_NOTES
:
'
tx_notes
'
,
SESSIONS
:
'
sessions
'
,
PUSH_NOTIFICATION_SUBS
:
'
push_notification_subs
'
,
TX_CONFIRMATION_SUBS
:
'
tx_confirmation_subs
'
,
};
var
Storage
=
function
(
opts
)
{
...
...
@@ -78,6 +79,10 @@ Storage.prototype._createIndexes = function() {
this
.
db
.
collection
(
collections
.
PUSH_NOTIFICATION_SUBS
).
createIndex
({
copayerId
:
1
,
});
this
.
db
.
collection
(
collections
.
TX_CONFIRMATION_SUBS
).
createIndex
({
copayerId
:
1
,
txid
:
1
,
});
};
Storage
.
prototype
.
connect
=
function
(
opts
,
cb
)
{
...
...
@@ -935,6 +940,42 @@ Storage.prototype.removePushNotificationSub = function(copayerId, token, cb) {
},
cb
);
};
Storage
.
prototype
.
fetchActiveTxConfirmationSubs
=
function
(
copayerId
,
cb
)
{
this
.
db
.
collection
(
collections
.
TX_CONFIRMATION_SUBS
).
find
({
copayerId
:
copayerId
,
isActive
:
true
,
}).
toArray
(
function
(
err
,
result
)
{
if
(
err
)
return
cb
(
err
);
if
(
!
result
)
return
cb
();
var
subs
=
_
.
map
([].
concat
(
result
),
function
(
r
)
{
return
Model
.
TxConfirmationSub
.
fromObj
(
r
);
});
return
cb
(
null
,
subs
);
});
};
Storage
.
prototype
.
storeTxConfirmationSub
=
function
(
txConfirmationSub
,
cb
)
{
this
.
db
.
collection
(
collections
.
TX_CONFIRMATION_SUBS
).
update
({
copayerId
:
txConfirmationSub
.
copayerId
,
txid
:
txConfirmationSub
.
txid
,
},
txConfirmationSub
,
{
w
:
1
,
upsert
:
true
,
},
cb
);
};
Storage
.
prototype
.
removeTxConfirmationSub
=
function
(
copayerId
,
txid
,
cb
)
{
this
.
db
.
collection
(
collections
.
TX_CONFIRMATION_SUBS
).
remove
({
copayerId
:
copayerId
,
txid
:
txid
,
},
{
w
:
1
},
cb
);
};
Storage
.
prototype
.
_dump
=
function
(
cb
,
fn
)
{
fn
=
fn
||
console
.
log
;
cb
=
cb
||
function
()
{};
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help