Skip to content
Permalink
Browse files

add ckb compile info to install doc

  • Loading branch information
BTC.com
BTC.com committed Dec 11, 2019
1 parent ab5c9f3 commit c8c64abeccbfbe3e4d31613578f2b0fe7c09da0d
Showing with 21 additions and 10 deletions.
  1. +6 −0 docs/INSTALL-BTCPool.md
  2. +2 −2 rust/nodebridge/Cargo.toml
  3. +13 −8 tools/ckb_update_reward/updatereward.py
@@ -317,6 +317,12 @@ make -j$(nproc)

Please use the build that linking to Bitcoin (`-DCHAIN_TYPE=BTC`).

**How about Nervos(CKB)?**

Please use the build that linking to Bitcoin (`-DCHAIN_TYPE=BTC`).
Please use [nodebridge](https://github.com/btccom/btcpool/tree/master/rust) instead of gwmaker/blkmaker to exchange data with nodes and store mined block info to db.
please use [ckb_update_reward](https://github.com/btccom/btcpool/tree/master/tools/ckb_update_reward) to update ckb's block reward.

---

## Init btcpool
@@ -7,8 +7,8 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.23.0" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.23.0" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.25.0" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.25.0" }
chrono = "0.4"
env_logger = "0.6"
failure = "0.1"
@@ -33,9 +33,10 @@ def create_mysql_handle(self):
except Exception as err:
self.logger.error("connect mysql Error %s " % (err))

def update_reward(self, height, reward):
def update_reward(self, height, reward, is_orphaned):
reward = reward if not is_orphaned else 0
try:
sql = "UPDATE %s SET rewards = %d WHERE height = %d;" %(self.config["MYSQL"]["table"], reward, height)
sql = "UPDATE %s SET rewards = %d , is_orphaned = %d WHERE height = %d;" %(self.config["MYSQL"]["table"], reward, is_orphaned, height)
self.cursor = self.create_mysql_handle()
self.cursor.execute(sql)
self.databasehandle.commit()
@@ -45,22 +46,24 @@ def update_reward(self, height, reward):
self.cursor.close()

def get_lattest_heights(self, lastupdatedheight):
sql = "select height from %s where height > %d;" %(self.config["MYSQL"]["table"], lastupdatedheight)
sql = "select height , hash from %s where height > %d;" %(self.config["MYSQL"]["table"], lastupdatedheight)
heights = []
height2hash = {}
try:
self.cursor = self.create_mysql_handle()
self.cursor.execute(sql)
rows = self.cursor.fetchall()
for row in rows:
heights.append(row[0])

height2hash[row[0]] = row[1]
heights.sort()
except Exception as err:
self.logger.warning("execute sql error %s " % (err))
if len(heights) > 0:
self.lastheight = heights[-1]
self.logger.info("curreent mysql hight : %d " % (self.lastheight))
self.logger.info("current mysql hight : %d " % (self.lastheight))
self.cursor.close()
return heights
return heights, height2hash


def get_chain_tip(self):
@@ -115,15 +118,17 @@ def get_block_hash(self, height):

def run(self):
while True:
heights = self.get_lattest_heights(self.lastheight)
heights, height2hash = self.get_lattest_heights(self.lastheight)
for height in heights:
self.wait_untill_height(height + 11)
curblockhash = self.get_block_hash(height)
blockhash = self.get_block_hash(height + 11)
reward = self.get_block_reward(blockhash)
if blockhash is None or reward is None:
heights.append(height)
else:
self.update_reward(height, reward)
is_orphaned = (height2hash[height] != curblockhash)
self.update_reward(height, reward, is_orphaned)
self.logger.info("update height: %d reeward : %d hash : %s " % (height, reward, blockhash))
time.sleep(5)

0 comments on commit c8c64ab

Please sign in to comment.
You can’t perform that action at this time.