File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,12 @@ pub struct ChainAnchor {
16
16
pub height : u32 ,
17
17
}
18
18
19
+ pub const RESERVED_SPACES : [ & ' static [ u8 ] ; 3 ] = [
20
+ b"\x07 example" ,
21
+ b"\x04 test" ,
22
+ b"\x04 local" ,
23
+ ] ;
24
+
19
25
/// The number of blocks between each rollout of new spaces for auction.
20
26
pub const ROLLOUT_BLOCK_INTERVAL : u32 = 144 ;
21
27
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ use crate::{
18
18
validate:: RejectParams ,
19
19
FullSpaceOut ,
20
20
} ;
21
+ use crate :: constants:: RESERVED_SPACES ;
21
22
22
23
/// Ways that a script might fail. Not everything is split up as
23
24
/// much as it could be; patches welcome if more detailed errors
@@ -32,6 +33,7 @@ use crate::{
32
33
#[ non_exhaustive]
33
34
pub enum ScriptError {
34
35
MalformedName ,
36
+ ReservedName ,
35
37
Reject ( RejectParams ) ,
36
38
}
37
39
@@ -138,6 +140,10 @@ impl SpaceScript {
138
140
}
139
141
let name = name. unwrap ( ) ;
140
142
143
+ if RESERVED_SPACES . iter ( ) . any ( |reserved| * reserved == name. as_ref ( ) ) {
144
+ return Ok ( Err ( ScriptError :: ReservedName ) ) ;
145
+ }
146
+
141
147
let kind = {
142
148
let spacehash = SpaceKey :: from ( H :: hash ( name. as_ref ( ) ) ) ;
143
149
let existing = src. get_space_outpoint ( & spacehash) ?;
@@ -186,6 +192,7 @@ impl core::fmt::Display for ScriptError {
186
192
187
193
match * self {
188
194
MalformedName => f. write_str ( "malformed name" ) ,
195
+ ReservedName => f. write_str ( "reserved name" ) ,
189
196
Reject ( _) => f. write_str ( "rejected" ) ,
190
197
}
191
198
}
You can’t perform that action at this time.
0 commit comments