@@ -176,7 +176,13 @@ func isCType(c CompressorType) bool {
176176 }
177177 return false
178178}
179-
179+ func compressors () []CompressorType {
180+ compressors := []CompressorType {}
181+ for _ , v := range ContractNameToCompressortype {
182+ compressors = append (compressors , v )
183+ }
184+ return compressors
185+ }
180186func (dcw * DataCompressorWrapper ) AddCompressorType (addr common.Address , cType CompressorType , discoveredAt int64 ) {
181187 if ! isCType (cType ) {
182188 log .Fatal ("ctype is wrong, " , cType )
@@ -218,7 +224,8 @@ func (dcw *DataCompressorWrapper) LoadMultipleDC(multiDCs interface{}) {
218224 sort .Slice (blockNums , func (i , j int ) bool { return blockNums [i ] < blockNums [j ] })
219225 }
220226 for _ , blockNum := range blockNums {
221- for _ , suffix := range []CompressorType {CompressorType ("" ), CompressorType ("300" ), MARKET_COMPRESSOR , POOL_COMPRESSOR , CREDIT_ACCOUNT_COMPRESSOR } {
227+ // TODO: NETWORK
228+ for _ , suffix := range append (compressors (), "" , "300" ) {
222229 key := fmt .Sprintf ("%d" , blockNum )
223230 if suffix != "" {
224231 key = fmt .Sprintf ("%d_%s" , blockNum , suffix )
@@ -240,6 +247,7 @@ func (dcw *DataCompressorWrapper) LoadMultipleDC(multiDCs interface{}) {
240247type CompressorType string
241248
242249const (
250+ // TODO : NETWORK
243251 MARKET_COMPRESSOR CompressorType = "MARKET"
244252 POOL_COMPRESSOR CompressorType = "POOL"
245253 CREDIT_ACCOUNT_COMPRESSOR CompressorType = "ACCOUNT"
@@ -416,7 +424,14 @@ func (dcw *DataCompressorWrapper) GetCreditAccountData(version core.VersionType,
416424 if err != nil {
417425 return dc.CreditAccountCallData {}, err
418426 }
419- accountData := * abi .ConvertType (out [0 ], new (creditAccountCompressor.CreditAccountData )).(* creditAccountCompressor.CreditAccountData )
427+ var accountData creditAccountCompressor.CreditAccountData
428+ switch compressorType {
429+ case CREDIT_ACCOUNT_COMPRESSOR :
430+ accountData = * abi .ConvertType (out [0 ], new (creditAccountCompressor.CreditAccountData )).(* creditAccountCompressor.CreditAccountData )
431+ case GLOBAL_ACCOUNT_COMPRESSOR :
432+ x := abi .ConvertType (out [0 ], new (globalAccountCompressor.CreditAccountData )).(* globalAccountCompressor.CreditAccountData )
433+ accountData = dc .Convert (x )
434+ }
420435 return AddFieldsToAccountv310 (dcw .client , blockNum , accountData )
421436 case DCV3 :
422437 out , err := core .GetAbi ("DataCompressorv3" ).Unpack ("getCreditAccountData" , bytes )
@@ -643,6 +658,7 @@ func (dcw *DataCompressorWrapper) GetPoolData(version core.VersionType, blockNum
643658 resultFn func ([]byte ) (dc.PoolCallData , error ),
644659 errReturn error ) {
645660 //
661+ // TODO : NETWORK
646662 key , dcAddr , compressorType := dcw .GetKeyAndAddress (version , blockNum , []CompressorType {POOL_COMPRESSOR , GLOBAL_MARKET_COMPRESSOR })
647663 switch key {
648664 case NODC :
0 commit comments