@@ -10,56 +10,34 @@ import (
1010)
1111
1212type (
13- HeaderP2PBroadcaster = Decorator [* types.SignedHeader ]
14- DataP2PBroadcaster = Decorator [* types.Data ]
13+ HeaderP2PBroadcaster = Broadcaster [* types.SignedHeader ]
14+ DataP2PBroadcaster = Broadcaster [* types.Data ]
1515)
1616
1717// Broadcaster interface for P2P broadcasting
1818type Broadcaster [H header.Header [H ]] interface {
1919 WriteToStoreAndBroadcast (ctx context.Context , payload H , opts ... pubsub.PubOpt ) error
20- Store () header.Store [H ]
2120 AppendDAHint (ctx context.Context , daHeight uint64 , hashes ... types.Hash ) error
22- }
23-
24- // Decorator to access the the payload type without the container
25- type Decorator [H header.Header [H ]] struct {
26- nested Broadcaster [* types.DAHeightHintContainer [H ]]
27- }
28-
29- func NewDecorator [H header.Header [H ]](nested Broadcaster [* types.DAHeightHintContainer [H ]]) Decorator [H ] {
30- return Decorator [H ]{nested : nested }
31- }
32-
33- func (d Decorator [H ]) WriteToStoreAndBroadcast (ctx context.Context , payload H , opts ... pubsub.PubOpt ) error {
34- return d .nested .WriteToStoreAndBroadcast (ctx , & types.DAHeightHintContainer [H ]{Entry : payload }, opts ... )
35- }
36-
37- func (d Decorator [H ]) Store () HeightStore [H ] {
38- return HeightStoreImpl [H ]{store : d .nested .Store ()}
39- }
40- func (d Decorator [H ]) XStore () header.Store [* types.DAHeightHintContainer [H ]] {
41- return d .nested .Store ()
42- }
43-
44- func (d Decorator [H ]) AppendDAHint (ctx context.Context , daHeight uint64 , hashes ... types.Hash ) error {
45- return d .nested .AppendDAHint (ctx , daHeight , hashes ... )
46- }
47-
48- // HeightStore is a subset of goheader.Store
49- type HeightStore [H header.Header [H ]] interface {
50- GetByHeight (context.Context , uint64 ) (H , error )
51- }
52-
53- type HeightStoreImpl [H header.Header [H ]] struct {
54- store header.Store [* types.DAHeightHintContainer [H ]]
55- }
56-
57- func (s HeightStoreImpl [H ]) GetByHeight (ctx context.Context , height uint64 ) (H , error ) {
58- var zero H
59- v , err := s .store .GetByHeight (ctx , height )
60- if err != nil {
61- return zero , err
62- }
63- return v .Entry , nil
64-
65- }
21+ GetByHeight (ctx context.Context , height uint64 ) (H , uint64 , error )
22+ }
23+
24+ //
25+ //// Decorator to access the payload type without the container
26+ //type Decorator[H header.Header[H]] struct {
27+ // nested Broadcaster[*sync.DAHeightHintContainer[H]]
28+ //}
29+ //
30+ //func NewDecorator[H header.Header[H]](nested Broadcaster[*sync.DAHeightHintContainer[H]]) Decorator[H] {
31+ // return Decorator[H]{nested: nested}
32+ //}
33+ //
34+ //func (d Decorator[H]) WriteToStoreAndBroadcast(ctx context.Context, payload H, opts ...pubsub.PubOpt) error {
35+ // return d.nested.WriteToStoreAndBroadcast(ctx, &sync.DAHeightHintContainer[H]{Entry: payload}, opts...)
36+ //}
37+ //
38+ //func (d Decorator[H]) AppendDAHint(ctx context.Context, daHeight uint64, hashes ...types.Hash) error {
39+ // return d.nested.AppendDAHint(ctx, daHeight, hashes...)
40+ //}
41+ //func (d Decorator[H]) GetByHeight(ctx context.Context, height uint64) (H, error) {
42+ // panic("not implemented")
43+ //}
0 commit comments