class Blocks: """ 受托人delegates相关的api """ def __init__(self): self.api = HttpApi() def execute(self, method, api, payload=None): return self.api.execute(method, api, payload) def get_blocks(self, payload): """ 获取block详情,不加参数则获取全网区块详情 """ api = '/api/blocks' return self.execute('get', api, payload) def get_height(self): """ 获取blockchain高度 :return:block chain height """ api = '/api/blocks/getHeight' return self.execute('get', api)
class Delegates: """ 受托人delegates相关的api """ def __init__(self): self.api = HttpApi() def execute(self, method, api, payload): return self.api.execute(method, api, payload) def get_voters(self, payload): """ 谁给我投了票 """ api = '/api/delegates/voters' return self.execute('get', api, payload) def get_info(self, payload): """ 通过公钥或者用户名获取受托人信息 """ api = '/api/delegates/get' return self.execute('get', api, payload) def get_delegates(self, payload): """ 获取受托人列表 """ api = '/api/delegates' return self.execute('get', api, payload)
class Accounts: """ 账户accounts相关的api """ def __init__(self): self.api = HttpApi() def open(self, payload): """ 登陆 :param """ api = '/api/accounts/open/' return self.api.execute('post', api, payload) def accounts(self, payload): """ 查询账户信息 """ api = '/api/accounts' return self.api.execute('get', api, payload) def balance(self, payload): """ :param payload: :return: """ api = '/api/accounts/getBalance' return self.api.execute('get', api, payload) def vote(self, payload): """ 给受托人投票 """ api = '/api/accounts/delegates' return self.api.execute('put', api, payload) def voters(self, payload): """ 该账户为谁投了票 """ api = '/api/accounts/delegates' return self.api.execute('get', api, payload) def top(self, payload): """ 获取top账户 :return: """ api = '/api/accounts/top' return self.api.execute('get', api, payload)
class Peers: """ 账户accounts相关的api """ def __init__(self): self.api = HttpApi() def peers(self, payload): """ 获取全网节点信息 :param payload :type payload: dict state integer N 节点状态,0: ,1:,2:,3: os string N 内核版本 version string N asch版本号 limit integer N 限制结果集个数,最小值:0,最大值:100 orderBy string N offset integer N 步长,最小值0 port integer N 端口,1~65535 :return """ api = '/api/peers' return self.api.execute('get', api, payload)
def __init__(self): self.api = HttpApi()