diff --git a/lns.go b/lns.go index 4b692da..bda6270 100644 --- a/lns.go +++ b/lns.go @@ -361,6 +361,16 @@ func (s *Service) GetNewClaim() *Claim { return s.NewClaim() } +// NewNameView constructs an empty cached name-state view. +func (s *Service) NewNameView() *NameView { + return primitives.NewNameView() +} + +// GetNewNameView is an alias for NewNameView. +func (s *Service) GetNewNameView() *NameView { + return s.NewNameView() +} + // Create constructs a reference NSEC record container. func (s *Service) Create(name, nextDomain string, typeBitmap []byte) NSECRecord { return dnspkg.Create(name, nextDomain, typeBitmap) @@ -1093,6 +1103,19 @@ type NameState = primitives.NameState // NameDelta mirrors the sparse name-state delta type from pkg/primitives. type NameDelta = primitives.NameDelta +// NameStateGetter mirrors the minimal name-state lookup interface used by +// NameView. +type NameStateGetter = primitives.NameStateGetter + +// NameView mirrors the cached name-state view used during state processing. +type NameView = primitives.NameView + +// NameUndo mirrors the sparse undo payload produced from a NameView. +type NameUndo = primitives.NameUndo + +// NameUndoEntry mirrors a single undo entry pairing a hash with a delta. +type NameUndoEntry = primitives.NameUndoEntry + // Claim mirrors the raw ownership-proof claim wrapper from pkg/primitives. type Claim = primitives.Claim @@ -1138,6 +1161,16 @@ func GetNewClaim() *Claim { return NewClaim() } +// NewNameView constructs an empty cached name-state view. +func NewNameView() *NameView { + return primitives.NewNameView() +} + +// GetNewNameView is an alias for NewNameView. +func GetNewNameView() *NameView { + return NewNameView() +} + // CoinView mirrors the minimal UTXO lookup interface required by covenant // verification helpers. type CoinView = covenant.CoinView diff --git a/lns_package_test.go b/lns_package_test.go index 6b27a14..f62fd1b 100644 --- a/lns_package_test.go +++ b/lns_package_test.go @@ -260,6 +260,16 @@ func TestPackageClaimAlias(t *testing.T) { if GetNewClaim() == nil { t.Fatal("GetNewClaim should alias NewClaim") } + + if view := NewNameView(); view == nil { + t.Fatal("NewNameView should return a cached name-state view") + } else if view.ToNameUndo().Names != nil { + t.Fatal("NewNameView should start with an empty undo payload") + } + + if GetNewNameView() == nil { + t.Fatal("GetNewNameView should alias NewNameView") + } } func TestPackageNSECAliases(t *testing.T) { diff --git a/lns_test.go b/lns_test.go index 1431bc8..67b6f06 100644 --- a/lns_test.go +++ b/lns_test.go @@ -891,6 +891,16 @@ func TestServiceUtilityAliases(t *testing.T) { t.Fatal("GetNewClaim should alias NewClaim") } + if view := svc.NewNameView(); view == nil { + t.Fatal("NewNameView should return a cached name-state view") + } else if view.ToNameUndo().Names != nil { + t.Fatal("NewNameView should start with an empty undo payload") + } + + if svc.GetNewNameView() == nil { + t.Fatal("GetNewNameView should alias NewNameView") + } + if got := svc.NextName("ExAmPle."); got != "example\x00." { t.Fatalf("NextName returned %q", got) }