Skip to content

Commit 2534077

Browse files
committed
feat: TLD auto-discovery
1 parent 7deaa0e commit 2534077

File tree

5 files changed

+386
-118
lines changed

5 files changed

+386
-118
lines changed

internal/config/config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ var globalConfig = &Config{
9191
Directory: "./.state",
9292
},
9393
Profiles: []string{
94+
// NOTE: this is here because .ada wasn't added to the discovery address when it was originally deployed
9495
"ada-preprod",
95-
"hydra-preprod",
96+
"auto-preprod",
9697
},
9798
}
9899

internal/config/profile.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 Blink Labs Software
1+
// Copyright 2024 Blink Labs Software
22
//
33
// Use of this source code is governed by an MIT-style
44
// license that can be found in the LICENSE file or at
@@ -7,12 +7,13 @@
77
package config
88

99
type Profile struct {
10-
Network string // Cardano network name
11-
Tld string // Top-level domain
12-
PolicyId string // Verification asset policy ID
13-
ScriptAddress string // Address to follow
14-
InterceptSlot uint64 // Chain-sync initial intercept slot
15-
InterceptHash string // Chain-sync initial intercept hash
10+
Network string // Cardano network name
11+
Tld string // Top-level domain
12+
PolicyId string // Verification asset policy ID
13+
ScriptAddress string // Address to follow
14+
InterceptSlot uint64 // Chain-sync initial intercept slot
15+
InterceptHash string // Chain-sync initial intercept hash
16+
DiscoveryAddress string // Auto-discovery address to follow
1617
}
1718

1819
func GetProfiles() []Profile {
@@ -65,4 +66,12 @@ var Profiles = map[string]Profile{
6566
InterceptSlot: 67799029,
6667
InterceptHash: "4815dae9cd8f492ab51b109ba87d091ae85a0999af33ac459d8504122cb911f7",
6768
},
69+
"auto-preprod": Profile{
70+
Network: "preprod",
71+
PolicyId: "63cdaef8b84702282c3454ae130ada94a9b200e32be21abd47fc636b",
72+
DiscoveryAddress: "addr_test1xrhqrug2hnc9az4ru02kp9rlfcppl464gl4yc8s8jm5p8kygc3uvcfh3r3kaa5gyk5l2vgdl8vj8cstslf4w2ajuy0wsp5fm89",
73+
// The intercept slot/hash correspond to the block before the first TX on the above address
74+
InterceptSlot: 67778432,
75+
InterceptHash: "6db5cdcfa1ee9cc137b0b238ff9251d4481c23bf49ad6272cb833b034a003cbe",
76+
},
6877
}

internal/indexer/datum.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2024 Blink Labs Software
2+
//
3+
// Use of this source code is governed by an MIT-style
4+
// license that can be found in the LICENSE file or at
5+
// https://opensource.org/licenses/MIT.
6+
7+
package indexer
8+
9+
import (
10+
"fmt"
11+
12+
"github.com/blinklabs-io/gouroboros/cbor"
13+
)
14+
15+
type DNSReferenceRefScriptDatum struct {
16+
// This allows the type to be used with cbor.DecodeGeneric
17+
cbor.StructAsArray
18+
TldName []byte
19+
SymbolDrat []byte
20+
SymbolHns []byte
21+
}
22+
23+
func (d *DNSReferenceRefScriptDatum) UnmarshalCBOR(cborData []byte) error {
24+
var tmpData cbor.Constructor
25+
if _, err := cbor.Decode(cborData, &tmpData); err != nil {
26+
return err
27+
}
28+
if tmpData.Constructor() != 3 {
29+
return fmt.Errorf("unexpected outer constructor index: %d", tmpData.Constructor())
30+
}
31+
tmpDataFields := tmpData.Fields()
32+
if len(tmpDataFields) != 1 {
33+
return fmt.Errorf("unexpected inner field count: expected 1, got %d", len(tmpDataFields))
34+
}
35+
fieldInner, ok := tmpDataFields[0].(cbor.Constructor)
36+
if !ok {
37+
return fmt.Errorf("unexpected data type %T for outer constructor field", tmpDataFields[0])
38+
}
39+
var tmpDataInner cbor.Constructor
40+
if _, err := cbor.Decode(fieldInner.Cbor(), &tmpDataInner); err != nil {
41+
return err
42+
}
43+
if tmpDataInner.Constructor() != 1 {
44+
return fmt.Errorf("unexpected inner constructor index: %d", tmpDataInner.Constructor())
45+
}
46+
return cbor.DecodeGeneric(tmpDataInner.FieldsCbor(), d)
47+
}

0 commit comments

Comments
 (0)