6 "github.com/bytom/vapor/consensus"
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 af.whitelist[consensus.BTMAssetID.String()] = struct{}{}
20 for _, assetID := range strings.Split(whitelist, ",") {
21 af.whitelist[strings.ToLower(assetID)] = struct{}{}
26 // IsDust implements the DustFilterer interface.
27 // It filters a transaction as long as there is one asset neither BTM or in the whitelist
28 // No need to check the output assets types becauese they must have been cover in input assets types
29 func (af *AssetFilter) IsDust(tx *types.Tx) bool {
30 for _, input := range tx.Inputs {
31 if _, ok := input.TypedInput.(*types.CrossChainInput); !ok {
35 assetID := input.AssetID()
36 if _, ok := af.whitelist[assetID.String()]; !ok {