6 "github.com/bytom/vapor/common"
7 "github.com/bytom/vapor/protocol/bc/types"
10 // AssetFilter is struct for allow open federation asset cross chain
11 type AssetFilter struct {
12 whitelist map[string]struct{}
15 // NewAssetFilter returns a assetFilter according a whitelist,
16 // which is a strings list cancated via comma
17 func NewAssetFilter(whitelist string) *AssetFilter {
18 af := &AssetFilter{whitelist: make(map[string]struct{})}
19 for _, assetID := range strings.Split(whitelist, ",") {
20 af.whitelist[strings.ToLower(assetID)] = struct{}{}
25 // IsDust implements the DustFilterer interface.
26 // It filters a transaction as long as there is one asset neither BTM or in the whitelist
27 // No need to check the output assets types becauese they must have been cover in input assets types
28 func (af *AssetFilter) IsDust(tx *types.Tx) bool {
29 for _, input := range tx.Inputs {
30 if crossChainInput, ok := input.TypedInput.(*types.CrossChainInput); !ok || !common.IsOpenFederationIssueAsset(crossChainInput.AssetDefinition) {
34 assetID := input.AssetID()
35 if _, ok := af.whitelist[assetID.String()]; !ok {