Skip to content

Commit b4a5899

Browse files
committed
Replace code-server with ocp-server
1 parent 8e6c1b9 commit b4a5899

21 files changed

Lines changed: 174 additions & 188 deletions

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ Core processing logic is in `geyser/handler_memory.go`. The worker:
5353

5454
### Key Dependencies
5555

56-
- `github.com/code-payments/code-server` — Solana/CVM utilities, gRPC infrastructure, retry logic
56+
- `github.com/code-payments/ocp-server` — Solana/CVM utilities, gRPC infrastructure, retry logic
5757
- Go 1.26

app/data.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"context"
55
"fmt"
66

7-
"github.com/code-payments/code-server/pkg/config/env"
8-
pg "github.com/code-payments/code-server/pkg/database/postgres"
7+
"github.com/code-payments/ocp-server/config/env"
8+
pg "github.com/code-payments/ocp-server/database/postgres"
99
"github.com/pkg/errors"
1010

1111
"github.com/code-payments/code-vm-indexer/data/ram"

app/geyser/main.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import (
44
"context"
55
"sync"
66

7-
"github.com/code-payments/code-server/pkg/config/env"
8-
grpcapp "github.com/code-payments/code-server/pkg/grpc/app"
9-
"github.com/code-payments/code-server/pkg/solana"
10-
"github.com/newrelic/go-agent/v3/newrelic"
7+
"github.com/code-payments/ocp-server/config/env"
8+
grpcapp "github.com/code-payments/ocp-server/grpc/app"
9+
"github.com/code-payments/ocp-server/metrics"
10+
"github.com/code-payments/ocp-server/solana"
1111
"github.com/sirupsen/logrus"
12+
"go.uber.org/zap"
1213
"google.golang.org/grpc"
1314

1415
indexerapp "github.com/code-payments/code-vm-indexer/app"
@@ -31,7 +32,7 @@ type app struct {
3132
// Init implements grpcapp.App.Init
3233
//
3334
// todo: Cleanup gRPC app package (ie. no hardcoded metrics provider)
34-
func (a *app) Init(_ grpcapp.Config, metricsProvider *newrelic.Application) error {
35+
func (a *app) Init(_ *zap.Logger, _ metrics.Provider, _ grpcapp.Config) error {
3536
ctx, cancel := context.WithCancel(context.Background())
3637
a.workerCancelFunc = cancel
3738
a.shutdownCh = make(chan struct{})

app/rpc/main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package main
33
import (
44
"sync"
55

6-
grpcapp "github.com/code-payments/code-server/pkg/grpc/app"
7-
"github.com/newrelic/go-agent/v3/newrelic"
6+
grpcapp "github.com/code-payments/ocp-server/grpc/app"
7+
"github.com/code-payments/ocp-server/metrics"
88
"github.com/sirupsen/logrus"
9+
"go.uber.org/zap"
910
"google.golang.org/grpc"
1011

1112
indexerpb "github.com/code-payments/code-vm-indexer/generated/indexer/v1"
@@ -24,7 +25,7 @@ type app struct {
2425
// Init implements grpcapp.App.Init
2526
//
2627
// todo: Cleanup gRPC app package (ie. no hardcoded metrics provider)
27-
func (a *app) Init(_ grpcapp.Config, metricsProvider *newrelic.Application) error {
28+
func (a *app) Init(_ *zap.Logger, _ metrics.Provider, _ grpcapp.Config) error {
2829
a.shutdownCh = make(chan struct{})
2930

3031
dataProvider, err := indexerapp.NewDataProvider()

data/ram/memory/memory.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"sync"
66
"time"
77

8-
"github.com/code-payments/code-server/pkg/solana/cvm"
8+
"github.com/code-payments/ocp-server/solana/vm"
99

1010
"github.com/code-payments/code-vm-indexer/data/ram"
1111
)
@@ -92,7 +92,7 @@ func (s *store) GetAllByMemoryAccount(_ context.Context, memoryAccount string) (
9292
}
9393

9494
// GetAllVirtualAccountsByAddressAndType implements ram.Store.GetAllVirtualAccountsByAddressAndType
95-
func (s *store) GetAllVirtualAccountsByAddressAndType(_ context.Context, vm, address string, accountType cvm.VirtualAccountType) ([]*ram.Record, error) {
95+
func (s *store) GetAllVirtualAccountsByAddressAndType(_ context.Context, vm, address string, accountType vm.VirtualAccountType) ([]*ram.Record, error) {
9696
s.mu.Lock()
9797
defer s.mu.Unlock()
9898

@@ -136,7 +136,7 @@ func (s *store) findByVm(vm string) []*ram.Record {
136136
return res
137137
}
138138

139-
func (s *store) findByVmAddressAndAccountType(vm, address string, accountType cvm.VirtualAccountType) []*ram.Record {
139+
func (s *store) findByVmAddressAndAccountType(vm, address string, accountType vm.VirtualAccountType) []*ram.Record {
140140
var res []*ram.Record
141141
for _, item := range s.records {
142142
if !item.IsAllocated {

data/ram/model.go

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"errors"
55
"time"
66

7-
"github.com/code-payments/code-server/pkg/solana/cvm"
7+
"github.com/code-payments/ocp-server/solana/vm"
88
)
99

1010
type Record struct {
@@ -17,7 +17,7 @@ type Record struct {
1717
IsAllocated bool
1818

1919
Address *string
20-
Type *cvm.VirtualAccountType
20+
Type *vm.VirtualAccountType
2121
Data []byte
2222

2323
Slot uint64
@@ -43,7 +43,7 @@ func (r *Record) Validate() error {
4343
return errors.New("memory item type is required for allocated memory")
4444
}
4545
switch *r.Type {
46-
case cvm.VirtualAccountTypeDurableNonce, cvm.VirtualAccountTypeTimelock, cvm.VirtualAccountTypeRelay:
46+
case vm.VirtualAccountTypeDurableNonce, vm.VirtualAccountTypeTimelock:
4747
default:
4848
return errors.New("invalid memory item type")
4949
}
@@ -110,41 +110,29 @@ func (r *Record) CopyTo(dst *Record) {
110110
dst.LastUpdatedAt = r.LastUpdatedAt
111111
}
112112

113-
func (r *Record) ToVirtualDurableNonce() (*cvm.VirtualDurableNonce, bool) {
114-
if !r.IsAllocated || *r.Type != cvm.VirtualAccountTypeDurableNonce {
113+
func (r *Record) ToVirtualDurableNonce() (*vm.VirtualDurableNonce, bool) {
114+
if !r.IsAllocated || *r.Type != vm.VirtualAccountTypeDurableNonce {
115115
return nil, false
116116
}
117117

118-
var vdn cvm.VirtualDurableNonce
118+
var vdn vm.VirtualDurableNonce
119119
err := vdn.UnmarshalDirectly(r.Data)
120120
if err != nil {
121121
return nil, false
122122
}
123123
return &vdn, true
124124
}
125125

126-
func (r *Record) ToVirtualTimelockAccount() (*cvm.VirtualTimelockAccount, bool) {
127-
if !r.IsAllocated || *r.Type != cvm.VirtualAccountTypeTimelock {
126+
func (r *Record) ToVirtualTimelockAccount() (*vm.VirtualTimelockAccount, bool) {
127+
if !r.IsAllocated || *r.Type != vm.VirtualAccountTypeTimelock {
128128
return nil, false
129129
}
130130

131-
var vta cvm.VirtualTimelockAccount
131+
var vta vm.VirtualTimelockAccount
132132
err := vta.UnmarshalDirectly(r.Data)
133133
if err != nil {
134134
return nil, false
135135
}
136136
return &vta, true
137137
}
138138

139-
func (r *Record) ToVirtualRelayAccount() (*cvm.VirtualRelayAccount, bool) {
140-
if !r.IsAllocated || *r.Type != cvm.VirtualAccountTypeRelay {
141-
return nil, false
142-
}
143-
144-
var vra cvm.VirtualRelayAccount
145-
err := vra.UnmarshalDirectly(r.Data)
146-
if err != nil {
147-
return nil, false
148-
}
149-
return &vra, true
150-
}

data/ram/postgres/model.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"database/sql"
66
"time"
77

8-
pgutil "github.com/code-payments/code-server/pkg/database/postgres"
9-
"github.com/code-payments/code-server/pkg/solana/cvm"
8+
pgutil "github.com/code-payments/ocp-server/database/postgres"
9+
"github.com/code-payments/ocp-server/solana/vm"
1010
"github.com/jmoiron/sqlx"
1111

1212
"github.com/code-payments/code-vm-indexer/data/ram"
@@ -70,9 +70,9 @@ func fromModel(obj *model) *ram.Record {
7070
address = &obj.Address.String
7171
}
7272

73-
var itemType *cvm.VirtualAccountType
73+
var itemType *vm.VirtualAccountType
7474
if obj.Type.Valid {
75-
casted := cvm.VirtualAccountType(obj.Type.Int16)
75+
casted := vm.VirtualAccountType(obj.Type.Int16)
7676
itemType = &casted
7777
}
7878

@@ -173,7 +173,7 @@ func dbGetAllByMemoryAccount(ctx context.Context, tableName string, db *sqlx.DB,
173173
return res, nil
174174
}
175175

176-
func dbGetAllVirtualAccountsByAddressAndType(ctx context.Context, tableName string, db *sqlx.DB, vm, address string, accountType cvm.VirtualAccountType) ([]*model, error) {
176+
func dbGetAllVirtualAccountsByAddressAndType(ctx context.Context, tableName string, db *sqlx.DB, vm, address string, accountType vm.VirtualAccountType) ([]*model, error) {
177177
res := []*model{}
178178

179179
query := `SELECT id, vm, memory_account, index, is_allocated, address, item_type, data, slot, last_updated_at FROM ` + tableName + `

data/ram/postgres/store.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"database/sql"
66

7-
"github.com/code-payments/code-server/pkg/solana/cvm"
7+
"github.com/code-payments/ocp-server/solana/vm"
88
"github.com/jmoiron/sqlx"
99

1010
"github.com/code-payments/code-vm-indexer/data/ram"
@@ -60,7 +60,7 @@ func (s *store) GetAllByMemoryAccount(ctx context.Context, memoryAccount string)
6060
}
6161

6262
// GetAllVirtualAccountsByAddressAndType implements ram.Store.GetAllVirtualAccountsByAddressAndType
63-
func (s *store) GetAllVirtualAccountsByAddressAndType(ctx context.Context, vm, address string, accountType cvm.VirtualAccountType) ([]*ram.Record, error) {
63+
func (s *store) GetAllVirtualAccountsByAddressAndType(ctx context.Context, vm, address string, accountType vm.VirtualAccountType) ([]*ram.Record, error) {
6464
models, err := dbGetAllVirtualAccountsByAddressAndType(ctx, s.tableName, s.db, vm, address, accountType)
6565
if err != nil {
6666
return nil, err

data/ram/postgres/store_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"os"
66
"testing"
77

8-
postgrestest "github.com/code-payments/code-server/pkg/database/postgres/test"
8+
postgrestest "github.com/code-payments/ocp-server/database/postgres/test"
99
"github.com/ory/dockertest/v3"
1010
"github.com/sirupsen/logrus"
1111

data/ram/store.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"errors"
66

7-
"github.com/code-payments/code-server/pkg/solana/cvm"
7+
"github.com/code-payments/ocp-server/solana/vm"
88
)
99

1010
var (
@@ -25,5 +25,5 @@ type Store interface {
2525

2626
// GetAllVirtualAccountsByAddressAndType gets all database records for
2727
// allocated memory with the provided address and account type in a VM
28-
GetAllVirtualAccountsByAddressAndType(ctx context.Context, vm, address string, accountType cvm.VirtualAccountType) ([]*Record, error)
28+
GetAllVirtualAccountsByAddressAndType(ctx context.Context, vm, address string, accountType vm.VirtualAccountType) ([]*Record, error)
2929
}

0 commit comments

Comments
 (0)