Skip to content

Commit

Permalink
Merge pull request #412 from oasisprotocol/mitjat/testnet-config
Browse files Browse the repository at this point in the history
node config: Support testnet
  • Loading branch information
mitjat authored May 9, 2023
2 parents ae2b9d4 + d5af0fb commit a73b04c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
1 change: 0 additions & 1 deletion config/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ var DefaultChains = map[common.ChainName]*History{
common.ChainNameTestnet: {
Records: []*Record{
// TODO: coalesce compatible records
// TODO: rename archives to match compatible API
// TODO: fill in chain context
{
// https://github.com/oasisprotocol/testnet-artifacts/releases/tag/2022-03-03
Expand Down
41 changes: 27 additions & 14 deletions storage/oasis/nodeapi/history/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,34 @@ var _ nodeapi.ConsensusApiLite = (*HistoryConsensusApiLite)(nil)

type APIConstructor func(ctx context.Context, chainContext string, archiveConfig *config.ArchiveConfig, fastStartup bool) (nodeapi.ConsensusApiLite, error)

func damaskAPIConstructor(ctx context.Context, chainContext string, archiveConfig *config.ArchiveConfig, fastStartup bool) (nodeapi.ConsensusApiLite, error) {
sdkConn, err := connections.SDKConnect(ctx, chainContext, archiveConfig.ResolvedConsensusNode(), fastStartup)
if err != nil {
return nil, err
}
return damask.NewDamaskConsensusApiLite(sdkConn.Consensus()), nil
}

func cobaltAPIConstructor(ctx context.Context, chainContext string, archiveConfig *config.ArchiveConfig, fastStartup bool) (nodeapi.ConsensusApiLite, error) {
rawConn, err := connections.RawConnect(archiveConfig.ResolvedConsensusNode())
if err != nil {
return nil, fmt.Errorf("indexer RawConnect: %w", err)
}
return cobalt.NewCobaltConsensusApiLite(rawConn), nil
}

// APIConstructors map each (indexer-internal) archive name to the API constructor
// that can talk to that archive. The namespace of archive names is shared
// between mainnet and testnet for simplicity.
// The supported archive names come from `config.DefaultChains`. If you want to use
// a custom set of archives (`custom_chain` in the yaml config), you must reuse
// a suitable archive name.
var APIConstructors = map[string]APIConstructor{
"damask": func(ctx context.Context, chainContext string, archiveConfig *config.ArchiveConfig, fastStartup bool) (nodeapi.ConsensusApiLite, error) {
sdkConn, err := connections.SDKConnect(ctx, chainContext, archiveConfig.ResolvedConsensusNode(), fastStartup)
if err != nil {
return nil, err
}
return damask.NewDamaskConsensusApiLite(sdkConn.Consensus()), nil
},
"cobalt": func(ctx context.Context, chainContext string, archiveConfig *config.ArchiveConfig, fastStartup bool) (nodeapi.ConsensusApiLite, error) {
rawConn, err := connections.RawConnect(archiveConfig.ResolvedConsensusNode())
if err != nil {
return nil, fmt.Errorf("indexer RawConnect: %w", err)
}
return cobalt.NewCobaltConsensusApiLite(rawConn), nil
},
// mainnet
"damask": damaskAPIConstructor,
"cobalt": cobaltAPIConstructor,
// testnet
"2022-03-03": damaskAPIConstructor,
}

type HistoryConsensusApiLite struct {
Expand Down

0 comments on commit a73b04c

Please sign in to comment.