Skip to content

Commit 537ff66

Browse files
caseyharutyunaraci
authored andcommitted
Terms::limit → Terms::amount (ordinals#3383)
1 parent 4015010 commit 537ff66

File tree

16 files changed

+138
-133
lines changed

16 files changed

+138
-133
lines changed

src/index/entry.rs

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,16 @@ impl RuneEntry {
6767
return Err(MintError::Cap(cap));
6868
}
6969

70-
Ok(terms.limit.unwrap_or_default())
70+
Ok(terms.amount.unwrap_or_default())
7171
}
7272

7373
pub fn supply(&self) -> u128 {
74-
self.premine + self.mints * self.terms.and_then(|terms| terms.limit).unwrap_or_default()
74+
self.premine
75+
+ self.mints
76+
* self
77+
.terms
78+
.and_then(|terms| terms.amount)
79+
.unwrap_or_default()
7580
}
7681

7782
pub fn pile(&self, amount: u128) -> Pile {
@@ -120,7 +125,7 @@ impl RuneEntry {
120125
type TermsEntryValue = (
121126
Option<u128>, // cap
122127
(Option<u64>, Option<u64>), // height
123-
Option<u128>, // limit
128+
Option<u128>, // amount
124129
(Option<u64>, Option<u64>), // offset
125130
);
126131

@@ -196,10 +201,10 @@ impl Entry for RuneEntry {
196201
spacers,
197202
},
198203
symbol,
199-
terms: terms.map(|(cap, height, limit, offset)| Terms {
204+
terms: terms.map(|(cap, height, amount, offset)| Terms {
200205
cap,
201206
height,
202-
limit,
207+
amount,
203208
offset,
204209
}),
205210
timestamp,
@@ -233,9 +238,9 @@ impl Entry for RuneEntry {
233238
|Terms {
234239
cap,
235240
height,
236-
limit,
241+
amount,
237242
offset,
238-
}| (cap, height, limit, offset),
243+
}| (cap, height, amount, offset),
239244
),
240245
self.timestamp,
241246
)
@@ -543,7 +548,7 @@ mod tests {
543548
terms: Some(Terms {
544549
cap: Some(1),
545550
height: (Some(2), Some(3)),
546-
limit: Some(4),
551+
amount: Some(4),
547552
offset: (Some(5), Some(6)),
548553
}),
549554
mints: 11,
@@ -611,7 +616,7 @@ mod tests {
611616
RuneEntry {
612617
terms: Some(Terms {
613618
cap: Some(1),
614-
limit: Some(1000),
619+
amount: Some(1000),
615620
..default()
616621
}),
617622
mints: 0,
@@ -625,7 +630,7 @@ mod tests {
625630
RuneEntry {
626631
terms: Some(Terms {
627632
cap: Some(1),
628-
limit: Some(1000),
633+
amount: Some(1000),
629634
..default()
630635
}),
631636
mints: 1,
@@ -639,7 +644,7 @@ mod tests {
639644
RuneEntry {
640645
terms: Some(Terms {
641646
cap: None,
642-
limit: Some(1000),
647+
amount: Some(1000),
643648
..default()
644649
}),
645650
mints: 0,
@@ -657,7 +662,7 @@ mod tests {
657662
block: 1,
658663
terms: Some(Terms {
659664
cap: Some(1),
660-
limit: Some(1000),
665+
amount: Some(1000),
661666
offset: (Some(1), None),
662667
..default()
663668
}),
@@ -673,7 +678,7 @@ mod tests {
673678
block: 1,
674679
terms: Some(Terms {
675680
cap: Some(1),
676-
limit: Some(1000),
681+
amount: Some(1000),
677682
offset: (Some(1), None),
678683
..default()
679684
}),
@@ -692,7 +697,7 @@ mod tests {
692697
block: 1,
693698
terms: Some(Terms {
694699
cap: Some(1),
695-
limit: Some(1000),
700+
amount: Some(1000),
696701
offset: (None, Some(1)),
697702
..default()
698703
}),
@@ -708,7 +713,7 @@ mod tests {
708713
block: 1,
709714
terms: Some(Terms {
710715
cap: Some(1),
711-
limit: Some(1000),
716+
amount: Some(1000),
712717
offset: (None, Some(1)),
713718
..default()
714719
}),
@@ -726,7 +731,7 @@ mod tests {
726731
RuneEntry {
727732
terms: Some(Terms {
728733
cap: Some(1),
729-
limit: Some(1000),
734+
amount: Some(1000),
730735
height: (Some(1), None),
731736
..default()
732737
}),
@@ -741,7 +746,7 @@ mod tests {
741746
RuneEntry {
742747
terms: Some(Terms {
743748
cap: Some(1),
744-
limit: Some(1000),
749+
amount: Some(1000),
745750
height: (Some(1), None),
746751
..default()
747752
}),
@@ -759,7 +764,7 @@ mod tests {
759764
RuneEntry {
760765
terms: Some(Terms {
761766
cap: Some(1),
762-
limit: Some(1000),
767+
amount: Some(1000),
763768
height: (None, Some(1)),
764769
..default()
765770
}),
@@ -774,7 +779,7 @@ mod tests {
774779
RuneEntry {
775780
terms: Some(Terms {
776781
cap: Some(1),
777-
limit: Some(1000),
782+
amount: Some(1000),
778783
height: (None, Some(1)),
779784
..default()
780785
}),
@@ -791,7 +796,7 @@ mod tests {
791796
let entry = RuneEntry {
792797
terms: Some(Terms {
793798
cap: Some(1),
794-
limit: Some(1000),
799+
amount: Some(1000),
795800
height: (Some(10), Some(20)),
796801
offset: (Some(0), Some(10)),
797802
}),
@@ -838,7 +843,7 @@ mod tests {
838843
assert_eq!(
839844
RuneEntry {
840845
terms: Some(Terms {
841-
limit: Some(1000),
846+
amount: Some(1000),
842847
..default()
843848
}),
844849
mints: 0,
@@ -851,7 +856,7 @@ mod tests {
851856
assert_eq!(
852857
RuneEntry {
853858
terms: Some(Terms {
854-
limit: Some(1000),
859+
amount: Some(1000),
855860
..default()
856861
}),
857862
mints: 1,
@@ -864,7 +869,7 @@ mod tests {
864869
assert_eq!(
865870
RuneEntry {
866871
terms: Some(Terms {
867-
limit: Some(1000),
872+
amount: Some(1000),
868873
..default()
869874
}),
870875
mints: 0,
@@ -878,7 +883,7 @@ mod tests {
878883
assert_eq!(
879884
RuneEntry {
880885
terms: Some(Terms {
881-
limit: Some(1000),
886+
amount: Some(1000),
882887
..default()
883888
}),
884889
mints: 1,

src/index/updater/rune_updater.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use {
55

66
struct Mint {
77
id: RuneId,
8-
limit: u128,
8+
amount: u128,
99
}
1010

1111
struct Etched {
@@ -54,7 +54,7 @@ impl<'a, 'tx, 'client> RuneUpdater<'a, 'tx, 'client> {
5454
.and_then(|id| self.mint(id).transpose())
5555
.transpose()?
5656
{
57-
*unallocated.entry(mint.id).or_default() += mint.limit;
57+
*unallocated.entry(mint.id).or_default() += mint.amount;
5858
}
5959

6060
let etched = self.etched(tx_index, tx, &runestone)?;
@@ -337,7 +337,7 @@ impl<'a, 'tx, 'client> RuneUpdater<'a, 'tx, 'client> {
337337

338338
let mut rune_entry = RuneEntry::load(entry.value());
339339

340-
let Ok(limit) = rune_entry.mintable(self.height.into()) else {
340+
let Ok(amount) = rune_entry.mintable(self.height.into()) else {
341341
return Ok(None);
342342
};
343343

@@ -347,7 +347,7 @@ impl<'a, 'tx, 'client> RuneUpdater<'a, 'tx, 'client> {
347347

348348
self.id_to_entry.insert(&id.store(), rune_entry.store())?;
349349

350-
Ok(Some(Mint { id, limit }))
350+
Ok(Some(Mint { id, amount }))
351351
}
352352

353353
fn tx_commits_to_rune(&self, tx: &Transaction, rune: Rune) -> Result<bool> {

0 commit comments

Comments
 (0)