Research Article
A Multi-Blockchain-Based Cross-Domain Authentication and Authorization Scheme for Energy Internet
Algorithm 5
The chaincode about the delete algorithm of the cuckoo filter.
1: Procedure func (s SmartContract) Delete(ctx contractapi.TransactionContextInterface, id string, item string) error | 2: cfJSON, err: = ctx.GetStub().GetState(id) | 3: If err! = nil then | 4: Return shim.Error(err.Error()) | 5: End if | 6: var cf CFilter | 7: err = json.Unmarshal(cfJSON, &cf) | 8: If err! = nil then | 9: Return shim.Error(err.Error()) | 10: End if | 11: f := fprint([]byte(item), cf.FpSize, Hashfn) | 12: j := hashfp([]byte(item)) % cf.Size | 13: k := (j XOR hashfp(f)) % cf.Size | 14: If cf.Buckets[j].remove(f) || cf.Buckets[k].remove(f) then | 15: cf.Count-- | 16: End if | 17: cfJSON, err = json.Marshal(&cf) | 18: If err! = nil then | 19: Return shim.Error(err.Error()) | 20: End if | 21: cf_ := CF{id: id, cfilter: cfJSON} | 22: err = ctx.GetStub().PutState(cf_.id, cf_.cfilter) | 23: If err! = nil then | 24: Return shim.Error(err.Error()) | 25: End if | 26: Return nil | 27: End procedure |
|