Skip to content
Snippets Groups Projects
Select Git revision
  • 11-22-implement-kv-interface-defined-in-collectiveversionedkvgo
  • release default protected
  • hotfix/TestHostPool_UpdateNdf_AddFilter
  • XX-4719/announcementChannels
  • xx-4717/logLevel
  • jonah/noob-channel
  • master protected
  • XX-4707/tagDiskJson
  • xx-4698/notification-retry
  • hotfix/notifylockup
  • syncNodes
  • hotfix/localCB
  • XX-4677/NewChanManagerMobile
  • XX-4689/DmSync
  • duplicatePrefix
  • XX-4601/HavenInvites
  • finalizedUICallbacks
  • XX-4673/AdminKeySync
  • debugNotifID
  • anne/test
  • v4.7.5
  • v4.7.4
  • v4.7.3
  • v4.7.2
  • v4.7.1
  • v4.6.3
  • v4.6.1
  • v4.5.0
  • v4.4.4
  • v4.3.11
  • v4.3.8
  • v4.3.7
  • v4.3.6
  • v4.3.5
  • v4.2.0
  • v4.3.0
  • v4.3.4
  • v4.3.3
  • v4.3.2
  • v4.3.1
40 results

responseProcessor.go

Blame
  • responseProcessor.go 1.51 KiB
    package single
    
    import (
    	jww "github.com/spf13/jwalterweatherman"
    	"gitlab.com/elixxir/client/cmix/identity/receptionID"
    	"gitlab.com/elixxir/client/cmix/rounds"
    	"gitlab.com/elixxir/client/single/message"
    	"gitlab.com/elixxir/crypto/contact"
    	"gitlab.com/elixxir/primitives/format"
    )
    
    type callbackWrapper func(payload []byte,
    	receptionID receptionID.EphemeralIdentity, round rounds.Round, err error)
    
    // responseProcessor is registered for each potential fingerprint. Adheres to
    // the message.Processor interface registered with cmix.Client
    type responseProcessor struct {
    	sendingID receptionID.EphemeralIdentity
    	c         *message.Collator
    	callback  callbackWrapper
    	cy        cypher
    	tag       string
    	recipient *contact.Contact
    }
    
    // Process decrypts a response part and adds it to the collator - returning
    // a full response to the callback when all parts are received.
    func (rsp *responseProcessor) Process(ecrMsg format.Message,
    	receptionID receptionID.EphemeralIdentity, round rounds.Round) {
    
    	decrypted, err := rsp.cy.Decrypt(ecrMsg.GetContents(), ecrMsg.GetMac())
    	if err != nil {
    		jww.ERROR.Printf("[SU] Failed to decrypt single-use response "+
    			"payload for %s to %s: %+v",
    			rsp.tag, rsp.recipient.ID, err)
    		return
    	}
    
    	payload, done, err := rsp.c.Collate(decrypted)
    	if err != nil {
    		jww.ERROR.Printf("[SU] Failed to collate single-use response payload "+
    			"for %s to %s, single use may fail: %+v",
    			rsp.tag, rsp.recipient.ID, err)
    		return
    	}
    
    	if done {
    		rsp.callback(payload, receptionID, round, nil)
    	}
    }