pull/271/merge
obscuren 10 years ago
parent b1870631a4
commit 65158d39b0
  1. 2
      cmd/mist/assets/examples/abi.html
  2. 22
      cmd/mist/assets/examples/coin.html
  3. 5
      cmd/mist/assets/examples/info.html
  4. 1418
      cmd/mist/assets/ext/ethereum.js/dist/ethereum.js
  5. 13
      core/block_processor.go
  6. 3
      core/chain_manager.go
  7. 7
      core/filter.go
  8. 8
      core/types/common.go
  9. 2
      event/filter/old_filter.go
  10. 13
      miner/worker.go
  11. 4
      rpc/http/server.go
  12. 1
      rpc/message.go
  13. 5
      rpc/util.go

@ -21,7 +21,7 @@
}];
var address = web3.eth.transact({
data: "0x603880600c6000396000f3006001600060e060020a600035048063c6888fa114601857005b6021600435602b565b8060005260206000f35b600081600702905091905056",
gasprice: "1000000000000000",
gasPrice: "1000000000000000",
gas: "10000",
});
var contract = web3.eth.contract(address, desc);

@ -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,
"constant": 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 = "0x60056011565b60ae8060356000396000f35b64174876e800600033600160a060020a031660005260205260406000208190555056006001600060e060020a600035048063d0679d34146022578063e3d670d714603457005b602e6004356024356047565b60006000f35b603d600435608d565b8060005260206000f35b80600083600160a060020a0316600052602052604060002090815401908190555080600033600160a060020a031660005260205260406000209081540390819055505050565b6000600082600160a060020a0316600052602052604060002054905091905056";
var code = "0x60056011565b60b88060356000396000f35b64e8d4a51000600033600160a060020a0316600052602052604060002081905550560060e060020a6000350480637bb98a68146028578063d0679d34146034578063e3d670d714604657005b602e60b3565b60006000f35b60406004356024356059565b60006000f35b604f6004356091565b8060005260206000f35b8060005281600160a060020a03167fb52dda022b6c1a1f40905a85f257f689aa5d69d850e49cf939d688fbe5af594660206000a25050565b6000600082600160a060020a03166000526020526040600020549050919050565b5b60008156";
address = web3.eth.transact({
data: code,
gasprice: "1000000000000000",
gasPrice: "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);

@ -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;

File diff suppressed because it is too large Load Diff

@ -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,

@ -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

@ -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)
}

@ -1,11 +1,7 @@
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)
}

@ -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.Messages(nil))
events := self.eventMux.Subscribe(core.NewBlockEvent{}, state.Logs(nil))
out:
for {

@ -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

@ -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.DebugDetailln("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.DebugDetailf("Generated response: %T %s", response, response)
JSON.Send(w, &rpc.RpcSuccessResponse{JsonRpc: reqParsed.JsonRpc, ID: reqParsed.ID, Error: false, Result: response})
}

@ -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])

@ -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.Infof("Sending payload: %s", payload)
rpclogger.DebugDetailf("Sending payload: %s", payload)
return writer.Write(payload)
}

Loading…
Cancel
Save