Skip to content

Commit d4844a3

Browse files
committed
slight fix
1 parent 74bed3b commit d4844a3

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

solana/observer.go

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -537,11 +537,6 @@ func (node *Node) handleUnconfirmedCalls(ctx context.Context) error {
537537
}
538538
} else {
539539
cid := common.UniqueId(id, "storage")
540-
nonce := node.ReadSpareNonceAccountWithCall(ctx, cid)
541-
err = node.store.OccupyNonceAccountByCall(ctx, nonce.Address, cid)
542-
if err != nil {
543-
return err
544-
}
545540
fee, err := node.getSystemCallFeeFromXIN(ctx, call)
546541
if err != nil {
547542
return err
@@ -551,6 +546,13 @@ func (node *Node) handleUnconfirmedCalls(ctx context.Context) error {
551546
return err
552547
}
553548
if tx != nil {
549+
nonce := node.ReadSpareNonceAccountWithCall(ctx, cid)
550+
if !nonce.CallId.Valid {
551+
err = node.store.OccupyNonceAccountByCall(ctx, nonce.Address, cid)
552+
if err != nil {
553+
return err
554+
}
555+
}
554556
tb, err := tx.MarshalBinary()
555557
if err != nil {
556558
panic(err)
@@ -808,9 +810,11 @@ func (node *Node) processSuccessedCall(ctx context.Context, call *store.SystemCa
808810
nonce := node.ReadSpareNonceAccountWithCall(ctx, cid)
809811
tx := node.CreatePostProcessTransaction(ctx, call, nonce, txx, meta)
810812
if tx != nil {
811-
err := node.store.OccupyNonceAccountByCall(ctx, nonce.Address, cid)
812-
if err != nil {
813-
return err
813+
if !nonce.CallId.Valid {
814+
err := node.store.OccupyNonceAccountByCall(ctx, nonce.Address, cid)
815+
if err != nil {
816+
return err
817+
}
814818
}
815819
data, err := tx.MarshalBinary()
816820
if err != nil {
@@ -838,9 +842,11 @@ func (node *Node) processFailedCall(ctx context.Context, call *store.SystemCall,
838842
nonce := node.ReadSpareNonceAccountWithCall(ctx, cid)
839843
tx := node.CreatePostProcessTransaction(ctx, call, nonce, nil, nil)
840844
if tx != nil {
841-
err := node.store.OccupyNonceAccountByCall(ctx, nonce.Address, cid)
842-
if err != nil {
843-
return err
845+
if !nonce.CallId.Valid {
846+
err := node.store.OccupyNonceAccountByCall(ctx, nonce.Address, cid)
847+
if err != nil {
848+
return err
849+
}
844850
}
845851
data, err := tx.MarshalBinary()
846852
if err != nil {

0 commit comments

Comments
 (0)