Removed redudant PayloadMounter types
This commit is contained in:
parent
d0396cdd35
commit
44a1379fbe
|
@ -110,7 +110,7 @@ func (c *BaseClient) getChallenge() error {
|
||||||
type SenderClient struct {
|
type SenderClient struct {
|
||||||
*BaseClient
|
*BaseClient
|
||||||
accountMounter PayloadMounter
|
accountMounter PayloadMounter
|
||||||
rawMessageMounter *RawMessagePayloadMounter
|
rawMessageMounter PayloadMounter
|
||||||
installationMounter *InstallationPayloadMounterReceiver
|
installationMounter *InstallationPayloadMounterReceiver
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ func (rmm *RawMessagePayloadMarshaller) MarshalProtobuf() ([]byte, error) {
|
||||||
|
|
||||||
// InstallationPayloadMounterReceiver represents an InstallationPayload Repository
|
// InstallationPayloadMounterReceiver represents an InstallationPayload Repository
|
||||||
type InstallationPayloadMounterReceiver struct {
|
type InstallationPayloadMounterReceiver struct {
|
||||||
*InstallationPayloadMounter
|
PayloadMounter
|
||||||
*InstallationPayloadReceiver
|
*InstallationPayloadReceiver
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,6 +133,6 @@ func NewInstallationPayloadMounterReceiver(logger *zap.Logger, encryptor *Payloa
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *InstallationPayloadMounterReceiver) LockPayload() {
|
func (i *InstallationPayloadMounterReceiver) LockPayload() {
|
||||||
i.InstallationPayloadMounter.LockPayload()
|
i.PayloadMounter.LockPayload()
|
||||||
i.InstallationPayloadReceiver.LockPayload()
|
i.InstallationPayloadReceiver.LockPayload()
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,13 +65,9 @@ func (bpm *BasePayloadMounter) Mount() error {
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// AccountPayloadMounter is responsible for the whole lifecycle of an AccountPayload
|
|
||||||
type AccountPayloadMounter struct {
|
|
||||||
*BasePayloadMounter
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewAccountPayloadMounter generates a new and initialised AccountPayloadMounter
|
// NewAccountPayloadMounter generates a new and initialised AccountPayloadMounter
|
||||||
func NewAccountPayloadMounter(pe *PayloadEncryptor, config *SenderConfig, logger *zap.Logger) (*AccountPayloadMounter, error) {
|
// responsible for the whole lifecycle of an AccountPayload
|
||||||
|
func NewAccountPayloadMounter(pe *PayloadEncryptor, config *SenderConfig, logger *zap.Logger) (*BasePayloadMounter, error) {
|
||||||
l := logger.Named("AccountPayloadLoader")
|
l := logger.Named("AccountPayloadLoader")
|
||||||
l.Debug("fired", zap.Any("config", config))
|
l.Debug("fired", zap.Any("config", config))
|
||||||
|
|
||||||
|
@ -84,13 +80,11 @@ func NewAccountPayloadMounter(pe *PayloadEncryptor, config *SenderConfig, logger
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &AccountPayloadMounter{
|
return NewBasePayloadMounter(
|
||||||
BasePayloadMounter: NewBasePayloadMounter(
|
apl,
|
||||||
apl,
|
NewPairingPayloadMarshaller(p, l),
|
||||||
NewPairingPayloadMarshaller(p, l),
|
pe,
|
||||||
pe,
|
), nil
|
||||||
),
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccountPayloadLoader is responsible for loading, parsing and validating AccountPayload data
|
// AccountPayloadLoader is responsible for loading, parsing and validating AccountPayload data
|
||||||
|
@ -147,21 +141,17 @@ func (apl *AccountPayloadLoader) Load() error {
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
type RawMessagePayloadMounter struct {
|
// NewRawMessagePayloadMounter generates a new and initialised RawMessagePayloadMounter
|
||||||
*BasePayloadMounter
|
// responsible for the whole lifecycle of an RawMessagePayload
|
||||||
}
|
func NewRawMessagePayloadMounter(logger *zap.Logger, pe *PayloadEncryptor, backend *api.GethStatusBackend, config *SenderConfig) *BasePayloadMounter {
|
||||||
|
|
||||||
func NewRawMessagePayloadMounter(logger *zap.Logger, pe *PayloadEncryptor, backend *api.GethStatusBackend, config *SenderConfig) *RawMessagePayloadMounter {
|
|
||||||
pe = pe.Renew()
|
pe = pe.Renew()
|
||||||
payload := new(protobuf.SyncRawMessage)
|
payload := new(protobuf.SyncRawMessage)
|
||||||
|
|
||||||
return &RawMessagePayloadMounter{
|
return NewBasePayloadMounter(
|
||||||
BasePayloadMounter: NewBasePayloadMounter(
|
NewRawMessageLoader(backend, payload, config),
|
||||||
NewRawMessageLoader(backend, payload, config),
|
NewRawMessagePayloadMarshaller(payload),
|
||||||
NewRawMessagePayloadMarshaller(payload),
|
pe,
|
||||||
pe,
|
)
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type RawMessageLoader struct {
|
type RawMessageLoader struct {
|
||||||
|
@ -194,21 +184,17 @@ func (r *RawMessageLoader) Load() (err error) {
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
type InstallationPayloadMounter struct {
|
// NewInstallationPayloadMounter generates a new and initialised InstallationPayloadMounter
|
||||||
*BasePayloadMounter
|
// responsible for the whole lifecycle of an InstallationPayload
|
||||||
}
|
func NewInstallationPayloadMounter(logger *zap.Logger, pe *PayloadEncryptor, backend *api.GethStatusBackend, deviceType string) *BasePayloadMounter {
|
||||||
|
|
||||||
func NewInstallationPayloadMounter(logger *zap.Logger, pe *PayloadEncryptor, backend *api.GethStatusBackend, deviceType string) *InstallationPayloadMounter {
|
|
||||||
pe = pe.Renew()
|
pe = pe.Renew()
|
||||||
payload := new(protobuf.SyncRawMessage)
|
payload := new(protobuf.SyncRawMessage)
|
||||||
|
|
||||||
return &InstallationPayloadMounter{
|
return NewBasePayloadMounter(
|
||||||
BasePayloadMounter: NewBasePayloadMounter(
|
NewInstallationPayloadLoader(backend, payload, deviceType),
|
||||||
NewInstallationPayloadLoader(backend, payload, deviceType),
|
NewRawMessagePayloadMarshaller(payload),
|
||||||
NewRawMessagePayloadMarshaller(payload),
|
pe,
|
||||||
pe,
|
)
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type InstallationPayloadLoader struct {
|
type InstallationPayloadLoader struct {
|
||||||
|
@ -244,7 +230,9 @@ func (r *InstallationPayloadLoader) Load() error {
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func NewPayloadMounters(logger *zap.Logger, pe *PayloadEncryptor, backend *api.GethStatusBackend, config *SenderConfig) (*AccountPayloadMounter, *RawMessagePayloadMounter, *InstallationPayloadMounterReceiver, error) {
|
// NewPayloadMounters returns PayloadMounter s configured to handle local pairing transfers of:
|
||||||
|
// - AccountPayload, RawMessagePayload and InstallationPayload
|
||||||
|
func NewPayloadMounters(logger *zap.Logger, pe *PayloadEncryptor, backend *api.GethStatusBackend, config *SenderConfig) (PayloadMounter, PayloadMounter, *InstallationPayloadMounterReceiver, error) {
|
||||||
am, err := NewAccountPayloadMounter(pe, config, logger)
|
am, err := NewAccountPayloadMounter(pe, config, logger)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
|
|
|
@ -112,7 +112,7 @@ func MakeServerConfig(config *ServerConfig) error {
|
||||||
type SenderServer struct {
|
type SenderServer struct {
|
||||||
*BaseServer
|
*BaseServer
|
||||||
accountMounter PayloadMounter
|
accountMounter PayloadMounter
|
||||||
rawMessageMounter *RawMessagePayloadMounter
|
rawMessageMounter PayloadMounter
|
||||||
installationMounter *InstallationPayloadMounterReceiver
|
installationMounter *InstallationPayloadMounterReceiver
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue