Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
9adb6258
Commit
9adb6258
authored
Oct 29, 2014
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
polling whisper in progress
parent
0b10cbd7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
30 deletions
+49
-30
main.js
main.js
+49
-30
No files found.
main.js
View file @
9adb6258
...
...
@@ -102,6 +102,28 @@
];
};
var
ethWatchMethods
=
function
()
{
var
newFilter
=
function
(
args
)
{
return
typeof
args
[
0
]
===
'string'
?
'newFilterString'
:
'newFilter'
;
};
return
[
{
name
:
'newFilter'
,
call
:
newFilter
},
{
name
:
'uninstallFilter'
,
call
:
'uninstallFilter'
},
{
name
:
'changed'
,
call
:
'changed'
},
{
name
:
'getMessages'
,
call
:
'getMessages'
}
];
};
var
shhWatchMethods
=
function
()
{
return
[
{
name
:
'newFilter'
,
call
:
'shhNewFilter'
},
{
name
:
'uninstallFilter'
,
call
:
'shhUninstallFilter'
},
{
name
:
'changed'
,
call
:
'shhChanged'
},
{
name
:
'getMessage'
,
call
:
'shhGetMessages'
}
];
};
var
setupMethods
=
function
(
obj
,
methods
)
{
methods
.
forEach
(
function
(
method
)
{
obj
[
method
.
name
]
=
function
()
{
...
...
@@ -186,6 +208,10 @@
return
str
;
},
toDecimal
:
function
(
val
)
{
return
parseInt
(
val
,
16
);
},
fromAscii
:
function
(
str
,
pad
)
{
if
(
pad
===
undefined
)
{
pad
=
32
...
...
@@ -201,8 +227,8 @@
eth
:
{
prototype
:
Object
(),
watch
:
function
(
params
)
{
return
new
Filter
(
params
);
watch
:
function
(
params
)
{
return
new
Filter
(
params
,
ethWatch
);
},
},
...
...
@@ -211,7 +237,10 @@
},
shh
:
{
prototype
:
Object
()
prototype
:
Object
(),
watch
:
function
(
params
)
{
return
new
Filter
(
params
,
shhWatch
);
}
},
on
:
function
(
event
,
cb
)
{
...
...
@@ -259,6 +288,11 @@
setupMethods
(
web3
.
db
,
dbMethods
());
setupMethods
(
web3
.
shh
,
shhMethods
());
var
ethWatch
=
{};
setupMethods
(
ethWatch
,
ethWatchMethods
());
var
shhWatch
=
{};
setupMethods
(
shhWatch
,
shhWatchMethods
());
var
ProviderManager
=
function
()
{
this
.
queued
=
[];
this
.
polls
=
[];
...
...
@@ -340,33 +374,22 @@
web3
.
setProvider
=
function
(
provider
)
{
provider
.
onmessage
=
messageHandler
;
web3
.
provider
.
set
(
provider
);
web3
.
provider
.
sendQueued
();
};
var
filters
=
[];
var
Filter
=
function
(
options
)
{
var
Filter
=
function
(
options
,
impl
)
{
filters
.
push
(
this
);
this
.
impl
=
impl
;
this
.
callbacks
=
[];
this
.
options
=
options
;
var
call
;
if
(
options
===
"chain"
||
options
===
"pending"
)
{
call
=
"newFilterString"
}
else
if
(
typeof
options
===
"object"
)
{
call
=
"newFilter"
}
var
self
=
this
;
// Cheaper than binding
this
.
promise
=
new
Promise
(
function
(
resolve
,
reject
)
{
web3
.
provider
.
send
({
call
:
call
,
args
:
[
options
]},
function
(
id
)
{
self
.
id
=
id
;
web3
.
provider
.
startPolling
({
call
:
"changed"
,
args
:
[
id
]},
id
);
resolve
(
id
);
});
this
.
promise
=
impl
.
newFilter
(
options
);
this
.
promise
.
then
(
function
(
id
)
{
self
.
id
=
id
;
web3
.
provider
.
startPolling
({
call
:
'changed'
,
args
:
[
id
]},
id
);
});
};
...
...
@@ -386,21 +409,17 @@
};
Filter
.
prototype
.
uninstall
=
function
()
{
this
.
promise
.
then
(
function
(
id
)
{
web3
.
provider
.
send
({
call
:
"uninstallFilter"
,
args
:[
id
]});
var
self
=
this
;
this
.
promise
.
then
(
function
(
id
)
{
self
.
impl
.
uninstallFilter
(
id
);
web3
.
provider
.
stopPolling
(
id
);
});
};
Filter
.
prototype
.
messages
=
function
()
{
var
self
=
this
;
return
Promise
.
all
([
this
.
promise
]).
then
(
function
()
{
var
id
=
self
.
id
return
new
Promise
(
function
(
resolve
,
reject
)
{
web3
.
provider
.
send
({
call
:
"getMessages"
,
args
:
[
id
]},
function
(
messages
)
{
resolve
(
messages
);
});
});
var
self
=
this
;
return
this
.
promise
.
then
(
function
(
id
)
{
return
self
.
impl
.
getMessages
(
id
);
});
};
...
...
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