forked from conduitxyz/plume-nitro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_limited.go
58 lines (43 loc) · 1.96 KB
/
read_limited.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
package das
import (
"context"
"fmt"
"github.com/offchainlabs/nitro/arbstate/daprovider"
)
// These classes are wrappers implementing das.StorageService and das.DataAvailabilityService.
// They are needed to make the DAS factory function uniform for all allowed configurations.
// The wrappers panic if they are used in a situation where writes are needed; panic is used because
// it is a programming error in the code setting up the node or daserver if a non-writeable object
// is used in a writeable context.
func NewReadLimitedStorageService(reader daprovider.DASReader) *readLimitedStorageService {
return &readLimitedStorageService{reader}
}
type readLimitedStorageService struct {
daprovider.DASReader
}
func (s *readLimitedStorageService) Put(ctx context.Context, data []byte, expiration uint64) error {
panic("Logic error: readLimitedStorageService.Put shouldn't be called.")
}
func (s *readLimitedStorageService) Sync(ctx context.Context) error {
panic("Logic error: readLimitedStorageService.Store shouldn't be called.")
}
func (s *readLimitedStorageService) Close(ctx context.Context) error {
return nil
}
func (s *readLimitedStorageService) String() string {
return fmt.Sprintf("readLimitedStorageService(%v)", s.DASReader)
}
type readLimitedDataAvailabilityService struct {
daprovider.DASReader
}
func NewReadLimitedDataAvailabilityService(da daprovider.DASReader) *readLimitedDataAvailabilityService {
return &readLimitedDataAvailabilityService{da}
}
func (*readLimitedDataAvailabilityService) Store(ctx context.Context, message []byte, timeout uint64, sig []byte) (*daprovider.DataAvailabilityCertificate, error) {
panic("Logic error: readLimitedDataAvailabilityService.Store shouldn't be called.")
}
func (s *readLimitedDataAvailabilityService) String() string {
return fmt.Sprintf("ReadLimitedDataAvailabilityService(%v)", s.DASReader)
}