Add transaction index to flip kick
This commit is contained in:
parent
a843de5eb7
commit
b2ba7ee1e3
@ -8,5 +8,6 @@ CREATE TABLE maker.flip_kick (
|
||||
"end" TIMESTAMP WITH TIME ZONE,
|
||||
urn VARCHAR,
|
||||
tab NUMERIC,
|
||||
tx_idx INTEGER NOT NUll,
|
||||
raw_log JSONB
|
||||
);
|
||||
|
@ -233,6 +233,7 @@ CREATE TABLE maker.flip_kick (
|
||||
"end" timestamp with time zone,
|
||||
urn character varying,
|
||||
tab numeric,
|
||||
tx_idx integer NOT NULL,
|
||||
raw_log jsonb
|
||||
);
|
||||
|
||||
|
@ -49,6 +49,7 @@ func (FlipKickConverter) ToEntity(contractAddress string, contractAbi string, et
|
||||
return entity, err
|
||||
}
|
||||
entity.Raw = ethLog
|
||||
entity.TransactionIndex = ethLog.TxIndex
|
||||
return entity, nil
|
||||
}
|
||||
|
||||
@ -79,6 +80,7 @@ func (FlipKickConverter) ToModel(flipKick FlipKickEntity) (FlipKickModel, error)
|
||||
End: end,
|
||||
Urn: urn,
|
||||
Tab: tab,
|
||||
TransactionIndex: flipKick.TransactionIndex,
|
||||
Raw: rawLogString,
|
||||
}, nil
|
||||
}
|
||||
|
@ -29,5 +29,6 @@ type FlipKickEntity struct {
|
||||
End *big.Int
|
||||
Urn [32]byte
|
||||
Tab *big.Int
|
||||
TransactionIndex uint
|
||||
Raw types.Log
|
||||
}
|
||||
|
@ -24,5 +24,6 @@ type FlipKickModel struct {
|
||||
End time.Time
|
||||
Urn string
|
||||
Tab string
|
||||
TransactionIndex uint `db:"tx_idx"`
|
||||
Raw string `db:"raw_log"`
|
||||
}
|
||||
|
@ -35,18 +35,13 @@ func NewFlipKickRepository(db *postgres.DB) FlipKickRepository {
|
||||
}
|
||||
func (fkr FlipKickRepository) Create(headerId int64, flipKick FlipKickModel) error {
|
||||
_, err := fkr.DB.Exec(
|
||||
`INSERT into maker.flip_kick (header_id, id, lot, bid, gal, "end", urn, tab, raw_log)
|
||||
VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9)`,
|
||||
headerId, flipKick.Id, flipKick.Lot, flipKick.Bid, flipKick.Gal, flipKick.End, flipKick.Urn, flipKick.Tab, flipKick.Raw,
|
||||
`INSERT into maker.flip_kick (header_id, id, lot, bid, gal, "end", urn, tab, tx_idx, raw_log)
|
||||
VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)`,
|
||||
headerId, flipKick.Id, flipKick.Lot, flipKick.Bid, flipKick.Gal, flipKick.End, flipKick.Urn, flipKick.Tab, flipKick.TransactionIndex, flipKick.Raw,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fkr FlipKickRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
|
||||
var result []core.Header
|
||||
err := fkr.DB.Select(
|
||||
|
@ -71,6 +71,7 @@ var _ = Describe("FlipKick Repository", func() {
|
||||
Expect(dbResult.End.Equal(flipKick.End)).To(BeTrue())
|
||||
Expect(dbResult.Urn).To(Equal(flipKick.Urn))
|
||||
Expect(dbResult.Tab).To(Equal(flipKick.Tab))
|
||||
Expect(dbResult.TransactionIndex).To(Equal(flipKick.TransactionIndex))
|
||||
Expect(dbResult.Raw).To(MatchJSON(flipKick.Raw))
|
||||
})
|
||||
|
||||
|
@ -61,7 +61,7 @@ var EthFlipKickLog = types.Log{
|
||||
Data: hexutil.MustDecode(flipKickData),
|
||||
BlockNumber: uint64(FlipKickBlockNumber),
|
||||
TxHash: common.HexToHash(flipKickTransactionHash),
|
||||
TxIndex: 0,
|
||||
TxIndex: 999,
|
||||
BlockHash: common.HexToHash(flipKickBlockHash),
|
||||
Index: 0,
|
||||
Removed: false,
|
||||
@ -75,6 +75,7 @@ var FlipKickEntity = flip_kick.FlipKickEntity{
|
||||
End: big.NewInt(end),
|
||||
Urn: urn,
|
||||
Tab: tab,
|
||||
TransactionIndex: EthFlipKickLog.TxIndex,
|
||||
Raw: EthFlipKickLog,
|
||||
}
|
||||
|
||||
@ -86,6 +87,7 @@ var FlipKickModel = flip_kick.FlipKickModel{
|
||||
End: time.Unix(end, 0),
|
||||
Urn: urnString,
|
||||
Tab: tabString,
|
||||
TransactionIndex: EthFlipKickLog.TxIndex,
|
||||
Raw: rawLogString,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user