feat(lns): add metadata getter aliases
This commit is contained in:
parent
e8d7f79109
commit
797267d27c
2 changed files with 143 additions and 0 deletions
91
lns.go
91
lns.go
|
|
@ -597,6 +597,13 @@ func (s *Service) ReservedSize() int {
|
|||
return s.ReservedCatalog().Size()
|
||||
}
|
||||
|
||||
// GetReservedSize is an alias for ReservedSize.
|
||||
//
|
||||
// size := svc.GetReservedSize()
|
||||
func (s *Service) GetReservedSize() int {
|
||||
return s.ReservedSize()
|
||||
}
|
||||
|
||||
// ReservedNameValue reports the base value used for reserved-name lookups.
|
||||
//
|
||||
// base := svc.ReservedNameValue()
|
||||
|
|
@ -604,6 +611,13 @@ func (s *Service) ReservedNameValue() uint64 {
|
|||
return s.ReservedCatalog().NameValue()
|
||||
}
|
||||
|
||||
// GetReservedNameValue is an alias for ReservedNameValue.
|
||||
//
|
||||
// base := svc.GetReservedNameValue()
|
||||
func (s *Service) GetReservedNameValue() uint64 {
|
||||
return s.ReservedNameValue()
|
||||
}
|
||||
|
||||
// ReservedRootValue reports the root-name increment used for reserved-name lookups.
|
||||
//
|
||||
// root := svc.ReservedRootValue()
|
||||
|
|
@ -611,6 +625,13 @@ func (s *Service) ReservedRootValue() uint64 {
|
|||
return s.ReservedCatalog().RootValue()
|
||||
}
|
||||
|
||||
// GetReservedRootValue is an alias for ReservedRootValue.
|
||||
//
|
||||
// root := svc.GetReservedRootValue()
|
||||
func (s *Service) GetReservedRootValue() uint64 {
|
||||
return s.ReservedRootValue()
|
||||
}
|
||||
|
||||
// ReservedTopValue reports the top-100 increment used for reserved-name lookups.
|
||||
//
|
||||
// top := svc.ReservedTopValue()
|
||||
|
|
@ -618,6 +639,13 @@ func (s *Service) ReservedTopValue() uint64 {
|
|||
return s.ReservedCatalog().TopValue()
|
||||
}
|
||||
|
||||
// GetReservedTopValue is an alias for ReservedTopValue.
|
||||
//
|
||||
// top := svc.GetReservedTopValue()
|
||||
func (s *Service) GetReservedTopValue() uint64 {
|
||||
return s.ReservedTopValue()
|
||||
}
|
||||
|
||||
// ReservedEntries exposes the reserved-name catalog entries used by the service.
|
||||
//
|
||||
// entries := svc.ReservedEntries()
|
||||
|
|
@ -625,6 +653,13 @@ func (s *Service) ReservedEntries() []covenant.ReservedEntry {
|
|||
return s.ReservedCatalog().Entries()
|
||||
}
|
||||
|
||||
// GetReservedEntries is an alias for ReservedEntries.
|
||||
//
|
||||
// entries := svc.GetReservedEntries()
|
||||
func (s *Service) GetReservedEntries() []covenant.ReservedEntry {
|
||||
return s.ReservedEntries()
|
||||
}
|
||||
|
||||
// ReservedKeys exposes the reserved-name hashes used by the service.
|
||||
//
|
||||
// keys := svc.ReservedKeys()
|
||||
|
|
@ -632,6 +667,13 @@ func (s *Service) ReservedKeys() []primitives.Hash {
|
|||
return s.ReservedCatalog().Keys()
|
||||
}
|
||||
|
||||
// GetReservedKeys is an alias for ReservedKeys.
|
||||
//
|
||||
// keys := svc.GetReservedKeys()
|
||||
func (s *Service) GetReservedKeys() []primitives.Hash {
|
||||
return s.ReservedKeys()
|
||||
}
|
||||
|
||||
// ReservedValues exposes the reserved-name entries used by the service.
|
||||
//
|
||||
// values := svc.ReservedValues()
|
||||
|
|
@ -639,6 +681,13 @@ func (s *Service) ReservedValues() []covenant.ReservedName {
|
|||
return s.ReservedCatalog().Values()
|
||||
}
|
||||
|
||||
// GetReservedValues is an alias for ReservedValues.
|
||||
//
|
||||
// values := svc.GetReservedValues()
|
||||
func (s *Service) GetReservedValues() []covenant.ReservedName {
|
||||
return s.ReservedValues()
|
||||
}
|
||||
|
||||
// LockedCatalog exposes the locked-name catalog used by the service.
|
||||
//
|
||||
// The returned catalog provides deterministic iteration helpers so callers can
|
||||
|
|
@ -664,6 +713,13 @@ func (s *Service) LockedSize() int {
|
|||
return s.LockedCatalog().Size()
|
||||
}
|
||||
|
||||
// GetLockedSize is an alias for LockedSize.
|
||||
//
|
||||
// size := svc.GetLockedSize()
|
||||
func (s *Service) GetLockedSize() int {
|
||||
return s.LockedSize()
|
||||
}
|
||||
|
||||
// LockedPrefixSize reports the byte offset where locked-name entries begin in
|
||||
// the reference table.
|
||||
//
|
||||
|
|
@ -672,6 +728,13 @@ func (s *Service) LockedPrefixSize() int {
|
|||
return s.LockedCatalog().PrefixSize()
|
||||
}
|
||||
|
||||
// GetLockedPrefixSize is an alias for LockedPrefixSize.
|
||||
//
|
||||
// offset := svc.GetLockedPrefixSize()
|
||||
func (s *Service) GetLockedPrefixSize() int {
|
||||
return s.LockedPrefixSize()
|
||||
}
|
||||
|
||||
// ReservedPrefixSize reports the byte offset where reserved-name entries begin in
|
||||
// the reference table.
|
||||
//
|
||||
|
|
@ -680,6 +743,13 @@ func (s *Service) ReservedPrefixSize() int {
|
|||
return s.ReservedCatalog().PrefixSize()
|
||||
}
|
||||
|
||||
// GetReservedPrefixSize is an alias for ReservedPrefixSize.
|
||||
//
|
||||
// offset := svc.GetReservedPrefixSize()
|
||||
func (s *Service) GetReservedPrefixSize() int {
|
||||
return s.ReservedPrefixSize()
|
||||
}
|
||||
|
||||
// LockedEntries exposes the locked-name catalog entries used by the service.
|
||||
//
|
||||
// entries := svc.LockedEntries()
|
||||
|
|
@ -687,6 +757,13 @@ func (s *Service) LockedEntries() []covenant.LockedEntry {
|
|||
return s.LockedCatalog().Entries()
|
||||
}
|
||||
|
||||
// GetLockedEntries is an alias for LockedEntries.
|
||||
//
|
||||
// entries := svc.GetLockedEntries()
|
||||
func (s *Service) GetLockedEntries() []covenant.LockedEntry {
|
||||
return s.LockedEntries()
|
||||
}
|
||||
|
||||
// LockedKeys exposes the locked-name hashes used by the service.
|
||||
//
|
||||
// keys := svc.LockedKeys()
|
||||
|
|
@ -694,6 +771,13 @@ func (s *Service) LockedKeys() []primitives.Hash {
|
|||
return s.LockedCatalog().Keys()
|
||||
}
|
||||
|
||||
// GetLockedKeys is an alias for LockedKeys.
|
||||
//
|
||||
// keys := svc.GetLockedKeys()
|
||||
func (s *Service) GetLockedKeys() []primitives.Hash {
|
||||
return s.LockedKeys()
|
||||
}
|
||||
|
||||
// LockedValues exposes the locked-name entries used by the service.
|
||||
//
|
||||
// values := svc.LockedValues()
|
||||
|
|
@ -701,6 +785,13 @@ func (s *Service) LockedValues() []covenant.LockedName {
|
|||
return s.LockedCatalog().Values()
|
||||
}
|
||||
|
||||
// GetLockedValues is an alias for LockedValues.
|
||||
//
|
||||
// values := svc.GetLockedValues()
|
||||
func (s *Service) GetLockedValues() []covenant.LockedName {
|
||||
return s.LockedValues()
|
||||
}
|
||||
|
||||
func catalogLabel(name any) (string, bool) {
|
||||
switch v := name.(type) {
|
||||
case string:
|
||||
|
|
|
|||
52
lns_test.go
52
lns_test.go
|
|
@ -860,22 +860,42 @@ func TestServiceReservedCatalog(t *testing.T) {
|
|||
t.Fatalf("ReservedSize() = %d, want %d", got, catalog.Size())
|
||||
}
|
||||
|
||||
if got := svc.GetReservedSize(); got != catalog.Size() {
|
||||
t.Fatalf("GetReservedSize() = %d, want %d", got, catalog.Size())
|
||||
}
|
||||
|
||||
if got := svc.ReservedNameValue(); got != catalog.NameValue() {
|
||||
t.Fatalf("ReservedNameValue() = %d, want %d", got, catalog.NameValue())
|
||||
}
|
||||
|
||||
if got := svc.GetReservedNameValue(); got != catalog.NameValue() {
|
||||
t.Fatalf("GetReservedNameValue() = %d, want %d", got, catalog.NameValue())
|
||||
}
|
||||
|
||||
if got := svc.ReservedRootValue(); got != catalog.RootValue() {
|
||||
t.Fatalf("ReservedRootValue() = %d, want %d", got, catalog.RootValue())
|
||||
}
|
||||
|
||||
if got := svc.GetReservedRootValue(); got != catalog.RootValue() {
|
||||
t.Fatalf("GetReservedRootValue() = %d, want %d", got, catalog.RootValue())
|
||||
}
|
||||
|
||||
if got := svc.ReservedTopValue(); got != catalog.TopValue() {
|
||||
t.Fatalf("ReservedTopValue() = %d, want %d", got, catalog.TopValue())
|
||||
}
|
||||
|
||||
if got := svc.GetReservedTopValue(); got != catalog.TopValue() {
|
||||
t.Fatalf("GetReservedTopValue() = %d, want %d", got, catalog.TopValue())
|
||||
}
|
||||
|
||||
if got := svc.ReservedPrefixSize(); got != catalog.PrefixSize() {
|
||||
t.Fatalf("ReservedPrefixSize() = %d, want %d", got, catalog.PrefixSize())
|
||||
}
|
||||
|
||||
if got := svc.GetReservedPrefixSize(); got != catalog.PrefixSize() {
|
||||
t.Fatalf("GetReservedPrefixSize() = %d, want %d", got, catalog.PrefixSize())
|
||||
}
|
||||
|
||||
if !catalog.HasByName("RESERVED") {
|
||||
t.Fatal("ReservedCatalog should expose the reserved catalog helpers")
|
||||
}
|
||||
|
|
@ -900,13 +920,25 @@ func TestServiceReservedCatalog(t *testing.T) {
|
|||
t.Fatal("ReservedEntries should expose catalog entries")
|
||||
}
|
||||
|
||||
if len(svc.GetReservedEntries()) == 0 {
|
||||
t.Fatal("GetReservedEntries should expose catalog entries")
|
||||
}
|
||||
|
||||
if len(svc.ReservedKeys()) == 0 {
|
||||
t.Fatal("ReservedKeys should expose catalog keys")
|
||||
}
|
||||
|
||||
if len(svc.GetReservedKeys()) == 0 {
|
||||
t.Fatal("GetReservedKeys should expose catalog keys")
|
||||
}
|
||||
|
||||
if len(svc.ReservedValues()) == 0 {
|
||||
t.Fatal("ReservedValues should expose catalog values")
|
||||
}
|
||||
|
||||
if len(svc.GetReservedValues()) == 0 {
|
||||
t.Fatal("GetReservedValues should expose catalog values")
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceLockedCatalog(t *testing.T) {
|
||||
|
|
@ -930,10 +962,18 @@ func TestServiceLockedCatalog(t *testing.T) {
|
|||
t.Fatalf("LockedSize() = %d, want %d", got, catalog.Size())
|
||||
}
|
||||
|
||||
if got := svc.GetLockedSize(); got != catalog.Size() {
|
||||
t.Fatalf("GetLockedSize() = %d, want %d", got, catalog.Size())
|
||||
}
|
||||
|
||||
if got := svc.LockedPrefixSize(); got != catalog.PrefixSize() {
|
||||
t.Fatalf("LockedPrefixSize() = %d, want %d", got, catalog.PrefixSize())
|
||||
}
|
||||
|
||||
if got := svc.GetLockedPrefixSize(); got != catalog.PrefixSize() {
|
||||
t.Fatalf("GetLockedPrefixSize() = %d, want %d", got, catalog.PrefixSize())
|
||||
}
|
||||
|
||||
if !catalog.HasByName("NEC") {
|
||||
t.Fatal("LockedCatalog should expose the locked catalog helpers")
|
||||
}
|
||||
|
|
@ -958,11 +998,23 @@ func TestServiceLockedCatalog(t *testing.T) {
|
|||
t.Fatal("LockedEntries should expose catalog entries")
|
||||
}
|
||||
|
||||
if len(svc.GetLockedEntries()) == 0 {
|
||||
t.Fatal("GetLockedEntries should expose catalog entries")
|
||||
}
|
||||
|
||||
if len(svc.LockedKeys()) == 0 {
|
||||
t.Fatal("LockedKeys should expose catalog keys")
|
||||
}
|
||||
|
||||
if len(svc.GetLockedKeys()) == 0 {
|
||||
t.Fatal("GetLockedKeys should expose catalog keys")
|
||||
}
|
||||
|
||||
if len(svc.LockedValues()) == 0 {
|
||||
t.Fatal("LockedValues should expose catalog values")
|
||||
}
|
||||
|
||||
if len(svc.GetLockedValues()) == 0 {
|
||||
t.Fatal("GetLockedValues should expose catalog values")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue