diff --git a/go.mod b/go.mod new file mode 100644 index 00000000..c90ef606 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/0xPolygon/cdk + +go 1.22 diff --git a/api/.gitkeep b/go.sum similarity index 100% rename from api/.gitkeep rename to go.sum diff --git a/pkg/cdk/sequencermanager/.gitkeep b/pkg/cdk/sequencermanager/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/pkg/dataavailability/.gitkeep b/pkg/dataavailability/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/pkg/rpcproxy/.gitkeep b/pkg/rpcproxy/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/pkg/sequencesender/.gitkeep b/pkg/sequencesender/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/pkg/syncer/.gitkeep b/pkg/syncer/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/internal/.gitkeep b/sequencermanager/.gitkeep similarity index 100% rename from internal/.gitkeep rename to sequencermanager/.gitkeep diff --git a/pkg/aggregatormanager/.gitkeep b/sequencesender/.gitkeep similarity index 100% rename from pkg/aggregatormanager/.gitkeep rename to sequencesender/.gitkeep diff --git a/syncer/ethprovider/ethprovider.go b/syncer/ethprovider/ethprovider.go new file mode 100644 index 00000000..9bc463d8 --- /dev/null +++ b/syncer/ethprovider/ethprovider.go @@ -0,0 +1,9 @@ +package ethsyncer + +import ( + "github.com/0xPolygon/cdk/syncer/storage" +) + +type EthSyncer struct { + Storage storage.StorageService +} diff --git a/syncer/interfaces.go b/syncer/interfaces.go new file mode 100644 index 00000000..2be883fd --- /dev/null +++ b/syncer/interfaces.go @@ -0,0 +1,9 @@ +package syncer + +type EventSyncer interface { + GetData() []byte +} + +type EventProcessor interface { + Process(data []byte) error +} \ No newline at end of file diff --git a/syncer/provider.go b/syncer/provider.go new file mode 100644 index 00000000..d62c4fbc --- /dev/null +++ b/syncer/provider.go @@ -0,0 +1 @@ +package syncer diff --git a/syncer/storage/inmem/inmem.go b/syncer/storage/inmem/inmem.go new file mode 100644 index 00000000..b9a930b0 --- /dev/null +++ b/syncer/storage/inmem/inmem.go @@ -0,0 +1,8 @@ +package inmem + +type Inmem struct { +} + +func (inmem *Inmem) GetData() []byte { + return []byte("Inmem") +} diff --git a/syncer/storage/storage.go b/syncer/storage/storage.go new file mode 100644 index 00000000..c485ecb6 --- /dev/null +++ b/syncer/storage/storage.go @@ -0,0 +1,7 @@ +package storage + +// Storage is an interface for the storage of the syncer +type StorageService interface { + GetData() []byte + GetLatestVerifiedBlock() uint64 +} diff --git a/syncer/syncer.go b/syncer/syncer.go new file mode 100644 index 00000000..fab1add8 --- /dev/null +++ b/syncer/syncer.go @@ -0,0 +1,23 @@ +package syncer + +type Syncer interface { + // Start starts the syncer + Start() error + // Stop stops the syncer + Stop() error + // Synced returns true if the syncer is synced + Synced() bool + // SyncedChan returns a channel that is closed when the syncer is synced + SyncedChan() <-chan struct{} + // LatestVerifiedBlock returns the latest verified block + LatestVerifiedBlock() uint64 + // LatestBlock returns the latest block + LatestBlock() uint64 + // SyncedBlock returns the latest block that is synced + SyncedBlock() uint64 + // SyncedBlockChan returns a channel that is closed when the latest block is synced + SyncedBlockChan() <-chan struct{} +} + +type Sync struct { +}