@@ -13,7 +13,7 @@ import (
1313 "github.com/vechain/thor/tx"
1414)
1515
16- // txObjectMap to maintain mapping of ID to tx object, and account quota.
16+ // txObjectMap to maintain mapping of tx hash to tx object, and account quota.
1717type txObjectMap struct {
1818 lock sync.RWMutex
1919 txObjMap map [thor.Bytes32 ]* txObject
@@ -27,18 +27,18 @@ func newTxObjectMap() *txObjectMap {
2727 }
2828}
2929
30- func (m * txObjectMap ) Contains (txID thor.Bytes32 ) bool {
30+ func (m * txObjectMap ) Contains (txHash thor.Bytes32 ) bool {
3131 m .lock .RLock ()
3232 defer m .lock .RUnlock ()
33- _ , found := m .txObjMap [txID ]
33+ _ , found := m .txObjMap [txHash ]
3434 return found
3535}
3636
3737func (m * txObjectMap ) Add (txObj * txObject , limitPerAccount int ) error {
3838 m .lock .Lock ()
3939 defer m .lock .Unlock ()
4040
41- if _ , found := m .txObjMap [txObj .ID ()]; found {
41+ if _ , found := m .txObjMap [txObj .Hash ()]; found {
4242 return nil
4343 }
4444
@@ -47,21 +47,21 @@ func (m *txObjectMap) Add(txObj *txObject, limitPerAccount int) error {
4747 }
4848
4949 m .quota [txObj .Origin ()]++
50- m .txObjMap [txObj .ID ()] = txObj
50+ m .txObjMap [txObj .Hash ()] = txObj
5151 return nil
5252}
5353
54- func (m * txObjectMap ) Remove (txID thor.Bytes32 ) bool {
54+ func (m * txObjectMap ) Remove (txHash thor.Bytes32 ) bool {
5555 m .lock .Lock ()
5656 defer m .lock .Unlock ()
5757
58- if txObj , ok := m .txObjMap [txID ]; ok {
58+ if txObj , ok := m .txObjMap [txHash ]; ok {
5959 if m .quota [txObj .Origin ()] > 1 {
6060 m .quota [txObj .Origin ()]--
6161 } else {
6262 delete (m .quota , txObj .Origin ())
6363 }
64- delete (m .txObjMap , txID )
64+ delete (m .txObjMap , txHash )
6565 return true
6666 }
6767 return false
@@ -93,13 +93,13 @@ func (m *txObjectMap) Fill(txObjs []*txObject) {
9393 m .lock .Lock ()
9494 defer m .lock .Unlock ()
9595 for _ , txObj := range txObjs {
96- if _ , found := m .txObjMap [txObj .ID ()]; found {
96+ if _ , found := m .txObjMap [txObj .Hash ()]; found {
9797 continue
9898 }
9999 // skip account limit check
100100
101101 m .quota [txObj .Origin ()]++
102- m .txObjMap [txObj .ID ()] = txObj
102+ m .txObjMap [txObj .Hash ()] = txObj
103103 }
104104}
105105
0 commit comments