Skip to content

Commit 7f972ac

Browse files
Add outdated operations kind (#5)
1 parent e5ef966 commit 7f972ac

File tree

8 files changed

+24
-6
lines changed

8 files changed

+24
-6
lines changed

build/dipdup.mainnet.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ hasura:
4040
admin_secret: ${ADMIN_SECRET:-changeme}
4141
select_limit: 100
4242
allow_aggregation: false
43+
source: default
44+
add_source: true
4345
rest: true
4446

4547
prometheus:

build/dipdup.testnet.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ hasura:
6262
admin_secret: ${ADMIN_SECRET:-changeme}
6363
select_limit: 100
6464
allow_aggregation: false
65+
source: default
66+
add_source: true
6567
rest: true
6668

6769
prometheus:

cmd/mempool/indexer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ func (indexer *Indexer) listen(ctx context.Context) {
270270
log.Err(err).Msg("handleAppliedOperation")
271271
continue
272272
}
273-
case receiver.StatusBranchDelayed, receiver.StatusBranchRefused, receiver.StatusRefused, receiver.StatusUnprocessed:
273+
case receiver.StatusBranchDelayed, receiver.StatusBranchRefused, receiver.StatusRefused, receiver.StatusUnprocessed, receiver.StatusOutdated:
274274
failed, ok := msg.Body.(node.FailedMonitor)
275275
if !ok {
276276
indexer.error().Msgf("invalid %s operation %v", msg.Status, failed)

cmd/mempool/main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,12 @@ func main() {
121121
for kind := range kinds {
122122
t = append(t, kind)
123123
}
124-
tables := models.GetModelsBy(t...)
125-
if err := hasura.Create(ctx, cfg.Hasura, cfg.Database, views, tables...); err != nil {
124+
if err := hasura.Create(ctx, hasura.GenerateArgs{
125+
Config: cfg.Hasura,
126+
DatabaseConfig: cfg.Database,
127+
Views: views,
128+
Models: models.GetModelsBy(t...),
129+
}); err != nil {
126130
log.Err(err).Msg("")
127131
cancel()
128132
return

cmd/mempool/receiver/data.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ const (
1616
StatusBranchDelayed Status = "branch_delayed"
1717
StatusBranchRefused Status = "branch_refused"
1818
StatusRefused Status = "refused"
19+
StatusOutdated Status = "outdated"
1920
StatusUnprocessed Status = "unprocessed"
2021
)

cmd/mempool/receiver/receiver.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func (indexer *Receiver) Start(ctx context.Context) {
7777
indexer.monitors[i].SubscribeOnMempoolBranchDelayed(ctx)
7878
indexer.monitors[i].SubscribeOnMempoolBranchRefused(ctx)
7979
indexer.monitors[i].SubscribeOnMempoolRefused(ctx)
80+
indexer.monitors[i].SubscribeOnMempoolOutdated(ctx)
8081
}
8182
}
8283

@@ -137,6 +138,14 @@ func (indexer *Receiver) run(ctx context.Context, monitor *node.Monitor) {
137138
Protocol: indexer.protocol,
138139
}
139140
}
141+
case outdated := <-monitor.Outdated():
142+
for i := range outdated {
143+
indexer.operations <- Message{
144+
Status: StatusOutdated,
145+
Body: *outdated[i],
146+
Protocol: indexer.protocol,
147+
}
148+
}
140149
}
141150
}
142151
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
require (
66
github.com/btcsuite/btcutil v1.0.2
7-
github.com/dipdup-net/go-lib v0.2.5
7+
github.com/dipdup-net/go-lib v0.2.11
88
github.com/go-pg/pg/v10 v10.10.6
99
github.com/karlseguin/ccache v2.0.3+incompatible
1010
github.com/mitchellh/mapstructure v1.4.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2
3838
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3939
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
4040
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
41-
github.com/dipdup-net/go-lib v0.2.5 h1:9CAcLmbD+0gcJ1S3g5ZPHulnV8x/GAIP1f0RMZ/VZNQ=
42-
github.com/dipdup-net/go-lib v0.2.5/go.mod h1:RjVhNv63RE3pOAeHLwnspa2UjJi80k/Kelwv7aN1ETE=
41+
github.com/dipdup-net/go-lib v0.2.11 h1:ZzPMOOa4y03UyC/7BbXKII5Ue/i76QvVavG4TArMSlg=
42+
github.com/dipdup-net/go-lib v0.2.11/go.mod h1:RjVhNv63RE3pOAeHLwnspa2UjJi80k/Kelwv7aN1ETE=
4343
github.com/ebellocchia/go-base58 v0.1.0 h1:0w/ODEfZnOPW5KW0QY/Xpb1fxba/BxQJMUa5iYzpljk=
4444
github.com/ebellocchia/go-base58 v0.1.0/go.mod h1:RHE/6C6Ru6YAH9Tc+A9eHQ6ZKEooLC0jw+YLnpt3CAU=
4545
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=

0 commit comments

Comments
 (0)