Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support v0.3 schema report format in LLO #74

Merged
merged 3 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions llo/channel_definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package llo

import (
"fmt"
"sort"

llotypes "github.com/smartcontractkit/chainlink-common/pkg/types/llo"
)
Expand All @@ -27,3 +28,28 @@ func VerifyChannelDefinitions(channelDefs llotypes.ChannelDefinitions) error {
}
return nil
}

func subtractChannelDefinitions(minuend llotypes.ChannelDefinitions, subtrahend llotypes.ChannelDefinitions, limit int) llotypes.ChannelDefinitions {
differenceList := []ChannelDefinitionWithID{}
for channelID, channelDefinition := range minuend {
if _, ok := subtrahend[channelID]; !ok {
differenceList = append(differenceList, ChannelDefinitionWithID{channelDefinition, channelID})
}
}

// Sort so we return deterministic result
sort.Slice(differenceList, func(i, j int) bool {
return differenceList[i].ChannelID < differenceList[j].ChannelID
})

if len(differenceList) > limit {
differenceList = differenceList[:limit]
}

difference := llotypes.ChannelDefinitions{}
for _, defWithID := range differenceList {
difference[defWithID.ChannelID] = defWithID.ChannelDefinition
}

return difference
}
3 changes: 3 additions & 0 deletions llo/json_codec.go → llo/json_report_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func (cdc JSONReportCodec) Encode(r Report, _ llotypes.ChannelDefinition) ([]byt
}
values := make([]JSONStreamValue, len(r.Values))
for i, sv := range r.Values {
if sv == nil {
return nil, ErrNilStreamValue
}
b, err := sv.MarshalText()
if err != nil {
return nil, fmt.Errorf("failed to encode StreamValue: %w", err)
Expand Down
File renamed without changes.
16 changes: 0 additions & 16 deletions llo/onchain_config.go

This file was deleted.

Loading
Loading