@@ -537,11 +537,6 @@ func (node *Node) handleUnconfirmedCalls(ctx context.Context) error {
537
537
}
538
538
} else {
539
539
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
- }
545
540
fee , err := node .getSystemCallFeeFromXIN (ctx , call )
546
541
if err != nil {
547
542
return err
@@ -551,6 +546,13 @@ func (node *Node) handleUnconfirmedCalls(ctx context.Context) error {
551
546
return err
552
547
}
553
548
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
+ }
554
556
tb , err := tx .MarshalBinary ()
555
557
if err != nil {
556
558
panic (err )
@@ -808,9 +810,11 @@ func (node *Node) processSuccessedCall(ctx context.Context, call *store.SystemCa
808
810
nonce := node .ReadSpareNonceAccountWithCall (ctx , cid )
809
811
tx := node .CreatePostProcessTransaction (ctx , call , nonce , txx , meta )
810
812
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
+ }
814
818
}
815
819
data , err := tx .MarshalBinary ()
816
820
if err != nil {
@@ -838,9 +842,11 @@ func (node *Node) processFailedCall(ctx context.Context, call *store.SystemCall,
838
842
nonce := node .ReadSpareNonceAccountWithCall (ctx , cid )
839
843
tx := node .CreatePostProcessTransaction (ctx , call , nonce , nil , nil )
840
844
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
+ }
844
850
}
845
851
data , err := tx .MarshalBinary ()
846
852
if err != nil {
0 commit comments