Skip to content

Commit

Permalink
Merge pull request open-horizon#3948 from LiilyZhang/zhangl/debugNilP…
Browse files Browse the repository at this point in the history
…ointer

Issue3949 - Bug: Agbot panic after receiving several rejection reply
  • Loading branch information
LiilyZhang authored Nov 16, 2023
2 parents 51d127e + 3526b64 commit 66fd586
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions agreementbot/basic_protocol_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type BasicProtocolHandler struct {
Work *PrioritizedWorkQueue
}

func NewBasicProtocolHandler(name string, cfg *config.HorizonConfig, db persistence.AgbotDatabase, pm *policy.PolicyManager, messages chan events.Message, mmsObjMgr *MMSObjectPolicyManager, secretsMgr secrets.AgbotSecrets) *BasicProtocolHandler {
func NewBasicProtocolHandler(name string, cfg *config.HorizonConfig, db persistence.AgbotDatabase, pm *policy.PolicyManager, messages chan events.Message, mmsObjMgr *MMSObjectPolicyManager, secretsMgr secrets.AgbotSecrets, nodeSearch *NodeSearch) *BasicProtocolHandler {
if name == basicprotocol.PROTOCOL_NAME {
return &BasicProtocolHandler{
BaseConsumerProtocolHandler: &BaseConsumerProtocolHandler{
Expand All @@ -39,6 +39,7 @@ func NewBasicProtocolHandler(name string, cfg *config.HorizonConfig, db persiste
messages: messages,
mmsObjMgr: mmsObjMgr,
secretsMgr: secretsMgr,
nodeSearch: nodeSearch,
},
agreementPH: basicprotocol.NewProtocolHandler(cfg.Collaborators.HTTPClientFactory.NewHTTPClient(nil), pm),
// Allow the main agbot thread to distribute protocol msgs and agreement handling to the worker pool.
Expand Down Expand Up @@ -68,7 +69,7 @@ func (c *BasicProtocolHandler) Initialize() {

// Set up agreement worker pool based on the current technical config.
for ix := 0; ix < c.config.AgreementBot.AgreementWorkers; ix++ {
agw := NewBasicAgreementWorker(c, c.config, c.db, c.pm, agreementLockMgr, c.mmsObjMgr, c.secretsMgr, c.NodeSearch)
agw := NewBasicAgreementWorker(c, c.config, c.db, c.pm, agreementLockMgr, c.mmsObjMgr, c.secretsMgr, c.nodeSearch)
go agw.start(c.Work, random)
}

Expand Down
4 changes: 2 additions & 2 deletions agreementbot/consumer_protocol_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

func CreateConsumerPH(name string, cfg *config.HorizonConfig, db persistence.AgbotDatabase, pm *policy.PolicyManager, msgq chan events.Message, mmsObjMgr *MMSObjectPolicyManager, secretsMgr secrets.AgbotSecrets, nodeSearch *NodeSearch) ConsumerProtocolHandler {
if handler := NewBasicProtocolHandler(name, cfg, db, pm, msgq, mmsObjMgr, secretsMgr); handler != nil {
if handler := NewBasicProtocolHandler(name, cfg, db, pm, msgq, mmsObjMgr, secretsMgr, nodeSearch); handler != nil {
return handler
} // Add new consumer side protocol handlers here
return nil
Expand Down Expand Up @@ -98,7 +98,7 @@ type BaseConsumerProtocolHandler struct {
messages chan events.Message
mmsObjMgr *MMSObjectPolicyManager
secretsMgr secrets.AgbotSecrets
NodeSearch *NodeSearch
nodeSearch *NodeSearch
}

func (b *BaseConsumerProtocolHandler) GetSendMessage() func(mt interface{}, pay []byte) error {
Expand Down

0 comments on commit 66fd586

Please sign in to comment.