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
65158d39
Commit
65158d39
authored
Feb 04, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Filtering
parent
b1870631
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
1044 additions
and
559 deletions
+1044
-559
abi.html
cmd/mist/assets/examples/abi.html
+1
-1
coin.html
cmd/mist/assets/examples/coin.html
+17
-5
info.html
cmd/mist/assets/examples/info.html
+5
-0
ethereum.js
cmd/mist/assets/ext/ethereum.js/dist/ethereum.js
+988
-530
block_processor.go
core/block_processor.go
+7
-6
chain_manager.go
core/chain_manager.go
+1
-2
filter.go
core/filter.go
+7
-0
common.go
core/types/common.go
+2
-6
old_filter.go
event/filter/old_filter.go
+1
-1
worker.go
miner/worker.go
+9
-4
server.go
rpc/http/server.go
+2
-2
message.go
rpc/message.go
+1
-0
util.go
rpc/util.go
+3
-2
No files found.
cmd/mist/assets/examples/abi.html
View file @
65158d39
...
...
@@ -21,7 +21,7 @@
}];
var
address
=
web3
.
eth
.
transact
({
data
:
"0x603880600c6000396000f3006001600060e060020a600035048063c6888fa114601857005b6021600435602b565b8060005260206000f35b600081600702905091905056"
,
gas
p
rice
:
"1000000000000000"
,
gas
P
rice
:
"1000000000000000"
,
gas
:
"10000"
,
});
var
contract
=
web3
.
eth
.
contract
(
address
,
desc
);
...
...
cmd/mist/assets/examples/coin.html
View file @
65158d39
...
...
@@ -32,17 +32,19 @@
web3
.
setProvider
(
new
web3
.
providers
.
HttpSyncProvider
(
'http://localhost:8080'
));
var
desc
=
[{
"name"
:
"balance(address)"
,
"type"
:
"function"
,
"inputs"
:
[{
"name"
:
"who"
,
"type"
:
"address"
}],
"const"
:
true
,
"const
ant
"
:
true
,
"outputs"
:
[{
"name"
:
"value"
,
"type"
:
"uint256"
}]
},
{
"name"
:
"send(address,uint256)"
,
"type"
:
"function"
,
"inputs"
:
[{
"name"
:
"to"
,
"type"
:
"address"
...
...
@@ -51,21 +53,31 @@
"type"
:
"uint256"
}],
"outputs"
:
[]
},
{
"name"
:
"Changed"
,
"type"
:
"event"
,
"inputs"
:
[
{
"name"
:
"to"
,
"type"
:
"address"
,
"indexed"
:
false
},
{
"name"
:
"amount"
,
"type"
:
"uint256"
,
"indexed"
:
true
},
],
}];
var
address
=
web3
.
db
.
get
(
"jevcoin"
,
"address"
);
var
address
=
""
;
//
web3.db.get("jevcoin", "address");
if
(
address
.
length
==
0
)
{
var
code
=
"0x60056011565b60
ae8060356000396000f35b64174876e800600033600160a060020a031660005260205260406000208190555056006001600060e060020a600035048063d0679d34146022578063e3d670d714603457005b602e6004356024356047565b60006000f35b603d600435608d565b8060005260206000f35b80600083600160a060020a0316600052602052604060002090815401908190555080600033600160a060020a031660005260205260406000209081540390819055505050565b6000600082600160a060020a03166000526020526040600020549050919050
56"
;
var
code
=
"0x60056011565b60
b88060356000396000f35b64e8d4a51000600033600160a060020a0316600052602052604060002081905550560060e060020a6000350480637bb98a68146028578063d0679d34146034578063e3d670d714604657005b602e60b3565b60006000f35b60406004356024356059565b60006000f35b604f6004356091565b8060005260206000f35b8060005281600160a060020a03167fb52dda022b6c1a1f40905a85f257f689aa5d69d850e49cf939d688fbe5af594660206000a25050565b6000600082600160a060020a03166000526020526040600020549050919050565b5b600081
56"
;
address
=
web3
.
eth
.
transact
({
data
:
code
,
gas
p
rice
:
"1000000000000000"
,
gas
P
rice
:
"1000000000000000"
,
gas
:
"10000"
,
});
web3
.
db
.
put
(
"jevcoin"
,
"address"
,
address
);
}
var
contract
=
web3
.
eth
.
contract
(
address
,
desc
);
contract
.
Changed
({
to
:
"0xaabb"
}).
changed
(
function
(
e
)
{
console
.
log
(
"e: "
+
JSON
.
stringify
(
e
));
});
contract
.
transact
({
gas
:
"10000"
,
gasprice
:
eth
.
gasPrice
}).
send
(
"0xaa"
,
10000
);
function
reflesh
()
{
document
.
querySelector
(
"#balance"
).
innerHTML
=
contract
.
call
().
balance
(
eth
.
coinbase
);
...
...
cmd/mist/assets/examples/info.html
View file @
65158d39
...
...
@@ -30,6 +30,10 @@
<td
id=
"accounts"
></td>
</tr>
<tr>
<td>
Balance
</td>
<td
id=
"balance"
></td>
<tr>
<td>
Gas price
</td>
<td
id=
"gas_price"
></td>
...
...
@@ -63,6 +67,7 @@
document
.
querySelector
(
"#peer_count"
).
innerHTML
=
eth
.
peerCount
;
document
.
querySelector
(
"#default_block"
).
innerHTML
=
eth
.
defaultBlock
;
document
.
querySelector
(
"#accounts"
).
innerHTML
=
eth
.
accounts
;
document
.
querySelector
(
"#balance"
).
innerHTML
=
web3
.
toEth
(
eth
.
balanceAt
(
eth
.
accounts
[
0
]));
document
.
querySelector
(
"#gas_price"
).
innerHTML
=
eth
.
gasPrice
;
document
.
querySelector
(
"#mining"
).
innerHTML
=
eth
.
mining
;
document
.
querySelector
(
"#listening"
).
innerHTML
=
eth
.
listening
;
...
...
cmd/mist/assets/ext/ethereum.js/dist/ethereum.js
View file @
65158d39
This diff is collapsed.
Click to expand it.
core/block_processor.go
View file @
65158d39
...
...
@@ -110,6 +110,8 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, state
go
self
.
eventMux
.
Post
(
TxPostEvent
{
tx
})
}
go
self
.
eventMux
.
Post
(
state
.
Logs
())
return
receipt
,
txGas
,
err
}
...
...
@@ -155,25 +157,25 @@ done:
return
receipts
,
handled
,
unhandled
,
erroneous
,
err
}
func
(
sm
*
BlockProcessor
)
Process
(
block
*
types
.
Block
)
(
td
*
big
.
Int
,
msgs
state
.
Messages
,
err
error
)
{
func
(
sm
*
BlockProcessor
)
Process
(
block
*
types
.
Block
)
(
td
*
big
.
Int
,
err
error
)
{
// Processing a blocks may never happen simultaneously
sm
.
mutex
.
Lock
()
defer
sm
.
mutex
.
Unlock
()
header
:=
block
.
Header
()
if
sm
.
bc
.
HasBlock
(
header
.
Hash
())
{
return
nil
,
nil
,
&
KnownBlockError
{
header
.
Number
,
header
.
Hash
()}
return
nil
,
&
KnownBlockError
{
header
.
Number
,
header
.
Hash
()}
}
if
!
sm
.
bc
.
HasBlock
(
header
.
ParentHash
)
{
return
nil
,
nil
,
ParentError
(
header
.
ParentHash
)
return
nil
,
ParentError
(
header
.
ParentHash
)
}
parent
:=
sm
.
bc
.
GetBlock
(
header
.
ParentHash
)
return
sm
.
ProcessWithParent
(
block
,
parent
)
}
func
(
sm
*
BlockProcessor
)
ProcessWithParent
(
block
,
parent
*
types
.
Block
)
(
td
*
big
.
Int
,
messages
state
.
Messages
,
err
error
)
{
func
(
sm
*
BlockProcessor
)
ProcessWithParent
(
block
,
parent
*
types
.
Block
)
(
td
*
big
.
Int
,
err
error
)
{
sm
.
lastAttemptedBlock
=
block
state
:=
state
.
New
(
parent
.
Root
(),
sm
.
db
)
...
...
@@ -227,7 +229,6 @@ func (sm *BlockProcessor) ProcessWithParent(block, parent *types.Block) (td *big
state
.
Sync
()
// Set the block hashes for the current messages
state
.
Manifest
()
.
SetHash
(
block
.
Hash
())
messages
=
state
.
Manifest
()
.
Messages
// Reset the manifest XXX We need this?
state
.
Manifest
()
.
Reset
()
// Remove transactions from the pool
...
...
@@ -235,7 +236,7 @@ func (sm *BlockProcessor) ProcessWithParent(block, parent *types.Block) (td *big
chainlogger
.
Infof
(
"processed block #%d (%x...)
\n
"
,
header
.
Number
,
block
.
Hash
()[
0
:
4
])
return
td
,
messages
,
nil
return
td
,
nil
}
// Validates the current block. Returns an error if the block was invalid,
...
...
core/chain_manager.go
View file @
65158d39
...
...
@@ -359,7 +359,7 @@ func (bc *ChainManager) Stop() {
func
(
self
*
ChainManager
)
InsertChain
(
chain
types
.
Blocks
)
error
{
for
_
,
block
:=
range
chain
{
td
,
messages
,
err
:=
self
.
processor
.
Process
(
block
)
td
,
err
:=
self
.
processor
.
Process
(
block
)
if
err
!=
nil
{
if
IsKnownBlockErr
(
err
)
{
continue
...
...
@@ -391,7 +391,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
self
.
mu
.
Unlock
()
self
.
eventMux
.
Post
(
NewBlockEvent
{
block
})
self
.
eventMux
.
Post
(
messages
)
}
return
nil
...
...
core/filter.go
View file @
65158d39
...
...
@@ -2,6 +2,7 @@ package core
import
(
"bytes"
"fmt"
"math"
"github.com/ethereum/go-ethereum/core/types"
...
...
@@ -130,6 +131,7 @@ func (self *Filter) Find() state.Logs {
func
includes
(
addresses
[][]
byte
,
a
[]
byte
)
(
found
bool
)
{
for
_
,
addr
:=
range
addresses
{
fmt
.
Println
(
"INCLUDES"
,
addr
,
a
)
if
bytes
.
Compare
(
addr
,
a
)
==
0
{
return
true
}
...
...
@@ -139,20 +141,25 @@ func includes(addresses [][]byte, a []byte) (found bool) {
}
func
(
self
*
Filter
)
FilterLogs
(
logs
state
.
Logs
)
state
.
Logs
{
fmt
.
Println
(
"FILTER LOGS"
,
self
.
topics
)
var
ret
state
.
Logs
// Filter the logs for interesting stuff
for
_
,
log
:=
range
logs
{
fmt
.
Println
(
log
)
if
len
(
self
.
address
)
>
0
&&
!
bytes
.
Equal
(
self
.
address
,
log
.
Address
())
{
continue
}
for
_
,
topic
:=
range
self
.
topics
{
fmt
.
Println
(
"TOPIC:"
,
topic
)
if
!
includes
(
log
.
Topics
(),
topic
)
{
continue
}
}
fmt
.
Println
(
"APPENDED"
)
ret
=
append
(
ret
,
log
)
}
...
...
core/types/common.go
View file @
65158d39
package
types
import
(
"math/big"
"github.com/ethereum/go-ethereum/state"
)
import
"math/big"
type
BlockProcessor
interface
{
Process
(
*
Block
)
(
*
big
.
Int
,
state
.
Messages
,
error
)
Process
(
*
Block
)
(
*
big
.
Int
,
error
)
}
event/filter/old_filter.go
View file @
65158d39
...
...
@@ -59,7 +59,7 @@ func (self *FilterManager) GetFilter(id int) *core.Filter {
func
(
self
*
FilterManager
)
filterLoop
()
{
// Subscribe to events
events
:=
self
.
eventMux
.
Subscribe
(
core
.
NewBlockEvent
{},
state
.
Message
s
(
nil
))
events
:=
self
.
eventMux
.
Subscribe
(
core
.
NewBlockEvent
{},
state
.
Log
s
(
nil
))
out
:
for
{
...
...
miner/worker.go
View file @
65158d39
...
...
@@ -41,6 +41,10 @@ func env(block *types.Block, eth *eth.Ethereum) *environment {
return
env
}
type
Agent
interface
{
Comms
()
chan
<-
*
types
.
Block
}
type
worker
struct
{
agents
[]
chan
<-
*
types
.
Block
mux
*
event
.
TypeMux
...
...
@@ -68,11 +72,12 @@ out:
case
event
:=
<-
events
.
Chan
()
:
switch
event
:=
event
.
(
type
)
{
case
core
.
NewBlockEvent
:
block
:=
event
.
Block
if
self
.
eth
.
ChainManager
()
.
HasBlock
(
block
.
Hash
())
{
}
else
if
true
{
if
self
.
eth
.
ChainManager
()
.
HasBlock
(
event
.
Block
.
Hash
())
{
}
case
core
.
TxPreEvent
:
if
err
:=
self
.
commitTransaction
(
event
.
Tx
);
err
!=
nil
{
self
.
commit
()
}
case
core
.
TxPreEvent
,
*
LocalTx
:
}
case
<-
self
.
quit
:
break
out
...
...
rpc/http/server.go
View file @
65158d39
...
...
@@ -87,7 +87,7 @@ func (s *RpcHttpServer) apiHandler(api *rpc.EthereumApi) http.Handler {
fn
:=
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
w
.
Header
()
.
Set
(
"Access-Control-Allow-Origin"
,
"*"
)
rpchttplogger
.
Debugln
(
"Handling request"
)
rpchttplogger
.
Debug
Detail
ln
(
"Handling request"
)
reqParsed
,
reqerr
:=
JSON
.
ParseRequestBody
(
req
)
if
reqerr
!=
nil
{
...
...
@@ -103,7 +103,7 @@ func (s *RpcHttpServer) apiHandler(api *rpc.EthereumApi) http.Handler {
return
}
rpchttplogger
.
Debugf
(
"Generated response: %T %s"
,
response
,
response
)
rpchttplogger
.
Debug
Detail
f
(
"Generated response: %T %s"
,
response
,
response
)
JSON
.
Send
(
w
,
&
rpc
.
RpcSuccessResponse
{
JsonRpc
:
reqParsed
.
JsonRpc
,
ID
:
reqParsed
.
ID
,
Error
:
false
,
Result
:
response
})
}
...
...
rpc/message.go
View file @
65158d39
...
...
@@ -206,6 +206,7 @@ func (req *RpcRequest) ToFilterArgs() (*FilterOptions, error) {
if
len
(
req
.
Params
)
<
1
{
return
nil
,
NewErrorResponse
(
ErrorArguments
)
}
fmt
.
Println
(
"filter params"
,
req
.
Params
)
args
:=
new
(
FilterOptions
)
r
:=
bytes
.
NewReader
(
req
.
Params
[
0
])
...
...
rpc/util.go
View file @
65158d39
...
...
@@ -18,10 +18,11 @@ package rpc
import
(
"encoding/json"
"github.com/ethereum/go-ethereum/logger"
"io"
"net/http"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/state"
)
...
...
@@ -36,7 +37,7 @@ func (self JsonWrapper) Send(writer io.Writer, v interface{}) (n int, err error)
rpclogger
.
Fatalln
(
"Error marshalling JSON"
,
err
)
return
0
,
err
}
rpclogger
.
Info
f
(
"Sending payload: %s"
,
payload
)
rpclogger
.
DebugDetail
f
(
"Sending payload: %s"
,
payload
)
return
writer
.
Write
(
payload
)
}
...
...
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