github.com/prebid/prebid-server/v2@v2.18.0/schain/schain.go (about) 1 package schain 2 3 import ( 4 "fmt" 5 6 "github.com/prebid/openrtb/v20/openrtb2" 7 8 "github.com/prebid/prebid-server/v2/openrtb_ext" 9 ) 10 11 // BidderToPrebidSChains organizes the ORTB 2.5 multiple root schain nodes into a map of schain nodes by bidder 12 func BidderToPrebidSChains(sChains []*openrtb_ext.ExtRequestPrebidSChain) (map[string]*openrtb2.SupplyChain, error) { 13 bidderToSChains := make(map[string]*openrtb2.SupplyChain) 14 15 for _, schainWrapper := range sChains { 16 for _, bidder := range schainWrapper.Bidders { 17 if _, present := bidderToSChains[bidder]; present { 18 return nil, fmt.Errorf("request.ext.prebid.schains contains multiple schains for bidder %s; "+ 19 "it must contain no more than one per bidder.", bidder) 20 } else { 21 bidderToSChains[bidder] = &schainWrapper.SChain 22 } 23 } 24 } 25 26 return bidderToSChains, nil 27 }