forked from Layr-Labs/eigenda-proxy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Layr-Labs#191): Routing namespace --> Storage (Layr-Labs#195)
- Loading branch information
Showing
24 changed files
with
474 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package utils | ||
package common | ||
|
||
import ( | ||
"fmt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package common | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// BackendType ... Storage backend type | ||
type BackendType uint8 | ||
|
||
const ( | ||
EigenDABackendType BackendType = iota | ||
MemoryBackendType | ||
S3BackendType | ||
RedisBackendType | ||
|
||
UnknownBackendType | ||
) | ||
|
||
var ( | ||
ErrProxyOversizedBlob = fmt.Errorf("encoded blob is larger than max blob size") | ||
ErrEigenDAOversizedBlob = fmt.Errorf("blob size cannot exceed") | ||
) | ||
|
||
func (b BackendType) String() string { | ||
switch b { | ||
case EigenDABackendType: | ||
return "EigenDA" | ||
case MemoryBackendType: | ||
return "Memory" | ||
case S3BackendType: | ||
return "S3" | ||
case RedisBackendType: | ||
return "Redis" | ||
case UnknownBackendType: | ||
fallthrough | ||
default: | ||
return "Unknown" | ||
} | ||
} | ||
|
||
func StringToBackendType(s string) BackendType { | ||
lower := strings.ToLower(s) | ||
|
||
switch lower { | ||
case "eigenda": | ||
return EigenDABackendType | ||
case "memory": | ||
return MemoryBackendType | ||
case "s3": | ||
return S3BackendType | ||
case "redis": | ||
return RedisBackendType | ||
case "unknown": | ||
fallthrough | ||
default: | ||
return UnknownBackendType | ||
} | ||
} | ||
|
||
type Store interface { | ||
// Backend returns the backend type provider of the store. | ||
BackendType() BackendType | ||
// Verify verifies the given key-value pair. | ||
Verify(ctx context.Context, key []byte, value []byte) error | ||
} | ||
|
||
type GeneratedKeyStore interface { | ||
Store | ||
// Get retrieves the given key if it's present in the key-value data store. | ||
Get(ctx context.Context, key []byte) ([]byte, error) | ||
// Put inserts the given value into the key-value data store. | ||
Put(ctx context.Context, value []byte) (key []byte, err error) | ||
} | ||
|
||
type PrecomputedKeyStore interface { | ||
Store | ||
// Get retrieves the given key if it's present in the key-value data store. | ||
Get(ctx context.Context, key []byte) ([]byte, error) | ||
// Put inserts the given value into the key-value data store. | ||
Put(ctx context.Context, key []byte, value []byte) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.