Skip to content

Commit 97d22be

Browse files
committed
Merge pull request #1441 from obscuren/logs-return-fix
miner, xeth: fire log event during mining. Fix return raw tx
2 parents 4c62ce8 + d256346 commit 97d22be

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

core/filter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ done:
9999
switch {
100100
case block.NumberU64() == 0:
101101
break done
102-
case block.NumberU64() == earliestBlockNo:
102+
case block.NumberU64() < earliestBlockNo:
103103
break done
104104
case self.max <= len(logs):
105105
break done

jsre/ethereum_js.go

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ module.exports = {
14171417
14181418
},{"bignumber.js":"bignumber.js"}],8:[function(require,module,exports){
14191419
module.exports={
1420-
"version": "0.8.0"
1420+
"version": "0.8.1"
14211421
}
14221422
14231423
},{}],9:[function(require,module,exports){
@@ -1840,21 +1840,23 @@ var contract = function (abi) {
18401840
};
18411841
18421842
/**
1843-
* Should be called to create new ContractFactory
1843+
* Should be called to check if the contract gets properly deployed on the blockchain.
18441844
*
18451845
* @method checkForContractAddress
18461846
* @param {Object} contract
18471847
* @param {Function} callback
18481848
* @returns {Undefined}
18491849
*/
1850-
var checkForContractAddress = function(contract, callback){
1850+
var checkForContractAddress = function(contract, abi, callback){
18511851
var count = 0;
18521852
18531853
// wait for receipt
18541854
var filter = web3.eth.filter('latest', function(e){
18551855
if(!e) {
18561856
count++;
18571857
1858+
// console.log('Checking for contract address', count);
1859+
18581860
// stop watching after 50 blocks (timeout)
18591861
if(count > 50) {
18601862
if(callback)
@@ -1870,8 +1872,14 @@ var checkForContractAddress = function(contract, callback){
18701872
web3.eth.getCode(receipt.contractAddress, function(e, code){
18711873
if(code.length > 2) {
18721874
1875+
// console.log('Contract code deployed!');
1876+
18731877
contract.address = receipt.contractAddress;
18741878
1879+
// attach events and methods
1880+
addFunctionsToContract(contract, abi);
1881+
addEventsToContract(contract, abi);
1882+
18751883
if(callback)
18761884
callback(null, contract);
18771885
@@ -1909,6 +1917,7 @@ var ContractFactory = function (abi) {
19091917
* @returns {Contract} returns contract instance
19101918
*/
19111919
ContractFactory.prototype.new = function () {
1920+
var _this = this;
19121921
var contract = new Contract(this.abi);
19131922
19141923
// parse arguments
@@ -1940,14 +1949,14 @@ ContractFactory.prototype.new = function () {
19401949
} else {
19411950
// add the transaction hash
19421951
contract.transactionHash = hash;
1943-
checkForContractAddress(contract, callback);
1952+
checkForContractAddress(contract, _this.abi, callback);
19441953
}
19451954
});
19461955
} else {
19471956
var hash = web3.eth.sendTransaction(options);
19481957
// add the transaction hash
19491958
contract.transactionHash = hash;
1950-
checkForContractAddress(contract);
1959+
checkForContractAddress(contract, _this.abi);
19511960
}
19521961
19531962
return contract;
@@ -1963,12 +1972,17 @@ ContractFactory.prototype.new = function () {
19631972
* otherwise calls callback function (err, contract)
19641973
*/
19651974
ContractFactory.prototype.at = function (address, callback) {
1975+
var contract = new Contract(this.abi, address);
19661976
// TODO: address is required
1977+
1978+
// attach functions
1979+
addFunctionsToContract(contract, this.abi);
1980+
addEventsToContract(contract, this.abi);
19671981
19681982
if (callback) {
1969-
callback(null, new Contract(this.abi, address));
1983+
callback(null, contract);
19701984
}
1971-
return new Contract(this.abi, address);
1985+
return contract;
19721986
};
19731987
19741988
/**
@@ -1980,8 +1994,6 @@ ContractFactory.prototype.at = function (address, callback) {
19801994
*/
19811995
var Contract = function (abi, address) {
19821996
this.address = address;
1983-
addFunctionsToContract(this, abi);
1984-
addEventsToContract(this, abi);
19851997
};
19861998
19871999
module.exports = contract;
@@ -2484,8 +2496,8 @@ SolidityEvent.prototype.encode = function (indexed, options) {
24842496
24852497
result.topics = [];
24862498
2499+
result.address = this._address;
24872500
if (!this._anonymous) {
2488-
result.address = this._address;
24892501
result.topics.push('0x' + this.signature());
24902502
}
24912503

miner/worker.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ func (self *worker) wait() {
298298
self.mux.Post(core.ChainEvent{block, block.Hash(), logs})
299299
if stat == core.CanonStatTy {
300300
self.mux.Post(core.ChainHeadEvent{block})
301+
self.mux.Post(logs)
301302
}
302303
}(block, self.current.state.Logs())
303304

xeth/xeth.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,6 @@ func (self *XEth) PushTx(encodedTx string) (string, error) {
781781

782782
addr := crypto.CreateAddress(from, tx.Nonce())
783783
glog.V(logger.Info).Infof("Tx(%x) created: %x\n", tx.Hash(), addr)
784-
return addr.Hex(), nil
785784
} else {
786785
glog.V(logger.Info).Infof("Tx(%x) to: %x\n", tx.Hash(), tx.To())
787786
}

0 commit comments

Comments
 (0)