Пример #1
0
    def wireDecode(self, wire):
        self.m_hasName = False
        self.m_hasStartBlockId = False
        self.m_hasEndBlockId = False
        self.m_hasProcessId = False
        self.m_hasMaxInterestNum = False
        self.m_hasWatchTimeout = False
        self.m_hasInterestLifetime = False

        #self.m_wire = wire

        decoder = TlvDecoder(wire)

        endOffset = decoder.readNestedTlvsStart(repoTlv.RepoCommandParameter)

        # Name
        if (decoder.peekType(Tlv.Name)):
            self.m_hasName = True
            Tlv0_1WireFormat._decodeName(self.m_name, decoder)

        # Selectors
        if (decoder.peekType(Tlv.Selectors)):
            Tlv0_1WireFormat._decodeSelectors(self.m_selector, decoder)
            self.m_selectors.wireDecode(*val)

        # StartBlockId
        if (decoder.peekType(repoTlv.StartBlockId)):
            self.m_hasStartBlockId = True
            self.m_startBlockId = decoder.readNonNegativeIntegerTlv(
                repoTlv.StartBlockId)

        # EndBlockId
        if (decoder.peekType(repoTlv.EndBlockId)):
            self.m_hasEndBlockId = True
            self.m_endBlockId = decoder.readNonNegativeIntegerTlv(
                repoTlv.EndBlockId)

        # ProcessId
        if (decoder.peekType(repoTlv.ProcessId)):
            self.m_hasProcessId = True
            self.m_processId = decoder.readNonNegativeInteger(
                repoTlv.ProcessId)

        # MaxInterestNum
        if (decoder.peekType(repoTlv.MaxInterestNum)):
            self.m_hasMaxInterestNum = True
            self.m_maxInterestNum = decoder.readNonNegativeInteger(
                repoTlv.MaxInterestNum)

        # WatchTimeout
        if (decoder.peekType(repoTlv.WatchTimeout)):
            self.m_hasWatchTimeout = True
            self.m_watchTimeout = milliseconds(
                decoder.readNonNegativeInteger(repoTlv.WatchTimeout))

        # InterestLifeTime
        if (decoder.peekType(Tlv.InterestLifetime)):
            self.m_hasInterestLifetime = True
            self.m_interestLifetime = milliseconds(
                decoder.readNonNegativeInteger(Tlv.InterestLifetime))
Пример #2
0
    def wireDecode(self, wire):
        self.m_hasName = False
        self.m_hasStartBlockId = False
        self.m_hasEndBlockId = False
        self.m_hasProcessId = False
        self.m_hasMaxInterestNum = False
        self.m_hasWatchTimeout = False
        self.m_hasInterestLifetime = False

        #self.m_wire = wire
        
        decoder = TlvDecoder(wire)

        endOffset = decoder.readNestedTlvsStart(repoTlv.RepoCommandParameter)
  
        # Name
        if (decoder.peekType(Tlv.Name)):
            self.m_hasName = True
            Tlv0_1WireFormat._decodeName(self.m_name, decoder)

        # Selectors
        if (decoder.peekType(Tlv.Selectors)):
            Tlv0_1WireFormat._decodeSelectors(self.m_selector, decoder)
            self.m_selectors.wireDecode(*val)
      
        # StartBlockId
        if (decoder.peekType(repoTlv.StartBlockId)):
            self.m_hasStartBlockId = True
            self.m_startBlockId = decoder.readNonNegativeIntegerTlv(repoTlv.StartBlockId)
  
        # EndBlockId
        if (decoder.peekType(repoTlv.EndBlockId)):
            self.m_hasEndBlockId = True
            self.m_endBlockId = decoder.readNonNegativeIntegerTlv(repoTlv.EndBlockId)

        # ProcessId
        if (decoder.peekType(repoTlv.ProcessId)):
            self.m_hasProcessId = True
            self.m_processId = decoder.readNonNegativeInteger(repoTlv.ProcessId)

        # MaxInterestNum
        if (decoder.peekType(repoTlv.MaxInterestNum)):
            self.m_hasMaxInterestNum = True
            self.m_maxInterestNum = decoder.readNonNegativeInteger(repoTlv.MaxInterestNum)

        # WatchTimeout
        if (decoder.peekType(repoTlv.WatchTimeout)):
            self.m_hasWatchTimeout = True
            self.m_watchTimeout = milliseconds(decoder.readNonNegativeInteger(repoTlv.WatchTimeout))

        # InterestLifeTime
        if (decoder.peekType(Tlv.InterestLifetime)):
            self.m_hasInterestLifetime = True
            self.m_interestLifetime = milliseconds(decoder.readNonNegativeInteger(Tlv.InterestLifetime))