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
9a8f45ee
Commit
9a8f45ee
authored
Jan 13, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Filter separated to filter.js file
parent
8b7d4b0c
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
224 additions
and
114 deletions
+224
-114
ethereum.js
dist/ethereum.js
+127
-54
ethereum.js.map
dist/ethereum.js.map
+4
-2
ethereum.min.js
dist/ethereum.min.js
+1
-1
filter.js
lib/filter.js
+89
-0
web3.js
lib/web3.js
+3
-57
No files found.
dist/ethereum.js
View file @
9a8f45ee
This diff is collapsed.
Click to expand it.
dist/ethereum.js.map
View file @
9a8f45ee
This diff is collapsed.
Click to expand it.
dist/ethereum.min.js
View file @
9a8f45ee
This diff is collapsed.
Click to expand it.
lib/filter.js
0 → 100644
View file @
9a8f45ee
/*
This file is part of ethereum.js.
ethereum.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethereum.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file filter.js
* @authors:
* Jeffrey Wilcke <jeff@ethdev.com>
* Marek Kotewicz <marek@ethdev.com>
* Marian Oancea <marian@ethdev.com>
* Gav Wood <g@ethdev.com>
* @date 2014
*/
// TODO: is these line is supposed to be here?
if
(
process
.
env
.
NODE_ENV
!==
'build'
)
{
var
web3
=
require
(
'./web3'
);
// jshint ignore:line
}
/// should be used when we want to watch something
/// it's using inner polling mechanism and is notified about changes
var
Filter
=
function
(
options
,
impl
)
{
this
.
impl
=
impl
;
this
.
callbacks
=
[];
var
self
=
this
;
this
.
promise
=
impl
.
newFilter
(
options
);
this
.
promise
.
then
(
function
(
id
)
{
self
.
id
=
id
;
web3
.
on
(
impl
.
changed
,
id
,
self
.
trigger
.
bind
(
self
));
web3
.
provider
.
startPolling
({
call
:
impl
.
changed
,
args
:
[
id
]},
id
);
});
};
/// alias for changed*
Filter
.
prototype
.
arrived
=
function
(
callback
)
{
this
.
changed
(
callback
);
};
/// gets called when there is new eth/shh message
Filter
.
prototype
.
changed
=
function
(
callback
)
{
var
self
=
this
;
this
.
promise
.
then
(
function
(
id
)
{
self
.
callbacks
.
push
(
callback
);
});
};
/// trigger calling new message from people
Filter
.
prototype
.
trigger
=
function
(
messages
)
{
for
(
var
i
=
0
;
i
<
this
.
callbacks
.
length
;
i
++
)
{
this
.
callbacks
[
i
].
call
(
this
,
messages
);
}
};
/// should be called to uninstall current filter
Filter
.
prototype
.
uninstall
=
function
()
{
var
self
=
this
;
this
.
promise
.
then
(
function
(
id
)
{
self
.
impl
.
uninstallFilter
(
id
);
web3
.
provider
.
stopPolling
(
id
);
web3
.
off
(
impl
.
changed
,
id
);
});
};
/// should be called to manually trigger getting latest messages from the client
Filter
.
prototype
.
messages
=
function
()
{
var
self
=
this
;
return
this
.
promise
.
then
(
function
(
id
)
{
return
self
.
impl
.
getMessages
(
id
);
});
};
/// alias for messages
Filter
.
prototype
.
logs
=
function
()
{
return
this
.
messages
();
};
module
.
exports
=
Filter
;
lib/web3.js
View file @
9a8f45ee
...
...
@@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file
main
.js
/** @file
web3
.js
* @authors:
* Jeffrey Wilcke <jeff@ethdev.com>
* Marek Kotewicz <marek@ethdev.com>
...
...
@@ -23,6 +23,8 @@
* @date 2014
*/
var
Filter
=
require
(
'./filter'
);
/// Recursively resolves all promises in given object and replaces the resolved values with promises
/// @param any object/array/promise/anything else..
/// @returns (resolves) object with replaced promises with their result
...
...
@@ -467,63 +469,7 @@ web3.haveProvider = function() {
return
!!
web3
.
provider
.
provider
;
};
/// should be used when we want to watch something
/// it's using inner polling mechanism and is notified about changes
var
Filter
=
function
(
options
,
impl
)
{
this
.
impl
=
impl
;
this
.
callbacks
=
[];
var
self
=
this
;
this
.
promise
=
impl
.
newFilter
(
options
);
this
.
promise
.
then
(
function
(
id
)
{
self
.
id
=
id
;
web3
.
on
(
impl
.
changed
,
id
,
self
.
trigger
.
bind
(
self
));
web3
.
provider
.
startPolling
({
call
:
impl
.
changed
,
args
:
[
id
]},
id
);
});
};
/// alias for changed*
Filter
.
prototype
.
arrived
=
function
(
callback
)
{
this
.
changed
(
callback
);
};
/// gets called when there is new eth/shh message
Filter
.
prototype
.
changed
=
function
(
callback
)
{
var
self
=
this
;
this
.
promise
.
then
(
function
(
id
)
{
self
.
callbacks
.
push
(
callback
);
});
};
/// trigger calling new message from people
Filter
.
prototype
.
trigger
=
function
(
messages
)
{
for
(
var
i
=
0
;
i
<
this
.
callbacks
.
length
;
i
++
)
{
this
.
callbacks
[
i
].
call
(
this
,
messages
);
}
};
/// should be called to uninstall current filter
Filter
.
prototype
.
uninstall
=
function
()
{
var
self
=
this
;
this
.
promise
.
then
(
function
(
id
)
{
self
.
impl
.
uninstallFilter
(
id
);
web3
.
provider
.
stopPolling
(
id
);
web3
.
off
(
impl
.
changed
,
id
);
});
};
/// should be called to manually trigger getting latest messages from the client
Filter
.
prototype
.
messages
=
function
()
{
var
self
=
this
;
return
this
.
promise
.
then
(
function
(
id
)
{
return
self
.
impl
.
getMessages
(
id
);
});
};
/// alias for messages
Filter
.
prototype
.
logs
=
function
()
{
return
this
.
messages
();
};
/// callled when there is new incoming message
function
messageHandler
(
data
)
{
...
...
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