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
15088d7e
Commit
15088d7e
authored
Nov 05, 2014
by
Marian Oancea
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed indent
Fixed indent so we can compare differences in PR.
parent
4be4db5e
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
946 additions
and
962 deletions
+946
-962
ethereum.js
dist/ethereum.js
+475
-483
httprpc.js
lib/httprpc.js
+53
-53
main.js
lib/main.js
+364
-372
qt.js
lib/qt.js
+17
-17
websocket.js
lib/websocket.js
+37
-37
No files found.
dist/ethereum.js
View file @
15088d7e
This diff is collapsed.
Click to expand it.
lib/httprpc.js
View file @
15088d7e
...
...
@@ -25,68 +25,68 @@
var
XMLHttpRequest
=
require
(
'xmlhttprequest'
).
XMLHttpRequest
;
// jshint ignore:line
var
HttpRpcProvider
=
function
(
host
)
{
this
.
handlers
=
[];
this
.
host
=
host
;
};
function
formatJsonRpcObject
(
object
)
{
return
{
jsonrpc
:
'2.0'
,
method
:
object
.
call
,
params
:
object
.
args
,
id
:
object
.
_id
var
HttpRpcProvider
=
function
(
host
)
{
this
.
handlers
=
[];
this
.
host
=
host
;
};
}
function
formatJsonRpcMessage
(
message
)
{
var
object
=
JSON
.
parse
(
message
);
function
formatJsonRpcObject
(
object
)
{
return
{
jsonrpc
:
'2.0'
,
method
:
object
.
call
,
params
:
object
.
args
,
id
:
object
.
_id
};
}
return
{
_id
:
object
.
id
,
data
:
object
.
result
};
}
function
formatJsonRpcMessage
(
message
)
{
var
object
=
JSON
.
parse
(
message
);
HttpRpcProvider
.
prototype
.
sendRequest
=
function
(
payload
,
cb
)
{
var
data
=
formatJsonRpcObject
(
payload
);
return
{
_id
:
object
.
id
,
data
:
object
.
result
};
}
var
request
=
new
XMLHttpRequest
();
request
.
open
(
"POST"
,
this
.
host
,
true
);
request
.
send
(
JSON
.
stringify
(
data
));
request
.
onreadystatechange
=
function
()
{
if
(
request
.
readyState
===
4
&&
cb
)
{
cb
(
request
);
}
HttpRpcProvider
.
prototype
.
sendRequest
=
function
(
payload
,
cb
)
{
var
data
=
formatJsonRpcObject
(
payload
);
var
request
=
new
XMLHttpRequest
();
request
.
open
(
"POST"
,
this
.
host
,
true
);
request
.
send
(
JSON
.
stringify
(
data
));
request
.
onreadystatechange
=
function
()
{
if
(
request
.
readyState
===
4
&&
cb
)
{
cb
(
request
);
}
};
};
};
HttpRpcProvider
.
prototype
.
send
=
function
(
payload
)
{
var
self
=
this
;
this
.
sendRequest
(
payload
,
function
(
request
)
{
self
.
handlers
.
forEach
(
function
(
handler
)
{
handler
.
call
(
self
,
formatJsonRpcMessage
(
request
.
responseText
));
HttpRpcProvider
.
prototype
.
send
=
function
(
payload
)
{
var
self
=
this
;
this
.
sendRequest
(
payload
,
function
(
request
)
{
self
.
handlers
.
forEach
(
function
(
handler
)
{
handler
.
call
(
self
,
formatJsonRpcMessage
(
request
.
responseText
));
});
});
}
)
;
};
HttpRpcProvider
.
prototype
.
poll
=
function
(
payload
,
id
)
{
var
self
=
this
;
this
.
sendRequest
(
payload
,
function
(
request
)
{
var
parsed
=
JSON
.
parse
(
request
.
responseText
);
if
(
parsed
.
result
instanceof
Array
?
parsed
.
result
.
length
===
0
:
!
parsed
.
result
)
{
return
;
}
self
.
handlers
.
forEach
(
function
(
handler
)
{
handler
.
call
(
self
,
{
_event
:
payload
.
call
,
_id
:
id
,
data
:
parsed
.
result
});
};
HttpRpcProvider
.
prototype
.
poll
=
function
(
payload
,
id
)
{
var
self
=
this
;
this
.
sendRequest
(
payload
,
function
(
request
)
{
var
parsed
=
JSON
.
parse
(
request
.
responseText
);
if
(
parsed
.
result
instanceof
Array
?
parsed
.
result
.
length
===
0
:
!
parsed
.
result
)
{
return
;
}
self
.
handlers
.
forEach
(
function
(
handler
)
{
handler
.
call
(
self
,
{
_event
:
payload
.
call
,
_id
:
id
,
data
:
parsed
.
result
});
});
});
});
};
};
Object
.
defineProperty
(
HttpRpcProvider
.
prototype
,
"onmessage"
,
{
set
:
function
(
handler
)
{
this
.
handlers
.
push
(
handler
);
}
});
Object
.
defineProperty
(
HttpRpcProvider
.
prototype
,
"onmessage"
,
{
set
:
function
(
handler
)
{
this
.
handlers
.
push
(
handler
);
}
});
module
.
exports
=
HttpRpcProvider
;
lib/main.js
View file @
15088d7e
This diff is collapsed.
Click to expand it.
lib/qt.js
View file @
15088d7e
...
...
@@ -20,25 +20,25 @@
* @date 2014
*/
var
QtProvider
=
function
()
{
this
.
handlers
=
[];
var
self
=
this
;
navigator
.
qt
.
onmessage
=
function
(
message
)
{
self
.
handlers
.
forEach
(
function
(
handler
)
{
handler
.
call
(
self
,
JSON
.
parse
(
message
.
data
));
});
var
QtProvider
=
function
()
{
this
.
handlers
=
[];
var
self
=
this
;
navigator
.
qt
.
onmessage
=
function
(
message
)
{
self
.
handlers
.
forEach
(
function
(
handler
)
{
handler
.
call
(
self
,
JSON
.
parse
(
message
.
data
));
});
};
};
};
QtProvider
.
prototype
.
send
=
function
(
payload
)
{
navigator
.
qt
.
postMessage
(
JSON
.
stringify
(
payload
));
};
QtProvider
.
prototype
.
send
=
function
(
payload
)
{
navigator
.
qt
.
postMessage
(
JSON
.
stringify
(
payload
));
};
Object
.
defineProperty
(
QtProvider
.
prototype
,
"onmessage"
,
{
set
:
function
(
handler
)
{
this
.
handlers
.
push
(
handler
);
}
});
Object
.
defineProperty
(
QtProvider
.
prototype
,
"onmessage"
,
{
set
:
function
(
handler
)
{
this
.
handlers
.
push
(
handler
);
}
});
module
.
exports
=
QtProvider
;
lib/websocket.js
View file @
15088d7e
...
...
@@ -24,50 +24,50 @@
var
WebSocket
=
require
(
'ws'
);
// jshint ignore:line
var
WebSocketProvider
=
function
(
host
)
{
// onmessage handlers
this
.
handlers
=
[];
// queue will be filled with messages if send is invoked before the ws is ready
this
.
queued
=
[];
this
.
ready
=
false
;
var
WebSocketProvider
=
function
(
host
)
{
// onmessage handlers
this
.
handlers
=
[];
// queue will be filled with messages if send is invoked before the ws is ready
this
.
queued
=
[];
this
.
ready
=
false
;
this
.
ws
=
new
WebSocket
(
host
);
this
.
ws
=
new
WebSocket
(
host
);
var
self
=
this
;
this
.
ws
.
onmessage
=
function
(
event
)
{
for
(
var
i
=
0
;
i
<
self
.
handlers
.
length
;
i
++
)
{
self
.
handlers
[
i
].
call
(
self
,
JSON
.
parse
(
event
.
data
),
event
);
}
};
var
self
=
this
;
this
.
ws
.
onmessage
=
function
(
event
)
{
for
(
var
i
=
0
;
i
<
self
.
handlers
.
length
;
i
++
)
{
self
.
handlers
[
i
].
call
(
self
,
JSON
.
parse
(
event
.
data
),
event
);
}
};
this
.
ws
.
onopen
=
function
()
{
self
.
ready
=
true
;
this
.
ws
.
onopen
=
function
()
{
self
.
ready
=
true
;
for
(
var
i
=
0
;
i
<
self
.
queued
.
length
;
i
++
)
{
// Resend
self
.
send
(
self
.
queued
[
i
]);
}
for
(
var
i
=
0
;
i
<
self
.
queued
.
length
;
i
++
)
{
// Resend
self
.
send
(
self
.
queued
[
i
]);
}
};
};
};
WebSocketProvider
.
prototype
.
send
=
function
(
payload
)
{
if
(
this
.
ready
)
{
var
data
=
JSON
.
stringify
(
payload
);
WebSocketProvider
.
prototype
.
send
=
function
(
payload
)
{
if
(
this
.
ready
)
{
var
data
=
JSON
.
stringify
(
payload
);
this
.
ws
.
send
(
data
);
}
else
{
this
.
queued
.
push
(
payload
);
}
};
this
.
ws
.
send
(
data
);
}
else
{
this
.
queued
.
push
(
payload
);
}
};
WebSocketProvider
.
prototype
.
onMessage
=
function
(
handler
)
{
this
.
handlers
.
push
(
handler
);
};
WebSocketProvider
.
prototype
.
onMessage
=
function
(
handler
)
{
this
.
handlers
.
push
(
handler
);
};
WebSocketProvider
.
prototype
.
unload
=
function
()
{
this
.
ws
.
close
();
};
Object
.
defineProperty
(
WebSocketProvider
.
prototype
,
"onmessage"
,
{
set
:
function
(
provider
)
{
this
.
onMessage
(
provider
);
}
});
WebSocketProvider
.
prototype
.
unload
=
function
()
{
this
.
ws
.
close
();
};
Object
.
defineProperty
(
WebSocketProvider
.
prototype
,
"onmessage"
,
{
set
:
function
(
provider
)
{
this
.
onMessage
(
provider
);
}
});
module
.
exports
=
WebSocketProvider
;
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