chore: omit `CommunityDescription` queuing if owner is already verified
This commit is contained in:
parent
42527723f2
commit
05db628406
|
@ -1308,6 +1308,9 @@ func (o *Community) setPrivateKey(pk *ecdsa.PrivateKey) {
|
|||
}
|
||||
|
||||
func (o *Community) ControlNode() *ecdsa.PublicKey {
|
||||
if o.config.ControlNode == nil {
|
||||
return o.config.ID
|
||||
}
|
||||
return o.config.ControlNode
|
||||
}
|
||||
|
||||
|
|
|
@ -1545,19 +1545,21 @@ func (m *Manager) HandleCommunityDescriptionMessage(signer *ecdsa.PublicKey, des
|
|||
}
|
||||
|
||||
// A new community, we need to check if we need to validate async.
|
||||
// That would be the case if it has a contract. We queue everything and process separately
|
||||
|
||||
// That would be the case if it has a contract. We queue everything and process separately.
|
||||
if shouldQueue {
|
||||
return nil, m.Queue(signer, community, description.Clock, payload)
|
||||
}
|
||||
|
||||
} else {
|
||||
// we only queue if the clock is greater
|
||||
if shouldQueue && community.config.CommunityDescription.Clock < description.Clock {
|
||||
// only queue if already known control node is different than the signer
|
||||
// and if the clock is greater
|
||||
shouldQueue = shouldQueue && !common.IsPubKeyEqual(community.ControlNode(), signer) &&
|
||||
community.config.CommunityDescription.Clock < description.Clock
|
||||
if shouldQueue {
|
||||
return nil, m.Queue(signer, community, description.Clock, payload)
|
||||
}
|
||||
}
|
||||
|
||||
if hasTokenOwnership {
|
||||
// Override verified owner
|
||||
if verifiedOwner != nil {
|
||||
m.logger.Info("updating verified owner", zap.String("communityID", community.IDString()), zap.String("owner", common.PubkeyToHex(verifiedOwner)))
|
||||
|
@ -1569,12 +1571,10 @@ func (m *Manager) HandleCommunityDescriptionMessage(signer *ecdsa.PublicKey, des
|
|||
|
||||
community.setControlNode(verifiedOwner)
|
||||
}
|
||||
|
||||
// If it has token ownership, we check the control node
|
||||
// otherwise we check the public key
|
||||
if hasTokenOwnership && !common.IsPubKeyEqual(community.ControlNode(), signer) {
|
||||
if !common.IsPubKeyEqual(community.ControlNode(), signer) {
|
||||
return nil, ErrNotAuthorized
|
||||
} else if !hasTokenOwnership && !common.IsPubKeyEqual(community.PublicKey(), signer) {
|
||||
}
|
||||
} else if !common.IsPubKeyEqual(community.PublicKey(), signer) {
|
||||
return nil, ErrNotAuthorized
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue