added fetch command
fetching command allows us to get the newest block so that we can use it to
update channel later.
@@ -37,12 +37,38 @@ class Channel(BasicEnv):
raise Exception(err_msg)
return res
- def update(self, channel, channel_tx, orderer_url, time_out="90s"):
+ def update(self, channel, channel_tx, orderer_url):
+ """
+ Send a configtx update.
+
+ params:
+ channel: channel id.
+ channel_tx: Configuration transaction file generated by a tool such as configtxgen for submitting to orderer
+ orderer_url: Ordering service endpoint.
+ """
try:
- res = os.system("{} channel create -c {} -f {} -o {} --timeout {}"
- .format(self.peer, channel, channel_tx, orderer_url, time_out))
+ res = os.system("{} channel update -c {} -f {} -o {}"
+ .format(self.peer, channel, channel_tx, orderer_url))
except Exception as e:
err_msg = "update channel failed for {e}!"
raise Exception(err_msg)
res = res >> 8
return res
+
+ def fetch(self, option, channel, orderer_url, time_out="90s"):
+ """
+ Fetch a specified block, writing it to a file e.g. <channelID>.block.
+
+ params:
+ option: block option newest|oldest|config|(block number).
+ channel: channel id.
+ orderer_url: Ordering service endpoint.
+ """
+ try:
+ res = os.system("{} channel fetch {} -c {} -o {} --timeout {}".format(
+ self.peer, option, channel, orderer_url, time_out))
+ except Exception as e:
+ err_msg = "fetch a specified block for {}!".format(e)
+ raise Exception(err_msg)
+ res = res >> 8
+ return res
