mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-17 04:30:03 +02:00
internal/server/ship_processor.go: implement blacklist
This commit is contained in:
parent
6d14591f6b
commit
0bc70f82d1
1 changed files with 17 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/eosswedenorg/thalos/api/message"
|
||||
"github.com/eosswedenorg/thalos/internal/abi"
|
||||
"github.com/eosswedenorg/thalos/internal/driver"
|
||||
"github.com/eosswedenorg/thalos/internal/types"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
|
|
@ -37,6 +38,9 @@ type ShipProcessor struct {
|
|||
|
||||
// ABI Returned from SHIP
|
||||
shipABI *chain.Abi
|
||||
|
||||
// Action blacklist
|
||||
blacklist types.Blacklist
|
||||
}
|
||||
|
||||
// SpawnProcessor creates a new ShipProccessor that consumes the shipclient.Stream passed to it.
|
||||
|
|
@ -62,6 +66,10 @@ func SpawnProccessor(shipStream *shipclient.Stream, loader StateLoader, saver St
|
|||
return processor
|
||||
}
|
||||
|
||||
func (processor *ShipProcessor) SetBlacklist(list types.Blacklist) {
|
||||
processor.blacklist = list
|
||||
}
|
||||
|
||||
func (processor *ShipProcessor) initHandler(abi *chain.Abi) {
|
||||
processor.shipABI = abi
|
||||
}
|
||||
|
|
@ -144,6 +152,15 @@ func (processor *ShipProcessor) proccessActionTrace(logger *log.Entry, trace *sh
|
|||
}
|
||||
}
|
||||
|
||||
// Check blacklist if we should skip this action
|
||||
if processor.blacklist.Lookup(trace.Act.Account.String(), trace.Act.Name.String()) {
|
||||
logger.WithFields(log.Fields{
|
||||
"contract": trace.Act.Account,
|
||||
"action": trace.Act.Name,
|
||||
}).Debug("Found in blacklist, skipping")
|
||||
return nil
|
||||
}
|
||||
|
||||
act := &message.ActionTrace{
|
||||
Name: trace.Act.Name.String(),
|
||||
Contract: trace.Act.Account.String(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue