def __init__(self, private=None, public=None): self._factory = MessageFactory( encoding='application/protobuf', family_name=SUPPLYCHAIN_FAMILY_NAME, family_version=SUPPLYCHAIN_VERSION, namespace=[Addressing.agent_namespace(), Addressing.application_namespace(), Addressing.record_namespace()], private=private, public=public )
def agent_list(self): result = self._send_get("state?address={}".format( Addressing.agent_namespace())) try: data = self._get_result_list(result) out = [] for state_obj in data: container = _decode_agent_container( _b64_dec(state_obj['data'])) out.extend(container.entries) return out except BaseException: return None
def agent_list(self): result = self._send_get("state?address={}".format( Addressing.agent_namespace())) try: data = self._get_result_list(result) out = [] for state_obj in data: container = _decode_agent_container(_b64_dec( state_obj['data'])) out.extend(container.entries) return out except BaseException: return None
def _get(state, addresses): entries = state.get(addresses) if entries: out = {} for e in entries: addr = e.address if e.data: if addr.startswith(Addressing.agent_namespace()): container = AgentContainer() elif addr.startswith(Addressing.application_namespace()): container = ApplicationContainer() elif addr.startswith(Addressing.record_namespace()): container = RecordContainer() else: raise InvalidTransaction("Unknown namespaces.") else: container = None container.ParseFromString(e.data) out[addr] = container return out return {}
from sawtooth_sdk.protobuf.state_delta_pb2 import \ StateDeltaUnsubscribeRequest from sawtooth_sdk.protobuf.state_delta_pb2 import StateDeltaEvent from sawtooth_sdk.protobuf.transaction_receipt_pb2 import StateChange from sawtooth_sdk.protobuf.validator_pb2 import Message from sawtooth_supplychain.common.addressing import Addressing from sawtooth_supplychain.protobuf.agent_pb2 import AgentContainer from sawtooth_supplychain.protobuf.application_pb2 import ApplicationContainer from sawtooth_supplychain.protobuf.application_pb2 import Application from sawtooth_supplychain.protobuf.record_pb2 import RecordContainer LOGGER = logging.getLogger(__name__) AGENT_NAMESPACE = Addressing.agent_namespace() APPLICATION_NAMESPACE = Addressing.application_namespace() RECORD_NAMESPACE = Addressing.record_namespace() MAX_BLOCK_NUMBER = int(math.pow(2, 63)) - 1 class Subscriber: """A State Delta Subscriber for supplychain. The Subscriber will send a StateDeltaSubscribeRequest, limited to the state values within the namespaces for the supplychain family. """ def __init__(self, stream, db_connection): self._stream = stream self._db_connection = db_connection
def namespaces(self): return [ Addressing.agent_namespace(), Addressing.application_namespace(), Addressing.record_namespace() ]
def namespaces(self): return [Addressing.agent_namespace(), Addressing.application_namespace(), Addressing.record_namespace()]