From 98dcefc50460f713658e7a5933766fff695156c7 Mon Sep 17 00:00:00 2001 From: sidhujag Date: Wed, 6 May 2020 13:48:51 -0700 Subject: [PATCH] fix basecoin masking --- bchain/baseparser.go | 2 +- bchain/types.go | 20 ++++++++++---------- db/rocksdb_ethereumtype.go | 2 +- db/rocksdb_syscointype.go | 2 +- db/rocksdb_test.go | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bchain/baseparser.go b/bchain/baseparser.go index 34f067e1..cfc6bb58 100644 --- a/bchain/baseparser.go +++ b/bchain/baseparser.go @@ -323,7 +323,7 @@ func (p *BaseParser) IsAssetActivateTx(nVersion int32) bool { return false } func (p *BaseParser) GetAssetsMaskFromVersion(nVersion int32) AssetsMask { - return AllMask + return BaseCoinMask } func (p *BaseParser) GetAssetTypeFromVersion(nVersion int32) TokenType { return SPTUnknownType diff --git a/bchain/types.go b/bchain/types.go index 44673ca1..2d8375b2 100644 --- a/bchain/types.go +++ b/bchain/types.go @@ -437,17 +437,17 @@ const SPTAssetAllocationBurnToSyscoinType TokenType = "SPTAssetAllocationBurnToS const SPTAssetAllocationBurnToEthereumType TokenType = "SPTAssetAllocationBurnToEthereum" -const AllMask AssetsMask = 1 -const BaseCoinMask AssetsMask = 2 -const AssetAllocationSendMask AssetsMask = 4 -const AssetSyscoinBurnToAllocationMask AssetsMask = 8 -const AssetAllocationBurnToSyscoinMask AssetsMask = 16 -const AssetAllocationBurnToEthereumMask AssetsMask = 32 -const AssetAllocationMintMask AssetsMask = 64 -const AssetUpdateMask AssetsMask = 128 -const AssetSendMask AssetsMask = 256 -const AssetActivateMask AssetsMask = 512 +const BaseCoinMask AssetsMask = 1 +const AssetAllocationSendMask AssetsMask = 2 +const AssetSyscoinBurnToAllocationMask AssetsMask = 4 +const AssetAllocationBurnToSyscoinMask AssetsMask = 8 +const AssetAllocationBurnToEthereumMask AssetsMask = 16 +const AssetAllocationMintMask AssetsMask = 32 +const AssetUpdateMask AssetsMask = 64 +const AssetSendMask AssetsMask = 128 +const AssetActivateMask AssetsMask = 256 const AssetMask AssetsMask = AssetActivateMask | AssetUpdateMask | AssetSendMask | AssetSyscoinBurnToAllocationMask | AssetAllocationBurnToSyscoinMask | AssetAllocationBurnToEthereumMask | AssetAllocationMintMask | AssetAllocationSendMask +const AllMask AssetsMask = BaseCoinMask | AssetMask // Amount is datatype holding amounts type Amount big.Int // MarshalJSON Amount serialization diff --git a/db/rocksdb_ethereumtype.go b/db/rocksdb_ethereumtype.go index 8ec9cafe..5c4bb551 100644 --- a/db/rocksdb_ethereumtype.go +++ b/db/rocksdb_ethereumtype.go @@ -143,7 +143,7 @@ func (d *RocksDB) addToAddressesAndContractsEthereumType(addrDesc bchain.Address } } } - counted := addToAddressesMap(addresses, strAddrDesc, btxID, index, bchain.AllMask) + counted := addToAddressesMap(addresses, strAddrDesc, btxID, index, bchain.BaseCoinMask) if !counted { ac.TotalTxs++ } diff --git a/db/rocksdb_syscointype.go b/db/rocksdb_syscointype.go index d4817aca..a7886b35 100644 --- a/db/rocksdb_syscointype.go +++ b/db/rocksdb_syscointype.go @@ -407,7 +407,7 @@ func (d *RocksDB) GetTxAssets(assetGuid uint32, lower uint32, higher uint32, ass txids := []string{} for _, txIndex := range txIndexes { mask := uint32(txIndex.Type) - if (assetsBitMask == bchain.AllMask || (uint32(assetsBitMask) & mask) == mask) { + if (uint32(assetsBitMask) & mask) == mask { txids = append(txids, hex.EncodeToString(txIndex.BtxID)) } } diff --git a/db/rocksdb_test.go b/db/rocksdb_test.go index e7ec1983..34818e90 100644 --- a/db/rocksdb_test.go +++ b/db/rocksdb_test.go @@ -112,7 +112,7 @@ func addressKeyHex(a string, height uint32, d *RocksDB) string { func txIndexesHex(tx string, indexes []int32, d *RocksDB) string { buf := make([]byte, vlq.MaxLen32) // type - l := d.chainParser.PackVaruint(uint(bchain.AllMask), buf) + l := d.chainParser.PackVaruint(uint(bchain.BaseCoinMask), buf) tx = hex.EncodeToString(buf[:l]) + tx for i, index := range indexes { index <<= 1