Skip to content

Commit cae35bc

Browse files
committed
[HACK] get some form of block height working
1 parent f50ea03 commit cae35bc

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

protocol/app/app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,7 @@ func (app *App) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk.
14861486
// BeginBlocker application updates every begin block
14871487
func (app *App) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) {
14881488
ctx = ctx.WithExecMode(lib.ExecModeBeginBlock)
1489+
app.GrpcStreamingManager.SetBlockHeight(uint32(ctx.BlockHeight()))
14891490

14901491
// Update the proposer address in the logger for the panic logging middleware.
14911492
proposerAddr := sdk.ConsAddress(ctx.BlockHeader().ProposerAddress)

protocol/streaming/grpc/grpc_streaming_manager.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ type GrpcStreamingManagerImpl struct {
2828
done chan bool
2929
// map of clob pair id to stream updates.
3030
streamUpdateCache map[uint32][]clobtypes.StreamUpdate
31+
32+
blockHeight uint32
3133
}
3234

3335
// OrderbookSubscription represents a active subscription to the orderbook updates stream.
@@ -58,7 +60,7 @@ func NewGrpcStreamingManager(flushIntervalMs uint32) *GrpcStreamingManagerImpl {
5860
select {
5961
case <-grpcStreamingManager.ticker.C:
6062
// fix this with values
61-
grpcStreamingManager.FlushStreamUpdates(0, 0)
63+
grpcStreamingManager.internalFlushStreamUpdates()
6264
case <-grpcStreamingManager.done:
6365
return
6466
}
@@ -76,6 +78,15 @@ func (sm *GrpcStreamingManagerImpl) Stop() {
7678
sm.done <- true
7779
}
7880

81+
func (sm *GrpcStreamingManagerImpl) internalFlushStreamUpdates() {
82+
// temporary
83+
sm.FlushStreamUpdates(sm.blockHeight, 0)
84+
}
85+
86+
func (sm *GrpcStreamingManagerImpl) SetBlockHeight(blockHeight uint32) {
87+
sm.blockHeight = blockHeight
88+
}
89+
7990
// Subscribe subscribes to the orderbook updates stream.
8091
func (sm *GrpcStreamingManagerImpl) Subscribe(
8192
req clobtypes.StreamOrderbookUpdatesRequest,

protocol/streaming/grpc/noop_streaming_manager.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ func (sm *NoopGrpcStreamingManager) GetUninitializedClobPairIds() []uint32 {
5050
func (sm *NoopGrpcStreamingManager) Stop() {
5151
}
5252

53+
func (sm *NoopGrpcStreamingManager) SetBlockHeight(
54+
blockHeight uint32,
55+
) {
56+
}
57+
5358
func (sm *NoopGrpcStreamingManager) FlushStreamUpdates(
5459
blockHeight uint32,
5560
execMode sdk.ExecMode,

protocol/streaming/grpc/types/manager.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ type GrpcStreamingManager interface {
2929
execMode sdk.ExecMode,
3030
)
3131
Stop()
32+
SetBlockHeight(
33+
blockHeight uint32,
34+
)
3235
FlushStreamUpdates(
3336
blockHeight uint32,
3437
execMode sdk.ExecMode,

0 commit comments

Comments
 (0)