iroha icon indicating copy to clipboard operation
iroha copied to clipboard

Bitmap masks

Open mversic opened this issue 9 months ago • 1 comments

  "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

mversic avatar Apr 29 '24 08:04 mversic

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?

DCNick3 avatar May 14 '24 16:05 DCNick3