Merge pull request #800 from obscuren/ethereum_js_update

Ethereum js update
This commit is contained in:
Jeffrey Wilcke 2015-04-24 04:34:51 -07:00
commit 31811365e0
7 changed files with 8 additions and 13 deletions

2
.gitignore vendored

@ -23,8 +23,6 @@ Godeps/_workspace/bin
.project
.settings
mist
cmd/mist/mist
deploy/osx/Mist.app
deploy/osx/Mist\ Installer.dmg

2
.gitmodules vendored

@ -1,3 +1,3 @@
[submodule "cmd/mist/assets/ext/ethereum.js"]
path = cmd/mist/assets/ext/ethereum.js
url = https://github.com/ethereum/ethereum.js
url = https://github.com/ethereum/web3.js

@ -118,7 +118,7 @@ func (js *jsre) apiBindings() {
utils.Fatalf("Error loading ethereum.js: %v", err)
}
_, err = js.re.Eval("var web3 = require('ethereum.js');")
_, err = js.re.Eval("var web3 = require('web3');")
if err != nil {
utils.Fatalf("Error requiring web3: %v", err)
}

@ -3,7 +3,7 @@
<title>JevCoin</title>
<head>
<script type="text/javascript" src="../ext/bignumber.min.js"></script>
<script type="text/javascript" src="../ext/ethereum.js/dist/ethereum-light.min.js"></script>
<script type="text/javascript" src="../ext/ethereum.js/dist/web3-light.min.js"></script>
</head>
<body>
@ -32,7 +32,6 @@
</body>
<script type="text/javascript">
var web3 = require('ethereum.js');
var eth = web3.eth;
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));

@ -1 +1 @@
Subproject commit c80ede50c3b60a482f1ec76038325ec52f5e73b0
Subproject commit f8a43eddfb450d0e0ba1669a6916babe0ea43642

@ -276,7 +276,7 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
return errResp(ErrDecode, "block validation %v: %v", msg, err)
}
hash := request.Block.Hash()
// Add the block hash as a known hash to the peer. This will later be used to detirmine
// Add the block hash as a known hash to the peer. This will later be used to determine
// who should receive this.
p.blockHashes.Add(hash)
@ -296,7 +296,6 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
if self.chainman.HasBlock(hash) {
break
}
/* XXX unsure about this */
if self.chainman.Td().Cmp(request.TD) > 0 && new(big.Int).Add(request.Block.Number(), big.NewInt(7)).Cmp(self.chainman.CurrentBlock().Number()) < 0 {
glog.V(logger.Debug).Infof("[%s] dropped block %v due to low TD %v\n", p.id, request.Block.Number(), request.TD)
break
@ -305,14 +304,12 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
// Attempt to insert the newly received by checking if the parent exists.
// if the parent exists we process the block and propagate to our peers
// if the parent does not exists we delegate to the downloader.
// NOTE we can reduce chatter by dropping blocks with Td < currentTd
if self.chainman.HasBlock(request.Block.ParentHash()) {
if err := self.chainman.InsertChain(types.Blocks{request.Block}); err != nil {
// handle error
return nil
}
self.BroadcastBlock(hash, request.Block)
//fmt.Println(request.Block.Hash().Hex(), "our calculated TD =", request.Block.Td, "their TD =", request.TD)
} else {
// adding blocks is synchronous
go func() {
@ -322,7 +319,6 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
return
}
self.BroadcastBlock(hash, request.Block)
//fmt.Println(request.Block.Hash().Hex(), "our calculated TD =", request.Block.Td, "their TD =", request.TD)
}()
}
default:

File diff suppressed because one or more lines are too long