Skip to content

Commit

Permalink
morph/notary: Allow waiting for notary request inclusion
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
  • Loading branch information
carpawell committed Dec 18, 2024
1 parent 59cebb3 commit 4e14e43
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pkg/innerring/processors/container/process_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (cp *Processor) approvePutContainer(ctx *putContainerContext) {
prm.SetZone(ctx.d.Zone())

nr := e.NotaryRequest()
err = cp.cnrClient.Morph().NotarySignAndInvokeTX(nr.MainTransaction)
err = cp.cnrClient.Morph().NotarySignAndInvokeTX(nr.MainTransaction, false)

if err != nil {
cp.log.Error("could not approve put container",
Expand Down Expand Up @@ -175,7 +175,7 @@ func (cp *Processor) approveDeleteContainer(e *containerEvent.Delete) {
prm.SetToken(e.SessionToken())

nr := e.NotaryRequest()
err = cp.cnrClient.Morph().NotarySignAndInvokeTX(nr.MainTransaction)
err = cp.cnrClient.Morph().NotarySignAndInvokeTX(nr.MainTransaction, false)

if err != nil {
cp.log.Error("could not approve delete container",
Expand Down
2 changes: 1 addition & 1 deletion pkg/innerring/processors/container/process_eacl.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (cp *Processor) approveSetEACL(e container.SetEACL) {
prm.SetToken(e.SessionToken())

nr := e.NotaryRequest()
err = cp.cnrClient.Morph().NotarySignAndInvokeTX(nr.MainTransaction)
err = cp.cnrClient.Morph().NotarySignAndInvokeTX(nr.MainTransaction, false)

if err != nil {
cp.log.Error("could not approve set EACL",
Expand Down
4 changes: 2 additions & 2 deletions pkg/innerring/processors/netmap/process_peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (np *Processor) processAddPeer(ev netmapEvent.AddPeer) {
np.log.Info("approving network map candidate",
zap.String("key", keyString))

err = np.netmapClient.Morph().NotarySignAndInvokeTX(tx)
err = np.netmapClient.Morph().NotarySignAndInvokeTX(tx, false)
if err != nil {
np.log.Error("can't sign and send notary request calling netmap.AddPeer", zap.Error(err))
}
Expand Down Expand Up @@ -93,7 +93,7 @@ func (np *Processor) processUpdatePeer(ev netmapEvent.UpdatePeer) {
}

nr := ev.NotaryRequest()
err = np.netmapClient.Morph().NotarySignAndInvokeTX(nr.MainTransaction)
err = np.netmapClient.Morph().NotarySignAndInvokeTX(nr.MainTransaction, false)

if err != nil {
np.log.Error("can't invoke netmap.UpdatePeer", zap.Error(err))
Expand Down
2 changes: 1 addition & 1 deletion pkg/innerring/processors/reputation/process_put.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (rp *Processor) approvePutReputation(e *reputationEvent.Put) {
nr = e.NotaryRequest()
)

err = rp.reputationWrp.Morph().NotarySignAndInvokeTX(nr.MainTransaction)
err = rp.reputationWrp.Morph().NotarySignAndInvokeTX(nr.MainTransaction, false)

if err != nil {
rp.log.Warn("can't send approval tx for reputation value",
Expand Down
5 changes: 4 additions & 1 deletion pkg/morph/client/notary.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ func (c *Client) NotaryInvokeNotAlpha(contract util.Uint160, fee fixedn.Fixed8,
// Notary service.
// NOTE: does not fallback to simple `Invoke()`. Expected to be used only for
// TXs retrieved from the received notary requests.
func (c *Client) NotarySignAndInvokeTX(mainTx *transaction.Transaction) error {
func (c *Client) NotarySignAndInvokeTX(mainTx *transaction.Transaction, await bool) error {
var conn = c.conn.Load()

if conn == nil {
Expand Down Expand Up @@ -424,6 +424,9 @@ func (c *Client) NotarySignAndInvokeTX(mainTx *transaction.Transaction) error {
fbTx.Nonce = binary.BigEndian.Uint32(mainH[:])

mainH, fbH, untilActual, err := nAct.SendRequest(mainTx, fbTx)
if await {
_, err = nAct.Wait(mainH, fbH, untilActual, err)
}
if err != nil && !alreadyOnChainError(err) {
return err
}
Expand Down

0 comments on commit 4e14e43

Please sign in to comment.