Skip to content

Commit eb171f2

Browse files
committed
use local framework and implement required new methods for history drop
1 parent 22bb2b5 commit eb171f2

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ require (
1111
github.com/stretchr/testify v1.9.0
1212
)
1313

14+
replace github.com/flare-foundation/verifier-indexer-framework => ../verifier-indexer-framework
15+
1416
require (
1517
github.com/BurntSushi/toml v1.4.0 // indirect
1618
github.com/alexflint/go-arg v1.5.1 // indirect

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ github.com/ethereum/go-ethereum v1.13.15 h1:U7sSGYGo4SPjP6iNIifNoyIAiNjrmQkz6EwQ
2323
github.com/ethereum/go-ethereum v1.13.15/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU=
2424
github.com/flare-foundation/go-flare-common v1.0.2 h1:GZTQMmIBMVhEMMe2smuGu46jWNoe6+xzeE68XAhmxSE=
2525
github.com/flare-foundation/go-flare-common v1.0.2/go.mod h1:Pb1OAtNe8jNsD2fh6syJD6kVdqxAAXWESTGgd7uQlME=
26-
github.com/flare-foundation/verifier-indexer-framework v1.0.6 h1:47t7l1AJ+cjeQ/h+oGBGVqdpKg2+2Y61kvvEeJLqDsw=
27-
github.com/flare-foundation/verifier-indexer-framework v1.0.6/go.mod h1:oaed4K4QdNOVCOHj9ydQgyA2ggGXu5wh8zNWlV5Q2Uw=
2826
github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU=
2927
github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
3028
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=

internal/xrp/entities.go

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,35 @@
11
package xrp
22

3+
import "github.com/flare-foundation/verifier-indexer-framework/pkg/database"
4+
35
type Block struct {
46
Hash string `gorm:"primaryKey;type:varchar(64)"`
57
BlockNumber uint64 `gorm:"index"`
68
Timestamp uint64 `gorm:"index"`
79
Transactions uint64
810
}
911

12+
func (b Block) GetBlockNumber() uint64 {
13+
return b.BlockNumber
14+
}
15+
16+
func (b Block) GetTimestamp() uint64 {
17+
return b.Timestamp
18+
}
19+
20+
func (b Block) TimestampQuery() string {
21+
return "timestamp < ?"
22+
}
23+
24+
func (b Block) HistoryDropOrder() []database.Deletable {
25+
// It does not particularly matter the order as there are no foreign key constraints.
26+
// However we drop transactions first to avoid leaving orphaned records in case of partial failures.
27+
return []database.Deletable{
28+
Transaction{},
29+
Block{},
30+
}
31+
}
32+
1033
type Transaction struct {
1134
Hash string `gorm:"primaryKey;type:varchar(64);index:idx_block_hash_composite,priority:2,option:CONCURRENTLY"`
1235
BlockNumber uint64 `gorm:"index:idx_block_hash_composite,priority:1,option:CONCURRENTLY"`
@@ -17,10 +40,6 @@ type Transaction struct {
1740
SourceAddressesRoot string `gorm:"index;type:varchar(64);default:null"`
1841
}
1942

20-
func (b Block) GetBlockNumber() uint64 {
21-
return b.BlockNumber
22-
}
23-
24-
func (b Block) GetTimestamp() uint64 {
25-
return b.Timestamp
43+
func (t Transaction) TimestampQuery() string {
44+
return "timestamp < ?"
2645
}

0 commit comments

Comments
 (0)