github.com/koko1123/flow-go-1@v0.29.6/storage/badger/operation/bft.go (about) 1 package operation 2 3 import ( 4 "errors" 5 "fmt" 6 7 "github.com/dgraph-io/badger/v3" 8 9 "github.com/koko1123/flow-go-1/model/flow" 10 "github.com/koko1123/flow-go-1/storage" 11 ) 12 13 // PurgeBlocklist removes the set of blocked nodes IDs from the data base. 14 // If no corresponding entry exists, this function is a no-op. 15 // No errors are expected during normal operations. 16 // TODO: TEMPORARY manual override for adding node IDs to list of ejected nodes, applies to networking layer only 17 func PurgeBlocklist() func(*badger.Txn) error { 18 return func(tx *badger.Txn) error { 19 err := remove(makePrefix(blockedNodeIDs))(tx) 20 if err != nil && !errors.Is(err, storage.ErrNotFound) { 21 return fmt.Errorf("enexpected error while purging blocklist: %w", err) 22 } 23 return nil 24 } 25 } 26 27 // PersistBlocklist writes the set of blocked nodes IDs into the data base. 28 // If an entry already exists, it is overwritten; otherwise a new entry is created. 29 // No errors are expected during normal operations. 30 // 31 // TODO: TEMPORARY manual override for adding node IDs to list of ejected nodes, applies to networking layer only 32 func PersistBlocklist(blocklist map[flow.Identifier]struct{}) func(*badger.Txn) error { 33 return upsert(makePrefix(blockedNodeIDs), blocklist) 34 } 35 36 // RetrieveBlocklist reads the set of blocked node IDs from the data base. 37 // Returns `storage.ErrNotFound` error in case no respective data base entry is present. 38 // 39 // TODO: TEMPORARY manual override for adding node IDs to list of ejected nodes, applies to networking layer only 40 func RetrieveBlocklist(blocklist *map[flow.Identifier]struct{}) func(*badger.Txn) error { 41 return retrieve(makePrefix(blockedNodeIDs), blocklist) 42 }