Skip to content

Commit

Permalink
Adapt to nodebridge changes
Browse files Browse the repository at this point in the history
  • Loading branch information
muXxer committed Nov 27, 2023
1 parent f38f470 commit a246ba7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 57 deletions.
56 changes: 17 additions & 39 deletions components/indexer/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func init() {

type dependencies struct {
dig.In
NodeBridge *nodebridge.NodeBridge
NodeBridge nodebridge.NodeBridge
Indexer *indexer.Indexer
ShutdownHandler *shutdown.ShutdownHandler
Echo *echo.Echo
Expand Down Expand Up @@ -412,32 +412,21 @@ func fillIndexer(ctx context.Context, indexer *indexer.Indexer) (int, error) {

func LedgerUpdateFromNodeBridge(update *nodebridge.LedgerUpdate) (*indexer.LedgerUpdate, error) {
consumed := make([]*indexer.LedgerOutput, len(update.Consumed))
for i, spent := range update.Consumed {
output := spent.GetOutput()
iotaOutput, err := output.UnwrapOutput(update.API)
if err != nil {
return nil, err
}

for i, output := range update.Consumed {
consumed[i] = &indexer.LedgerOutput{
OutputID: output.UnwrapOutputID(),
Output: iotaOutput,
BookedAt: iotago.SlotIndex(output.GetSlotBooked()),
SpentAt: iotago.SlotIndex(spent.GetSlotSpent()),
OutputID: output.OutputID,
Output: output.Output,
BookedAt: output.SlotBooked,
SpentAt: output.SlotSpent,
}
}

created := make([]*indexer.LedgerOutput, len(update.Created))
for i, output := range update.Created {
iotaOutput, err := output.UnwrapOutput(update.API)
if err != nil {
return nil, err
}

created[i] = &indexer.LedgerOutput{
OutputID: output.UnwrapOutputID(),
Output: iotaOutput,
BookedAt: iotago.SlotIndex(output.GetSlotBooked()),
OutputID: output.OutputID,
Output: output.Output,
BookedAt: output.SlotBooked,
}
}

Expand All @@ -450,32 +439,21 @@ func LedgerUpdateFromNodeBridge(update *nodebridge.LedgerUpdate) (*indexer.Ledge

func LedgerUpdateFromNodeBridgeAcceptedTransaction(tx *nodebridge.AcceptedTransaction) (*indexer.LedgerUpdate, error) {
consumed := make([]*indexer.LedgerOutput, len(tx.Consumed))
for i, spent := range tx.Consumed {
output := spent.GetOutput()
iotaOutput, err := output.UnwrapOutput(tx.API)
if err != nil {
return nil, err
}

for i, output := range tx.Consumed {
consumed[i] = &indexer.LedgerOutput{
OutputID: output.UnwrapOutputID(),
Output: iotaOutput,
BookedAt: iotago.SlotIndex(output.GetSlotBooked()),
SpentAt: tx.Slot,
OutputID: output.OutputID,
Output: output.Output,
BookedAt: output.SlotBooked,
SpentAt: output.SlotSpent,
}
}

created := make([]*indexer.LedgerOutput, len(tx.Created))
for i, output := range tx.Created {
iotaOutput, err := output.UnwrapOutput(tx.API)
if err != nil {
return nil, err
}

created[i] = &indexer.LedgerOutput{
OutputID: output.UnwrapOutputID(),
Output: iotaOutput,
BookedAt: tx.Slot,
OutputID: output.OutputID,
Output: output.Output,
BookedAt: output.SlotBooked,
}
}

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ require (
github.com/iotaledger/hive.go/lo v0.0.0-20231122112629-bdf1cc39fba7
github.com/iotaledger/hive.go/logger v0.0.0-20231113110812-4ca2b6cc9a42
github.com/iotaledger/hive.go/runtime v0.0.0-20231122112629-bdf1cc39fba7
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231123103852-bb039cbab83b
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231123103318-f6ea945e2e98
github.com/iotaledger/iota.go/v4 v4.0.0-20231123102955-eff367396512
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231127162144-bba7e494e442
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231124154447-f20fb8921e8c
github.com/iotaledger/iota.go/v4 v4.0.0-20231124103306-ad44904e2b86
github.com/labstack/echo-contrib v0.15.0
github.com/labstack/echo/v4 v4.11.3
github.com/pkg/errors v0.9.1
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6c
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6cc9a42/go.mod h1:FoH3T6yKlZJp8xm8K+zsQiibSynp32v21CpWx8xkek8=
github.com/iotaledger/hive.go/stringify v0.0.0-20231122112629-bdf1cc39fba7 h1:h481Dn+giKO/1MamwuDZ8Mvzg4GbPx/asKD/X3Zs8wc=
github.com/iotaledger/hive.go/stringify v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231123103852-bb039cbab83b h1:T/9f4eYcP/fxe0G0pYa6TRZxD9rI9uMdDW89hnsNByU=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231123103852-bb039cbab83b/go.mod h1:c7ktZxoH5Wp2ixzJn/8RmM5v2QOCIu/79tDFvfLbyPs=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231123103318-f6ea945e2e98 h1:PjGs+njONeFaxFgQ3lxxlRs3wTYw3233f/yDyTV8/F8=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231123103318-f6ea945e2e98/go.mod h1:jFRt2SZO3KE74/mk+zeCjlhVROriEg86K8CJTxvfdP8=
github.com/iotaledger/iota.go/v4 v4.0.0-20231123102955-eff367396512 h1:E1m9Ja6d47sVkl0k2a8eU9f5COWqpyNY9ET3TyYLHiI=
github.com/iotaledger/iota.go/v4 v4.0.0-20231123102955-eff367396512/go.mod h1:aO+5iL0vTNwNfE4QMGHVIufGziSI1wTvwJY1ipSMgCk=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231127162144-bba7e494e442 h1:izm0bwyHjas8T76MTTvzy3xG96iZ1Hk1QfsGk1eS2Cs=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231127162144-bba7e494e442/go.mod h1:iL2W0qVT3gUKEEKSDuuvVWK0wj4iJMPR0rDEiPUDI2A=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231124154447-f20fb8921e8c h1:BS7T2gXCJQeXyLZ3fLHbX8HJDx9zDAnj5P1ZB/5XahY=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231124154447-f20fb8921e8c/go.mod h1:WsNHyemrN5A9GIlmQMEB0mpqU8SymMZaaKBfhV31y5k=
github.com/iotaledger/iota.go/v4 v4.0.0-20231124103306-ad44904e2b86 h1:vIQemhyUKXzLtmuyadp2VAwg2lGGYciIjRIqWSMs/30=
github.com/iotaledger/iota.go/v4 v4.0.0-20231124103306-ad44904e2b86/go.mod h1:aO+5iL0vTNwNfE4QMGHVIufGziSI1wTvwJY1ipSMgCk=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
Expand Down
6 changes: 3 additions & 3 deletions tools/gendoc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ require (
github.com/iotaledger/hive.go/runtime v0.0.0-20231122112629-bdf1cc39fba7 // indirect
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6cc9a42 // indirect
github.com/iotaledger/hive.go/stringify v0.0.0-20231122112629-bdf1cc39fba7 // indirect
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231123103852-bb039cbab83b // indirect
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231123103318-f6ea945e2e98 // indirect
github.com/iotaledger/iota.go/v4 v4.0.0-20231123102955-eff367396512 // indirect
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231127162144-bba7e494e442 // indirect
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231124154447-f20fb8921e8c // indirect
github.com/iotaledger/iota.go/v4 v4.0.0-20231124103306-ad44904e2b86 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.5.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions tools/gendoc/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6c
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6cc9a42/go.mod h1:FoH3T6yKlZJp8xm8K+zsQiibSynp32v21CpWx8xkek8=
github.com/iotaledger/hive.go/stringify v0.0.0-20231122112629-bdf1cc39fba7 h1:h481Dn+giKO/1MamwuDZ8Mvzg4GbPx/asKD/X3Zs8wc=
github.com/iotaledger/hive.go/stringify v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231123103852-bb039cbab83b h1:T/9f4eYcP/fxe0G0pYa6TRZxD9rI9uMdDW89hnsNByU=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231123103852-bb039cbab83b/go.mod h1:c7ktZxoH5Wp2ixzJn/8RmM5v2QOCIu/79tDFvfLbyPs=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231123103318-f6ea945e2e98 h1:PjGs+njONeFaxFgQ3lxxlRs3wTYw3233f/yDyTV8/F8=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231123103318-f6ea945e2e98/go.mod h1:jFRt2SZO3KE74/mk+zeCjlhVROriEg86K8CJTxvfdP8=
github.com/iotaledger/iota.go/v4 v4.0.0-20231123102955-eff367396512 h1:E1m9Ja6d47sVkl0k2a8eU9f5COWqpyNY9ET3TyYLHiI=
github.com/iotaledger/iota.go/v4 v4.0.0-20231123102955-eff367396512/go.mod h1:aO+5iL0vTNwNfE4QMGHVIufGziSI1wTvwJY1ipSMgCk=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231127162144-bba7e494e442 h1:izm0bwyHjas8T76MTTvzy3xG96iZ1Hk1QfsGk1eS2Cs=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231127162144-bba7e494e442/go.mod h1:iL2W0qVT3gUKEEKSDuuvVWK0wj4iJMPR0rDEiPUDI2A=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231124154447-f20fb8921e8c h1:BS7T2gXCJQeXyLZ3fLHbX8HJDx9zDAnj5P1ZB/5XahY=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231124154447-f20fb8921e8c/go.mod h1:WsNHyemrN5A9GIlmQMEB0mpqU8SymMZaaKBfhV31y5k=
github.com/iotaledger/iota.go/v4 v4.0.0-20231124103306-ad44904e2b86 h1:vIQemhyUKXzLtmuyadp2VAwg2lGGYciIjRIqWSMs/30=
github.com/iotaledger/iota.go/v4 v4.0.0-20231124103306-ad44904e2b86/go.mod h1:aO+5iL0vTNwNfE4QMGHVIufGziSI1wTvwJY1ipSMgCk=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
Expand Down

0 comments on commit a246ba7

Please sign in to comment.