Skip to content

Commit 9868d57

Browse files
committed
crc: improved cost for update-recipient and validate-caller
1 parent 00c6b1a commit 9868d57

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

stackslib/src/chainstate/stacks/boot/sip-031.clar

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,15 @@
3535
;;
3636
;; Returns `true` if the recipient was updated.
3737
(define-public (update-recipient (new-recipient principal)) (begin
38-
(let
39-
(
40-
(old-recipient (var-get recipient))
41-
)
38+
(begin
4239
(try! (validate-caller))
43-
(var-set recipient new-recipient)
4440
(print {
4541
topic: "update-recipient",
46-
old-recipient: old-recipient,
42+
old-recipient: (var-get recipient),
4743
new-recipient: new-recipient,
4844
})
49-
(ok true)
50-
)
45+
(var-set recipient new-recipient)
46+
(ok true))
5147
))
5248

5349
;; Transfer all currently withdrawable STX (vested + extra) to `recipient`.
@@ -71,10 +67,9 @@
7167
)
7268

7369
(define-private (validate-caller)
74-
(begin
75-
(asserts! (is-eq contract-caller (var-get recipient)) (err ERR_NOT_ALLOWED))
76-
(asserts! (is-eq tx-sender (var-get recipient)) (err ERR_NOT_ALLOWED))
77-
(ok true))
70+
(if (is-eq (var-get recipient) contract-caller tx-sender)
71+
(ok true)
72+
(err ERR_NOT_ALLOWED))
7873
)
7974

8075
;; Returns the *total* vested amount at `burn-height`, i.e.

0 commit comments

Comments
 (0)