refactor: remove always nil `shard` parameter in `HandleCommunityDescriptionMessage`

This commit is contained in:
Patryk Osmaczko 2023-10-30 09:22:19 +01:00 committed by osmaczko
parent c1a6771977
commit 627ac9449b
3 changed files with 8 additions and 9 deletions

View File

@ -462,7 +462,7 @@ func (m *Manager) runOwnerVerificationLoop() {
}
// TODO: handle shards
response, err := m.HandleCommunityDescriptionMessage(signer, description, communityToValidate.payload, nil, ownerPK)
response, err := m.HandleCommunityDescriptionMessage(signer, description, communityToValidate.payload, ownerPK)
if err != nil {
m.logger.Error("failed to handle community", zap.Error(err))
continue
@ -1538,7 +1538,7 @@ func (m *Manager) Queue(signer *ecdsa.PublicKey, community *Community, clock uin
return nil
}
func (m *Manager) HandleCommunityDescriptionMessage(signer *ecdsa.PublicKey, description *protobuf.CommunityDescription, payload []byte, shard *common.Shard, verifiedOwner *ecdsa.PublicKey) (*CommunityResponse, error) {
func (m *Manager) HandleCommunityDescriptionMessage(signer *ecdsa.PublicKey, description *protobuf.CommunityDescription, payload []byte, verifiedOwner *ecdsa.PublicKey) (*CommunityResponse, error) {
if signer == nil {
return nil, errors.New("signer can't be nil")
}
@ -1577,7 +1577,6 @@ func (m *Manager) HandleCommunityDescriptionMessage(signer *ecdsa.PublicKey, des
Logger: m.logger,
CommunityDescriptionProtocolMessage: payload,
MemberIdentity: &m.identity.PublicKey,
Shard: shard,
ID: pubKey,
ControlNode: signer,
}

View File

@ -1611,7 +1611,7 @@ func (s *ManagerSuite) TestCommunityQueue() {
subscription := m.Subscribe()
response, err := m.HandleCommunityDescriptionMessage(&notTheOwner.PublicKey, description, payload, nil, nil)
response, err := m.HandleCommunityDescriptionMessage(&notTheOwner.PublicKey, description, payload, nil)
s.Require().NoError(err)
// No response, as it should be queued
@ -1703,7 +1703,7 @@ func (s *ManagerSuite) TestCommunityQueueMultipleDifferentSigners() {
subscription := m.Subscribe()
response, err := m.HandleCommunityDescriptionMessage(&oldOwner.PublicKey, description, payload, nil, nil)
response, err := m.HandleCommunityDescriptionMessage(&oldOwner.PublicKey, description, payload, nil)
s.Require().NoError(err)
// No response, as it should be queued
@ -1721,7 +1721,7 @@ func (s *ManagerSuite) TestCommunityQueueMultipleDifferentSigners() {
payload, err = v1.WrapMessageV1(payload, protobuf.ApplicationMetadataMessage_COMMUNITY_DESCRIPTION, newOwner)
s.Require().NoError(err)
response, err = m.HandleCommunityDescriptionMessage(&newOwner.PublicKey, description, payload, nil, nil)
response, err = m.HandleCommunityDescriptionMessage(&newOwner.PublicKey, description, payload, nil)
s.Require().NoError(err)
// No response, as it should be queued
@ -1833,7 +1833,7 @@ func (s *ManagerSuite) TestCommunityQueueMultipleDifferentSignersIgnoreIfNotRetu
subscription := m.Subscribe()
response, err := m.HandleCommunityDescriptionMessage(&oldOwner.PublicKey, description, payload, nil, nil)
response, err := m.HandleCommunityDescriptionMessage(&oldOwner.PublicKey, description, payload, nil)
s.Require().NoError(err)
// No response, as it should be queued
@ -1849,7 +1849,7 @@ func (s *ManagerSuite) TestCommunityQueueMultipleDifferentSignersIgnoreIfNotRetu
payload, err = v1.WrapMessageV1(payload, protobuf.ApplicationMetadataMessage_COMMUNITY_DESCRIPTION, newOwner)
s.Require().NoError(err)
response, err = m.HandleCommunityDescriptionMessage(&newOwner.PublicKey, description, payload, nil, nil)
response, err = m.HandleCommunityDescriptionMessage(&newOwner.PublicKey, description, payload, nil)
s.Require().NoError(err)
// No response, as it should be queued

View File

@ -2866,7 +2866,7 @@ func (m *Messenger) passStoredCommunityInfoToSignalHandler(communityID string) {
// handleCommunityDescription handles an community description
func (m *Messenger) handleCommunityDescription(state *ReceivedMessageState, signer *ecdsa.PublicKey, description *protobuf.CommunityDescription, rawPayload []byte) error {
communityResponse, err := m.communitiesManager.HandleCommunityDescriptionMessage(signer, description, rawPayload, nil, nil)
communityResponse, err := m.communitiesManager.HandleCommunityDescriptionMessage(signer, description, rawPayload, nil)
if err != nil {
return err
}