forked from cerc-io/plugeth
Merge pull request #1441 from obscuren/logs-return-fix
miner, xeth: fire log event during mining. Fix return raw tx
This commit is contained in:
commit
97d22be318
@ -99,7 +99,7 @@ done:
|
|||||||
switch {
|
switch {
|
||||||
case block.NumberU64() == 0:
|
case block.NumberU64() == 0:
|
||||||
break done
|
break done
|
||||||
case block.NumberU64() == earliestBlockNo:
|
case block.NumberU64() < earliestBlockNo:
|
||||||
break done
|
break done
|
||||||
case self.max <= len(logs):
|
case self.max <= len(logs):
|
||||||
break done
|
break done
|
||||||
|
@ -1417,7 +1417,7 @@ module.exports = {
|
|||||||
|
|
||||||
},{"bignumber.js":"bignumber.js"}],8:[function(require,module,exports){
|
},{"bignumber.js":"bignumber.js"}],8:[function(require,module,exports){
|
||||||
module.exports={
|
module.exports={
|
||||||
"version": "0.8.0"
|
"version": "0.8.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
},{}],9:[function(require,module,exports){
|
},{}],9:[function(require,module,exports){
|
||||||
@ -1840,14 +1840,14 @@ var contract = function (abi) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should be called to create new ContractFactory
|
* Should be called to check if the contract gets properly deployed on the blockchain.
|
||||||
*
|
*
|
||||||
* @method checkForContractAddress
|
* @method checkForContractAddress
|
||||||
* @param {Object} contract
|
* @param {Object} contract
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
* @returns {Undefined}
|
* @returns {Undefined}
|
||||||
*/
|
*/
|
||||||
var checkForContractAddress = function(contract, callback){
|
var checkForContractAddress = function(contract, abi, callback){
|
||||||
var count = 0;
|
var count = 0;
|
||||||
|
|
||||||
// wait for receipt
|
// wait for receipt
|
||||||
@ -1855,6 +1855,8 @@ var checkForContractAddress = function(contract, callback){
|
|||||||
if(!e) {
|
if(!e) {
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
|
// console.log('Checking for contract address', count);
|
||||||
|
|
||||||
// stop watching after 50 blocks (timeout)
|
// stop watching after 50 blocks (timeout)
|
||||||
if(count > 50) {
|
if(count > 50) {
|
||||||
if(callback)
|
if(callback)
|
||||||
@ -1870,8 +1872,14 @@ var checkForContractAddress = function(contract, callback){
|
|||||||
web3.eth.getCode(receipt.contractAddress, function(e, code){
|
web3.eth.getCode(receipt.contractAddress, function(e, code){
|
||||||
if(code.length > 2) {
|
if(code.length > 2) {
|
||||||
|
|
||||||
|
// console.log('Contract code deployed!');
|
||||||
|
|
||||||
contract.address = receipt.contractAddress;
|
contract.address = receipt.contractAddress;
|
||||||
|
|
||||||
|
// attach events and methods
|
||||||
|
addFunctionsToContract(contract, abi);
|
||||||
|
addEventsToContract(contract, abi);
|
||||||
|
|
||||||
if(callback)
|
if(callback)
|
||||||
callback(null, contract);
|
callback(null, contract);
|
||||||
|
|
||||||
@ -1909,6 +1917,7 @@ var ContractFactory = function (abi) {
|
|||||||
* @returns {Contract} returns contract instance
|
* @returns {Contract} returns contract instance
|
||||||
*/
|
*/
|
||||||
ContractFactory.prototype.new = function () {
|
ContractFactory.prototype.new = function () {
|
||||||
|
var _this = this;
|
||||||
var contract = new Contract(this.abi);
|
var contract = new Contract(this.abi);
|
||||||
|
|
||||||
// parse arguments
|
// parse arguments
|
||||||
@ -1940,14 +1949,14 @@ ContractFactory.prototype.new = function () {
|
|||||||
} else {
|
} else {
|
||||||
// add the transaction hash
|
// add the transaction hash
|
||||||
contract.transactionHash = hash;
|
contract.transactionHash = hash;
|
||||||
checkForContractAddress(contract, callback);
|
checkForContractAddress(contract, _this.abi, callback);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var hash = web3.eth.sendTransaction(options);
|
var hash = web3.eth.sendTransaction(options);
|
||||||
// add the transaction hash
|
// add the transaction hash
|
||||||
contract.transactionHash = hash;
|
contract.transactionHash = hash;
|
||||||
checkForContractAddress(contract);
|
checkForContractAddress(contract, _this.abi);
|
||||||
}
|
}
|
||||||
|
|
||||||
return contract;
|
return contract;
|
||||||
@ -1963,12 +1972,17 @@ ContractFactory.prototype.new = function () {
|
|||||||
* otherwise calls callback function (err, contract)
|
* otherwise calls callback function (err, contract)
|
||||||
*/
|
*/
|
||||||
ContractFactory.prototype.at = function (address, callback) {
|
ContractFactory.prototype.at = function (address, callback) {
|
||||||
|
var contract = new Contract(this.abi, address);
|
||||||
// TODO: address is required
|
// TODO: address is required
|
||||||
|
|
||||||
|
// attach functions
|
||||||
|
addFunctionsToContract(contract, this.abi);
|
||||||
|
addEventsToContract(contract, this.abi);
|
||||||
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(null, new Contract(this.abi, address));
|
callback(null, contract);
|
||||||
}
|
}
|
||||||
return new Contract(this.abi, address);
|
return contract;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1980,8 +1994,6 @@ ContractFactory.prototype.at = function (address, callback) {
|
|||||||
*/
|
*/
|
||||||
var Contract = function (abi, address) {
|
var Contract = function (abi, address) {
|
||||||
this.address = address;
|
this.address = address;
|
||||||
addFunctionsToContract(this, abi);
|
|
||||||
addEventsToContract(this, abi);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = contract;
|
module.exports = contract;
|
||||||
@ -2484,8 +2496,8 @@ SolidityEvent.prototype.encode = function (indexed, options) {
|
|||||||
|
|
||||||
result.topics = [];
|
result.topics = [];
|
||||||
|
|
||||||
if (!this._anonymous) {
|
|
||||||
result.address = this._address;
|
result.address = this._address;
|
||||||
|
if (!this._anonymous) {
|
||||||
result.topics.push('0x' + this.signature());
|
result.topics.push('0x' + this.signature());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,6 +298,7 @@ func (self *worker) wait() {
|
|||||||
self.mux.Post(core.ChainEvent{block, block.Hash(), logs})
|
self.mux.Post(core.ChainEvent{block, block.Hash(), logs})
|
||||||
if stat == core.CanonStatTy {
|
if stat == core.CanonStatTy {
|
||||||
self.mux.Post(core.ChainHeadEvent{block})
|
self.mux.Post(core.ChainHeadEvent{block})
|
||||||
|
self.mux.Post(logs)
|
||||||
}
|
}
|
||||||
}(block, self.current.state.Logs())
|
}(block, self.current.state.Logs())
|
||||||
|
|
||||||
|
@ -781,7 +781,6 @@ func (self *XEth) PushTx(encodedTx string) (string, error) {
|
|||||||
|
|
||||||
addr := crypto.CreateAddress(from, tx.Nonce())
|
addr := crypto.CreateAddress(from, tx.Nonce())
|
||||||
glog.V(logger.Info).Infof("Tx(%x) created: %x\n", tx.Hash(), addr)
|
glog.V(logger.Info).Infof("Tx(%x) created: %x\n", tx.Hash(), addr)
|
||||||
return addr.Hex(), nil
|
|
||||||
} else {
|
} else {
|
||||||
glog.V(logger.Info).Infof("Tx(%x) to: %x\n", tx.Hash(), tx.To())
|
glog.V(logger.Info).Infof("Tx(%x) to: %x\n", tx.Hash(), tx.To())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user