Merge pull request #800 from obscuren/ethereum_js_update
Ethereum js update
This commit is contained in:
commit
31811365e0
2
.gitignore
vendored
2
.gitignore
vendored
@ -23,8 +23,6 @@ Godeps/_workspace/bin
|
|||||||
.project
|
.project
|
||||||
.settings
|
.settings
|
||||||
|
|
||||||
mist
|
|
||||||
cmd/mist/mist
|
|
||||||
deploy/osx/Mist.app
|
deploy/osx/Mist.app
|
||||||
deploy/osx/Mist\ Installer.dmg
|
deploy/osx/Mist\ Installer.dmg
|
||||||
|
|
||||||
|
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -1,3 +1,3 @@
|
|||||||
[submodule "cmd/mist/assets/ext/ethereum.js"]
|
[submodule "cmd/mist/assets/ext/ethereum.js"]
|
||||||
path = 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)
|
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 {
|
if err != nil {
|
||||||
utils.Fatalf("Error requiring web3: %v", err)
|
utils.Fatalf("Error requiring web3: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<title>JevCoin</title>
|
<title>JevCoin</title>
|
||||||
<head>
|
<head>
|
||||||
<script type="text/javascript" src="../ext/bignumber.min.js"></script>
|
<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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@ -32,7 +32,6 @@
|
|||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var web3 = require('ethereum.js');
|
|
||||||
var eth = web3.eth;
|
var eth = web3.eth;
|
||||||
|
|
||||||
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
|
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)
|
return errResp(ErrDecode, "block validation %v: %v", msg, err)
|
||||||
}
|
}
|
||||||
hash := request.Block.Hash()
|
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.
|
// who should receive this.
|
||||||
p.blockHashes.Add(hash)
|
p.blockHashes.Add(hash)
|
||||||
|
|
||||||
@ -296,7 +296,6 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
|
|||||||
if self.chainman.HasBlock(hash) {
|
if self.chainman.HasBlock(hash) {
|
||||||
break
|
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 {
|
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)
|
glog.V(logger.Debug).Infof("[%s] dropped block %v due to low TD %v\n", p.id, request.Block.Number(), request.TD)
|
||||||
break
|
break
|
||||||
@ -305,14 +304,12 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
|
|||||||
// Attempt to insert the newly received by checking if the parent exists.
|
// 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 exists we process the block and propagate to our peers
|
||||||
// if the parent does not exists we delegate to the downloader.
|
// 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 self.chainman.HasBlock(request.Block.ParentHash()) {
|
||||||
if err := self.chainman.InsertChain(types.Blocks{request.Block}); err != nil {
|
if err := self.chainman.InsertChain(types.Blocks{request.Block}); err != nil {
|
||||||
// handle error
|
// handle error
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
self.BroadcastBlock(hash, request.Block)
|
self.BroadcastBlock(hash, request.Block)
|
||||||
//fmt.Println(request.Block.Hash().Hex(), "our calculated TD =", request.Block.Td, "their TD =", request.TD)
|
|
||||||
} else {
|
} else {
|
||||||
// adding blocks is synchronous
|
// adding blocks is synchronous
|
||||||
go func() {
|
go func() {
|
||||||
@ -322,7 +319,6 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.BroadcastBlock(hash, request.Block)
|
self.BroadcastBlock(hash, request.Block)
|
||||||
//fmt.Println(request.Block.Hash().Hex(), "our calculated TD =", request.Block.Td, "their TD =", request.TD)
|
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user