日志记录

日志记录

有四个级别的日志记录:

info,信息。
warn,警告。
error,错误。
debug,调试。

默认情况下,info、warn和error条目将发送到控制台console,不会记录debug。

交易信息并不会直接从区块链种查询,通过eth.filter实时监听区块上的日志,将所有的交易数据存储到本地数据库中,需要查询的时候直接从本地数据库中查询

在这里插入图片描述

4.帮助我们通过filter过滤出历史交易数据.
下面的方法具体实现我们开始讲的通过filter办法,从链上扒出历史交易数据的办法。
//以下是web3.js代码:

var depositEvent = cryptoExContract.Deposit({_sender: userAddress});
depositEvent.watch(function(err, result) {
if (err) {
console.log(err)
return;
}
else{
// append details of result.args to UI
//将这笔交易写入客户端资料库中,方便以后查询历史交易数据。
}
})
//通过增加fromBlock参数指定关注的区块范围,来查询所有的交易数据。(获取链上存储的历史交易数据,我们用扒链的办法来获取,因为eth目前没有提供获取历史数据的API。)
var depositEventAll = cryptoExContract.Deposit({_sender: userAddress}, {fromBlock: 0, toBlock: ‘latest’});
depositEventAll.watch(function(err, result) {
if (err) {
console.log(err)
return;
}
else{
// append details of result.args to UI
//如果不想再被通知可以调用:
//depositEventAll.stopWatching();
}
})

启动节点
geth --rpc --nodiscover --datadir “./nodedata0” --port 30303 --rpcapi “db,eth,net,web3” --rpccorsdomain “*” --networkid 1001 --ipcdisable console 2>>geth.log

–datadir 区块链数据存储目录

console 打开一个可交互的javascript环境
2>>geth.log 把geth中的log信息导入geth.log,也可以不加这个,把信息直接输出在console里,这样直观

更多参数:https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options
http://www.yaozihao.cn/2017/07/07/geth%E5%91%BD%E4%BB%A4%E9%80%89%E9%A1%B9%E4%BB%8B%E7%BB%8D/

根据显示信息去找到那个geth.log文件
在这里插入图片描述

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值