hyperledger / iroha

Iroha - A simple, enterprise-grade decentralized ledger
https://wiki.hyperledger.org/display/iroha
Apache License 2.0
434 stars 277 forks source link

Bitmap masks #4525

Open mversic opened 4 months ago

mversic commented 4 months ago
  "AccountEventSet": {
    "Bitmap": {
      "repr": "u32",
      "masks": [
        {
          "name": "AnyAsset",
          "mask": 1
        },
        {
          "name": "Created",
          "mask": 2
        },
        {
          "name": "Deleted",
          "mask": 4
        },

Why don't we make mask the power of 2? In this case we would have:

  "AccountEventSet": {
    "Bitmap": {
      "repr": "u32",
      "masks": [
        {
          "name": "AnyAsset",
          "mask": 0
        },
        {
          "name": "Created",
          "mask": 1
        },
        {
          "name": "Deleted",
          "mask": 2
        },

This is contingent on whether it's possible to have odd numbers (multiple 1s) in a schema such as 0000 0000 0000 0011. Do we allow this possibility?

@DCNick3

DCNick3 commented 3 months ago

For now, we emit only bitmasks that are power of two.

However, I've decided to have more flexibility in the format in case we would need it.

The design basically allows representing everything representable with bitflags crate (which does let you specify more than one bit in a flag). I do not have anything in mind that would use this in the near future, but I don't think it hurts to have this possibility?