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
Show 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,30 +25,30 @@
var
XMLHttpRequest
=
require
(
'xmlhttprequest'
).
XMLHttpRequest
;
// jshint ignore:line
var
HttpRpcProvider
=
function
(
host
)
{
var
HttpRpcProvider
=
function
(
host
)
{
this
.
handlers
=
[];
this
.
host
=
host
;
};
};
function
formatJsonRpcObject
(
object
)
{
function
formatJsonRpcObject
(
object
)
{
return
{
jsonrpc
:
'2.0'
,
method
:
object
.
call
,
params
:
object
.
args
,
id
:
object
.
_id
};
}
}
function
formatJsonRpcMessage
(
message
)
{
function
formatJsonRpcMessage
(
message
)
{
var
object
=
JSON
.
parse
(
message
);
return
{
_id
:
object
.
id
,
data
:
object
.
result
};
}
}
HttpRpcProvider
.
prototype
.
sendRequest
=
function
(
payload
,
cb
)
{
HttpRpcProvider
.
prototype
.
sendRequest
=
function
(
payload
,
cb
)
{
var
data
=
formatJsonRpcObject
(
payload
);
var
request
=
new
XMLHttpRequest
();
...
...
@@ -59,18 +59,18 @@ HttpRpcProvider.prototype.sendRequest = function (payload, cb) {
cb
(
request
);
}
};
};
};
HttpRpcProvider
.
prototype
.
send
=
function
(
payload
)
{
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
)
{
HttpRpcProvider
.
prototype
.
poll
=
function
(
payload
,
id
)
{
var
self
=
this
;
this
.
sendRequest
(
payload
,
function
(
request
)
{
var
parsed
=
JSON
.
parse
(
request
.
responseText
);
...
...
@@ -81,12 +81,12 @@ HttpRpcProvider.prototype.poll = function (payload, id) {
handler
.
call
(
self
,
{
_event
:
payload
.
call
,
_id
:
id
,
data
:
parsed
.
result
});
});
});
};
};
Object
.
defineProperty
(
HttpRpcProvider
.
prototype
,
"onmessage"
,
{
Object
.
defineProperty
(
HttpRpcProvider
.
prototype
,
"onmessage"
,
{
set
:
function
(
handler
)
{
this
.
handlers
.
push
(
handler
);
}
});
});
module
.
exports
=
HttpRpcProvider
;
lib/main.js
View file @
15088d7e
...
...
@@ -23,11 +23,11 @@ along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
function
isPromise
(
o
)
{
function
isPromise
(
o
)
{
return
o
instanceof
Promise
;
}
}
function
flattenPromise
(
obj
)
{
function
flattenPromise
(
obj
)
{
if
(
obj
instanceof
Promise
)
{
return
Promise
.
resolve
(
obj
);
}
...
...
@@ -64,9 +64,9 @@ function flattenPromise (obj) {
}
return
Promise
.
resolve
(
obj
);
}
}
var
ethMethods
=
function
()
{
var
ethMethods
=
function
()
{
var
blockCall
=
function
(
args
)
{
return
typeof
args
[
0
]
===
"string"
?
"blockByHash"
:
"blockByNumber"
;
};
...
...
@@ -92,9 +92,9 @@ var ethMethods = function () {
{
name
:
'compile'
,
call
:
'compile'
}
];
return
methods
;
};
};
var
ethProperties
=
function
()
{
var
ethProperties
=
function
()
{
return
[
{
name
:
'coinbase'
,
getter
:
'coinbase'
,
setter
:
'setCoinbase'
},
{
name
:
'listening'
,
getter
:
'listening'
,
setter
:
'setListening'
},
...
...
@@ -106,18 +106,18 @@ var ethProperties = function () {
{
name
:
'defaultBlock'
,
getter
:
'defaultBlock'
,
setter
:
'setDefaultBlock'
},
{
name
:
'number'
,
getter
:
'number'
}
];
};
};
var
dbMethods
=
function
()
{
var
dbMethods
=
function
()
{
return
[
{
name
:
'put'
,
call
:
'put'
},
{
name
:
'get'
,
call
:
'get'
},
{
name
:
'putString'
,
call
:
'putString'
},
{
name
:
'getString'
,
call
:
'getString'
}
];
};
};
var
shhMethods
=
function
()
{
var
shhMethods
=
function
()
{
return
[
{
name
:
'post'
,
call
:
'post'
},
{
name
:
'newIdentity'
,
call
:
'newIdentity'
},
...
...
@@ -125,9 +125,9 @@ var shhMethods = function () {
{
name
:
'newGroup'
,
call
:
'newGroup'
},
{
name
:
'addToGroup'
,
call
:
'addToGroup'
}
];
};
};
var
ethWatchMethods
=
function
()
{
var
ethWatchMethods
=
function
()
{
var
newFilter
=
function
(
args
)
{
return
typeof
args
[
0
]
===
'string'
?
'newFilterString'
:
'newFilter'
;
};
...
...
@@ -137,17 +137,17 @@ var ethWatchMethods = function () {
{
name
:
'uninstallFilter'
,
call
:
'uninstallFilter'
},
{
name
:
'getMessages'
,
call
:
'getMessages'
}
];
};
};
var
shhWatchMethods
=
function
()
{
var
shhWatchMethods
=
function
()
{
return
[
{
name
:
'newFilter'
,
call
:
'shhNewFilter'
},
{
name
:
'uninstallFilter'
,
call
:
'shhUninstallFilter'
},
{
name
:
'getMessage'
,
call
:
'shhGetMessages'
}
];
};
};
var
setupMethods
=
function
(
obj
,
methods
)
{
var
setupMethods
=
function
(
obj
,
methods
)
{
methods
.
forEach
(
function
(
method
)
{
obj
[
method
.
name
]
=
function
()
{
return
flattenPromise
(
Array
.
prototype
.
slice
.
call
(
arguments
)).
then
(
function
(
args
)
{
...
...
@@ -168,9 +168,9 @@ var setupMethods = function (obj, methods) {
});
};
});
};
};
var
setupProperties
=
function
(
obj
,
properties
)
{
var
setupProperties
=
function
(
obj
,
properties
)
{
properties
.
forEach
(
function
(
property
)
{
var
proto
=
{};
proto
.
get
=
function
()
{
...
...
@@ -199,9 +199,9 @@ var setupProperties = function (obj, properties) {
}
Object
.
defineProperty
(
obj
,
property
.
name
,
proto
);
});
};
};
var
web3
=
{
var
web3
=
{
_callbacks
:
{},
_events
:
{},
providers
:
{},
...
...
@@ -286,24 +286,24 @@ var web3 = {
var
cb
=
callbacks
[
id
];
cb
(
data
);
}
};
};
var
eth
=
web3
.
eth
;
setupMethods
(
eth
,
ethMethods
());
setupProperties
(
eth
,
ethProperties
());
setupMethods
(
web3
.
db
,
dbMethods
());
setupMethods
(
web3
.
shh
,
shhMethods
());
var
eth
=
web3
.
eth
;
setupMethods
(
eth
,
ethMethods
());
setupProperties
(
eth
,
ethProperties
());
setupMethods
(
web3
.
db
,
dbMethods
());
setupMethods
(
web3
.
shh
,
shhMethods
());
var
ethWatch
=
{
var
ethWatch
=
{
changed
:
'changed'
};
setupMethods
(
ethWatch
,
ethWatchMethods
());
var
shhWatch
=
{
};
setupMethods
(
ethWatch
,
ethWatchMethods
());
var
shhWatch
=
{
changed
:
'shhChanged'
};
setupMethods
(
shhWatch
,
shhWatchMethods
());
};
setupMethods
(
shhWatch
,
shhWatchMethods
());
var
ProviderManager
=
function
()
{
var
ProviderManager
=
function
()
{
this
.
queued
=
[];
this
.
polls
=
[];
this
.
ready
=
false
;
...
...
@@ -322,9 +322,9 @@ var ProviderManager = function() {
setTimeout
(
poll
,
12000
);
};
poll
();
};
};
ProviderManager
.
prototype
.
send
=
function
(
data
,
cb
)
{
ProviderManager
.
prototype
.
send
=
function
(
data
,
cb
)
{
data
.
_id
=
this
.
id
;
if
(
cb
)
{
web3
.
_callbacks
[
data
.
_id
]
=
cb
;
...
...
@@ -339,53 +339,53 @@ ProviderManager.prototype.send = function(data, cb) {
console
.
warn
(
"provider is not set"
);
this
.
queued
.
push
(
data
);
}
};
};
ProviderManager
.
prototype
.
set
=
function
(
provider
)
{
ProviderManager
.
prototype
.
set
=
function
(
provider
)
{
if
(
this
.
provider
!==
undefined
&&
this
.
provider
.
unload
!==
undefined
)
{
this
.
provider
.
unload
();
}
this
.
provider
=
provider
;
this
.
ready
=
true
;
};
};
ProviderManager
.
prototype
.
sendQueued
=
function
()
{
ProviderManager
.
prototype
.
sendQueued
=
function
()
{
for
(
var
i
=
0
;
this
.
queued
.
length
;
i
++
)
{
// Resend
this
.
send
(
this
.
queued
[
i
]);
}
};
};
ProviderManager
.
prototype
.
installed
=
function
()
{
ProviderManager
.
prototype
.
installed
=
function
()
{
return
this
.
provider
!==
undefined
;
};
};
ProviderManager
.
prototype
.
startPolling
=
function
(
data
,
pollId
)
{
ProviderManager
.
prototype
.
startPolling
=
function
(
data
,
pollId
)
{
if
(
!
this
.
provider
||
!
this
.
provider
.
poll
)
{
return
;
}
this
.
polls
.
push
({
data
:
data
,
id
:
pollId
});
};
};
ProviderManager
.
prototype
.
stopPolling
=
function
(
pollId
)
{
ProviderManager
.
prototype
.
stopPolling
=
function
(
pollId
)
{
for
(
var
i
=
this
.
polls
.
length
;
i
--
;)
{
var
poll
=
this
.
polls
[
i
];
if
(
poll
.
id
===
pollId
)
{
this
.
polls
.
splice
(
i
,
1
);
}
}
};
};
web3
.
provider
=
new
ProviderManager
();
web3
.
provider
=
new
ProviderManager
();
web3
.
setProvider
=
function
(
provider
)
{
web3
.
setProvider
=
function
(
provider
)
{
provider
.
onmessage
=
messageHandler
;
web3
.
provider
.
set
(
provider
);
web3
.
provider
.
sendQueued
();
};
};
var
Filter
=
function
(
options
,
impl
)
{
var
Filter
=
function
(
options
,
impl
)
{
this
.
impl
=
impl
;
this
.
callbacks
=
[];
...
...
@@ -396,42 +396,42 @@ var Filter = function(options, impl) {
web3
.
on
(
impl
.
changed
,
id
,
self
.
trigger
.
bind
(
self
));
web3
.
provider
.
startPolling
({
call
:
impl
.
changed
,
args
:
[
id
]},
id
);
});
};
};
Filter
.
prototype
.
arrived
=
function
(
callback
)
{
Filter
.
prototype
.
arrived
=
function
(
callback
)
{
this
.
changed
(
callback
);
};
};
Filter
.
prototype
.
changed
=
function
(
callback
)
{
Filter
.
prototype
.
changed
=
function
(
callback
)
{
var
self
=
this
;
this
.
promise
.
then
(
function
(
id
)
{
self
.
callbacks
.
push
(
callback
);
});
};
};
Filter
.
prototype
.
trigger
=
function
(
messages
)
{
Filter
.
prototype
.
trigger
=
function
(
messages
)
{
for
(
var
i
=
0
;
i
<
this
.
callbacks
.
length
;
i
++
)
{
this
.
callbacks
[
i
].
call
(
this
,
messages
);
}
};
};
Filter
.
prototype
.
uninstall
=
function
()
{
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
);
});
};
};
Filter
.
prototype
.
messages
=
function
()
{
Filter
.
prototype
.
messages
=
function
()
{
var
self
=
this
;
return
this
.
promise
.
then
(
function
(
id
)
{
return
self
.
impl
.
getMessages
(
id
);
});
};
};
function
messageHandler
(
data
)
{
function
messageHandler
(
data
)
{
if
(
data
.
_event
!==
undefined
)
{
web3
.
trigger
(
data
.
_event
,
data
.
_id
,
data
.
data
);
return
;
...
...
@@ -444,15 +444,7 @@ function messageHandler(data) {
delete
web3
.
_callbacks
[
data
.
_id
];
}
}
}
/*
// Install default provider
if(!web3.provider.installed()) {
var sock = new web3.providers.WebSocketProvider("ws://localhost:40404/eth");
}
web3.setProvider(sock);
}
*/
module
.
exports
=
web3
;
lib/qt.js
View file @
15088d7e
...
...
@@ -20,7 +20,7 @@
* @date 2014
*/
var
QtProvider
=
function
()
{
var
QtProvider
=
function
()
{
this
.
handlers
=
[];
var
self
=
this
;
...
...
@@ -29,16 +29,16 @@ var QtProvider = function() {
handler
.
call
(
self
,
JSON
.
parse
(
message
.
data
));
});
};
};
};
QtProvider
.
prototype
.
send
=
function
(
payload
)
{
QtProvider
.
prototype
.
send
=
function
(
payload
)
{
navigator
.
qt
.
postMessage
(
JSON
.
stringify
(
payload
));
};
};
Object
.
defineProperty
(
QtProvider
.
prototype
,
"onmessage"
,
{
Object
.
defineProperty
(
QtProvider
.
prototype
,
"onmessage"
,
{
set
:
function
(
handler
)
{
this
.
handlers
.
push
(
handler
);
}
});
});
module
.
exports
=
QtProvider
;
lib/websocket.js
View file @
15088d7e
...
...
@@ -24,7 +24,7 @@
var
WebSocket
=
require
(
'ws'
);
// jshint ignore:line
var
WebSocketProvider
=
function
(
host
)
{
var
WebSocketProvider
=
function
(
host
)
{
// onmessage handlers
this
.
handlers
=
[];
// queue will be filled with messages if send is invoked before the ws is ready
...
...
@@ -48,8 +48,8 @@ var WebSocketProvider = function(host) {
self
.
send
(
self
.
queued
[
i
]);
}
};
};
WebSocketProvider
.
prototype
.
send
=
function
(
payload
)
{
};
WebSocketProvider
.
prototype
.
send
=
function
(
payload
)
{
if
(
this
.
ready
)
{
var
data
=
JSON
.
stringify
(
payload
);
...
...
@@ -57,17 +57,17 @@ WebSocketProvider.prototype.send = function(payload) {
}
else
{
this
.
queued
.
push
(
payload
);
}
};
};
WebSocketProvider
.
prototype
.
onMessage
=
function
(
handler
)
{
WebSocketProvider
.
prototype
.
onMessage
=
function
(
handler
)
{
this
.
handlers
.
push
(
handler
);
};
};
WebSocketProvider
.
prototype
.
unload
=
function
()
{
WebSocketProvider
.
prototype
.
unload
=
function
()
{
this
.
ws
.
close
();
};
Object
.
defineProperty
(
WebSocketProvider
.
prototype
,
"onmessage"
,
{
};
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