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
f3ce1f07
Commit
f3ce1f07
authored
Feb 03, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplified polling && jsonrpc payload creation
parent
ddc17196
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
90 deletions
+36
-90
ethereum.js
dist/ethereum.js
+15
-42
ethereum.js.map
dist/ethereum.js.map
+5
-5
ethereum.min.js
dist/ethereum.min.js
+1
-1
filter.js
lib/filter.js
+1
-1
httpsync.js
lib/httpsync.js
+2
-27
providermanager.js
lib/providermanager.js
+7
-9
web3.js
lib/web3.js
+5
-5
No files found.
dist/ethereum.js
View file @
f3ce1f07
...
...
@@ -683,7 +683,7 @@ var Filter = function(options, impl) {
this
.
callbacks
=
[];
this
.
id
=
impl
.
newFilter
(
options
);
web3
.
provider
.
startPolling
({
call
:
impl
.
changed
,
arg
s
:
[
this
.
id
]},
this
.
id
,
this
.
trigger
.
bind
(
this
));
web3
.
provider
.
startPolling
({
method
:
impl
.
changed
,
param
s
:
[
this
.
id
]},
this
.
id
,
this
.
trigger
.
bind
(
this
));
};
/// alias for changed*
...
...
@@ -916,37 +916,12 @@ var HttpSyncProvider = function (host) {
this
.
host
=
host
||
'http://localhost:8080'
;
};
/// Transforms inner message to proper jsonrpc object
/// @param inner message object
/// @returns jsonrpc object
function
formatJsonRpcObject
(
object
)
{
return
{
jsonrpc
:
'2.0'
,
method
:
object
.
call
,
params
:
object
.
args
,
id
:
object
.
_id
};
}
/// Transforms jsonrpc object to inner message
/// @param incoming jsonrpc message
/// @returns inner message object
function
formatJsonRpcMessage
(
message
)
{
var
object
=
JSON
.
parse
(
message
);
return
{
_id
:
object
.
id
,
data
:
object
.
result
,
error
:
object
.
error
};
}
HttpSyncProvider
.
prototype
.
send
=
function
(
payload
)
{
var
data
=
formatJsonRpcObject
(
payload
);
//
var data = formatJsonRpcObject(payload);
var
request
=
new
XMLHttpRequest
();
request
.
open
(
'POST'
,
this
.
host
,
false
);
request
.
send
(
JSON
.
stringify
(
data
));
request
.
send
(
JSON
.
stringify
(
payload
));
// check request.status
return
request
.
responseText
;
...
...
@@ -1001,18 +976,14 @@ var ProviderManager = function() {
var
poll
=
function
()
{
if
(
self
.
provider
)
{
self
.
polls
.
forEach
(
function
(
data
)
{
data
.
data
.
_id
=
self
.
id
;
self
.
id
++
;
var
result
=
self
.
provider
.
send
(
data
.
data
);
var
result
=
self
.
send
(
data
.
data
);
result
=
JSON
.
parse
(
result
);
// dont call the callback if result is not an array, or empty one
if
(
result
.
error
||
!
(
result
.
result
instanceof
Array
)
||
result
.
result
.
length
===
0
)
{
if
(
!
(
result
instanceof
Array
)
||
result
.
length
===
0
)
{
return
;
}
data
.
callback
(
result
.
result
);
data
.
callback
(
result
);
});
}
setTimeout
(
poll
,
1000
);
...
...
@@ -1021,10 +992,12 @@ var ProviderManager = function() {
};
/// sends outgoing requests
/// @params data - an object with at least 'method' property
ProviderManager
.
prototype
.
send
=
function
(
data
)
{
data
.
args
=
data
.
args
||
[];
data
.
_id
=
this
.
id
++
;
data
.
jsonrpc
=
'2.0'
;
data
.
params
=
data
.
params
||
[];
data
.
id
=
this
.
id
++
;
if
(
this
.
provider
===
undefined
)
{
console
.
error
(
'provider is not set'
);
...
...
@@ -1465,8 +1438,8 @@ var setupMethods = function (obj, methods) {
var
args
=
Array
.
prototype
.
slice
.
call
(
arguments
);
var
call
=
typeof
method
.
call
===
'function'
?
method
.
call
(
args
)
:
method
.
call
;
return
web3
.
provider
.
send
({
call
:
call
,
arg
s
:
args
method
:
call
,
param
s
:
args
});
};
});
...
...
@@ -1479,15 +1452,15 @@ var setupProperties = function (obj, properties) {
var
proto
=
{};
proto
.
get
=
function
()
{
return
web3
.
provider
.
send
({
call
:
property
.
getter
method
:
property
.
getter
});
};
if
(
property
.
setter
)
{
proto
.
set
=
function
(
val
)
{
return
web3
.
provider
.
send
({
call
:
property
.
setter
,
arg
s
:
[
val
]
method
:
property
.
setter
,
param
s
:
[
val
]
});
};
}
...
...
dist/ethereum.js.map
View file @
f3ce1f07
This diff is collapsed.
Click to expand it.
dist/ethereum.min.js
View file @
f3ce1f07
This diff is collapsed.
Click to expand it.
lib/filter.js
View file @
f3ce1f07
...
...
@@ -56,7 +56,7 @@ var Filter = function(options, impl) {
this
.
callbacks
=
[];
this
.
id
=
impl
.
newFilter
(
options
);
web3
.
provider
.
startPolling
({
call
:
impl
.
changed
,
arg
s
:
[
this
.
id
]},
this
.
id
,
this
.
trigger
.
bind
(
this
));
web3
.
provider
.
startPolling
({
method
:
impl
.
changed
,
param
s
:
[
this
.
id
]},
this
.
id
,
this
.
trigger
.
bind
(
this
));
};
/// alias for changed*
...
...
lib/httpsync.js
View file @
f3ce1f07
...
...
@@ -30,37 +30,12 @@ var HttpSyncProvider = function (host) {
this
.
host
=
host
||
'http://localhost:8080'
;
};
/// Transforms inner message to proper jsonrpc object
/// @param inner message object
/// @returns jsonrpc object
function
formatJsonRpcObject
(
object
)
{
return
{
jsonrpc
:
'2.0'
,
method
:
object
.
call
,
params
:
object
.
args
,
id
:
object
.
_id
};
}
/// Transforms jsonrpc object to inner message
/// @param incoming jsonrpc message
/// @returns inner message object
function
formatJsonRpcMessage
(
message
)
{
var
object
=
JSON
.
parse
(
message
);
return
{
_id
:
object
.
id
,
data
:
object
.
result
,
error
:
object
.
error
};
}
HttpSyncProvider
.
prototype
.
send
=
function
(
payload
)
{
var
data
=
formatJsonRpcObject
(
payload
);
//
var data = formatJsonRpcObject(payload);
var
request
=
new
XMLHttpRequest
();
request
.
open
(
'POST'
,
this
.
host
,
false
);
request
.
send
(
JSON
.
stringify
(
data
));
request
.
send
(
JSON
.
stringify
(
payload
));
// check request.status
return
request
.
responseText
;
...
...
lib/providermanager.js
View file @
f3ce1f07
...
...
@@ -43,18 +43,14 @@ var ProviderManager = function() {
var
poll
=
function
()
{
if
(
self
.
provider
)
{
self
.
polls
.
forEach
(
function
(
data
)
{
data
.
data
.
_id
=
self
.
id
;
self
.
id
++
;
var
result
=
self
.
provider
.
send
(
data
.
data
);
var
result
=
self
.
send
(
data
.
data
);
result
=
JSON
.
parse
(
result
);
// dont call the callback if result is not an array, or empty one
if
(
result
.
error
||
!
(
result
.
result
instanceof
Array
)
||
result
.
result
.
length
===
0
)
{
if
(
!
(
result
instanceof
Array
)
||
result
.
length
===
0
)
{
return
;
}
data
.
callback
(
result
.
result
);
data
.
callback
(
result
);
});
}
setTimeout
(
poll
,
1000
);
...
...
@@ -63,10 +59,12 @@ var ProviderManager = function() {
};
/// sends outgoing requests
/// @params data - an object with at least 'method' property
ProviderManager
.
prototype
.
send
=
function
(
data
)
{
data
.
args
=
data
.
args
||
[];
data
.
_id
=
this
.
id
++
;
data
.
jsonrpc
=
'2.0'
;
data
.
params
=
data
.
params
||
[];
data
.
id
=
this
.
id
++
;
if
(
this
.
provider
===
undefined
)
{
console
.
error
(
'provider is not set'
);
...
...
lib/web3.js
View file @
f3ce1f07
...
...
@@ -136,8 +136,8 @@ var setupMethods = function (obj, methods) {
var
args
=
Array
.
prototype
.
slice
.
call
(
arguments
);
var
call
=
typeof
method
.
call
===
'function'
?
method
.
call
(
args
)
:
method
.
call
;
return
web3
.
provider
.
send
({
call
:
call
,
arg
s
:
args
method
:
call
,
param
s
:
args
});
};
});
...
...
@@ -150,15 +150,15 @@ var setupProperties = function (obj, properties) {
var
proto
=
{};
proto
.
get
=
function
()
{
return
web3
.
provider
.
send
({
call
:
property
.
getter
method
:
property
.
getter
});
};
if
(
property
.
setter
)
{
proto
.
set
=
function
(
val
)
{
return
web3
.
provider
.
send
({
call
:
property
.
setter
,
arg
s
:
[
val
]
method
:
property
.
setter
,
param
s
:
[
val
]
});
};
}
...
...
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