trc20部署event-plugin

编译源代码

  1. 创建代码目录
mkdir -p  /project/eventplugin/
  1. 下载eventplugin源码
cd  /project/eventplugin/
git clone https://github.com/tronprotocol/event-plugin.git
  1. 编译eventplugin项目
cd eventplugin
./gradlew build
  1. 查看编译好的jar包
cd /build/libs

部署MongoDB

配置
event.subscribe = {
    path = "/project/eventplugin/build/plugins/plugin-mongodb-1.0.0.zip" // absolute path of plugin
    server = "127.0.0.1:27017" // target server address to receive event triggers
    dbconfig = "eventlog|tron|123456" // dbname|username|password
    topics = [
        {
          triggerName = "block" // block trigger, the value can't be modified
          enable = false
          topic = "block" // plugin topic, the value could be modified
        },
        {
          triggerName = "transaction"
          enable = false
          topic = "transaction"
        },
        {
          triggerName = "contractevent"
          enable = true
          topic = "contractevent"
        },
        {
          triggerName = "contractlog"
          enable = true
          topic = "contractlog"
        },
        {
          triggerName = "solidity" // solidity block event trigger, the value can't be modified
          enable = true            // the default value is true
          topic = "solidity"
        },
        {
          triggerName = "solidityevent"
          enable = false
          topic = "solidityevent"
        },
        {
          triggerName = "soliditylog"
          enable = false
          topic = "soliditylog"
        }
    ]

    filter = {
       fromblock = "" // the value could be "", "earliest" or a specified block number as the beginning of the queried range
       toblock = "" // the value could be "", "latest" or a specified block number as end of the queried range
       contractAddress = [
           "" // contract address you want to subscribe, if it's set to "", you will receive contract logs/events with any contract address.
       ]

       contractTopic = [
           "" // contract topic you want to subscribe, if it's set to "", you will receive contract logs/events with any contract topic.
       ]
    }
}
字段解析
  1. path: “plugin-kafka-1.0.0.zip” 或 "plugin-mongodb-1.0.0.zip"的绝对路径
  2. server: 服务器地址+端口号(mongodb的)
  3. dbconfig: mongodb的配置,按例子中的来
  4. topics: 目前支持四种事件类型 block, transaction, contract log and contract event
  5. triggerName: 触发类型,可以修改
  6. enable: fasle就是禁用,true开启
  7. topic: mongodb接收事件的集合
部署MongoDB
安装
mkdir /project/soft
cd  /project/soft
curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.4.tgz
tar zxvf mongodb-linux-x86_64-4.0.4.tgz
mv mongodb-linux-x86_64-4.0.4 mongodb

设置环境变量 

export MONGOPATH= /project/soft/mongodb/
export PATH=$PATH:$MONGOPATH/bin

mongodb配置 

mkdir -p  /project/soft/mongodb/{log,data}
cd /project/soft/mongodb/log/ && touch mongodb.log && cd
vim mgdb.conf

mgdb.conf

dbpath=/project/soft/mongodb/data
logpath=/project/soft/mongodb/log/mongodb.log
port=27017
logappend=true
fork=true
bind_ip=0.0.0.0
auth=true
wiredTigerCacheSizeGB=2
启动mongodb
启动mongodb
mongod --config ./mgdb.conf &

创建管理员命令

mongo
use admin
db.createUser({user:"root",pwd:"hVvTb8ZHKnO3r555",roles:[{role:"root",db:"admin"}]})

创建db eventlog和账户命令

db.auth("root", "hVvTb8ZHKnO3r555")
use eventlog
db.createUser({user:"tron",pwd:"123456",roles:[{role:"dbOwner",db:"eventlog"}]})

部署kafka插件

配置
event.subscribe = {
  native = {
    useNativeQueue = false// if true, use native message queue, else use event plugin.
    bindport = 5555// bind port
    sendqueuelength = 1000 //max length of send queue
  }
    path = "" // absolute path of plugin
    server = "" // target server address to receive event triggers
   # dbconfig="" // dbname|username|password
    topics = [
        {
          triggerName = "block" // block trigger, the value can't be modified
          enable = false
          topic = "block" // plugin topic, the value could be modified
        },
        {
          triggerName = "transaction"
          enable = false
          topic = "transaction"
        },
        {
          triggerName = "contractevent"
          enable = true
          topic = "contractevent"
        },
        {
          triggerName = "contractlog"
          enable = true
          topic = "contractlog"
        },
        {
          triggerName = "solidity" // solidity block event trigger, the value can't be modified
          enable = true            // the default value is true
          topic = "solidity"
        },
        {
          triggerName = "solidityevent"
          enable = false
          topic = "solidityevent"
        },
        {
          triggerName = "soliditylog"
          enable = false
          topic = "soliditylog"
        }
    ]

    filter = {
       fromblock = "" // the value could be "", "earliest" or a specified block number as the beginning of the queried range
       toblock = "" // the value could be "", "latest" or a specified block number as end of the queried range
       contractAddress = [
           "" // contract address you want to subscribe, if it's set to "", you will receive contract logs/events with any contract address.
       ]

       contractTopic = [
           "" // contract topic you want to subscribe, if it's set to "", you will receive contract logs/events with any contract topic.
       ]
    }
}
安装kafka
mkdir /project/soft
cd  /project/soft
wget http://archive.apache.org/dist/kafka/0.10.2.2/kafka_2.10-0.10.2.2.tgz
tar -xzvf kafka_2.10-0.10.2.2.tgz 
mv kafka_2.10-0.10.2.2 kafka

add "export PATH=$PATH:/project/soft/kafka/bin" to end of /etc/profile
source /etc/profile

创建topic
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic block
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic transaction
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic contractlog
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic contractevent
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic solidity
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic solidityevent
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic soliditylog
启动消费者
kafka-console-consumer.sh --zookeeper localhost:2181 --topic block
kafka-console-consumer.sh --zookeeper localhost:2181 --topic transaction
kafka-console-consumer.sh --zookeeper localhost:2181 --topic contractlog
kafka-console-consumer.sh --zookeeper localhost:2181 --topic contractevent
kafka-console-consumer.sh --zookeeper localhost:2181 --topic solidity
kafka-console-consumer.sh --zookeeper localhost:2181 --topic solidityevent
kafka-console-consumer.sh --zookeeper localhost:2181 --topic soliditylog

启动节点

 java -jar FullNode.jar -c config.conf --es 

参考文档
https://cn.developers.tron.network/docs/tron%E4%BA%8B%E4%BB%B6%E6%8F%92%E4%BB%B6mongodb
https://github.com/tronprotocol/event-plugin

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值