Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Release 0.5.1 #78

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions collect/service/cmd/chain/bnb/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (s *Service) GetBlockByHash(blockHash string, eLog *logrus.Entry, flag bool
return nil, nil
}

r := &collect.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block}
r := &collect.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block, BlockTime: block.BlockTime}
if !flag { //仅区块,不涉及交易
return r, nil
}
Expand Down Expand Up @@ -118,7 +118,6 @@ func (s *Service) GetBlockByHash(blockHash string, eLog *logrus.Entry, flag bool
txs = append(txs, t)
}
}
//r := &service.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block}
return r, txs
}

Expand Down Expand Up @@ -158,7 +157,7 @@ func (s *Service) GetBlockByNumber(blockNumber string, eLog *logrus.Entry, flag
return nil, nil
}

r := &collect.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block}
r := &collect.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block, BlockTime: block.BlockTime}
if !flag { //仅区块数据,不涉及交易
return r, nil
}
Expand Down Expand Up @@ -191,7 +190,6 @@ func (s *Service) GetBlockByNumber(blockNumber string, eLog *logrus.Entry, flag
eLog.Warnf("the tx is ignored,hash=%v", tx.TxHash)
}
}
//r := &service.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block}
return r, txs
}

Expand Down Expand Up @@ -220,6 +218,14 @@ func (s *Service) GetTx(txHash string, eLog *logrus.Entry) *collect.TxInterface
return nil
}

//fix tx.time
if len(tx.TxTime) < 1 {
b, _ := s.GetBlockByNumber(tx.BlockNumber, eLog, false)
if b != nil {
tx.TxTime = b.BlockTime
}
}

receipt, err := s.GetReceipt(tx.TxHash, eLog)
if err != nil {
eLog.Errorf("GetTx|BlockChainCode=%v,err=%v,txHash=%v", s.chain.BlockChainCode, err.Error(), tx.TxHash)
Expand Down
14 changes: 10 additions & 4 deletions collect/service/cmd/chain/ether/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (s *Service) GetBlockByHash(blockHash string, eLog *logrus.Entry, flag bool
return nil, nil
}

r := &collect.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block}
r := &collect.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block, BlockTime: block.BlockTime}
if !flag { //仅区块,不涉及交易
return r, nil
}
Expand Down Expand Up @@ -118,7 +118,6 @@ func (s *Service) GetBlockByHash(blockHash string, eLog *logrus.Entry, flag bool
txs = append(txs, t)
}
}
//r := &service.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block}
return r, txs
}

Expand Down Expand Up @@ -158,7 +157,7 @@ func (s *Service) GetBlockByNumber(blockNumber string, eLog *logrus.Entry, flag
return nil, nil
}

r := &collect.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block}
r := &collect.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block, BlockTime: block.BlockTime}
if !flag { //仅区块数据,不涉及交易
return r, nil
}
Expand Down Expand Up @@ -191,7 +190,6 @@ func (s *Service) GetBlockByNumber(blockNumber string, eLog *logrus.Entry, flag
eLog.Warnf("the tx is ignored,hash=%v", tx.TxHash)
}
}
//r := &service.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block}
return r, txs
}

Expand Down Expand Up @@ -220,6 +218,14 @@ func (s *Service) GetTx(txHash string, eLog *logrus.Entry) *collect.TxInterface
return nil
}

//fix tx.time
if len(tx.TxTime) < 1 {
b, _ := s.GetBlockByNumber(tx.BlockNumber, eLog, false)
if b != nil {
tx.TxTime = b.BlockTime
}
}

receipt, err := s.GetReceipt(tx.TxHash, eLog)
if err != nil {
eLog.Errorf("GetTx|BlockChainCode=%v,err=%v,txHash=%v", s.chain.BlockChainCode, err.Error(), tx.TxHash)
Expand Down
6 changes: 5 additions & 1 deletion collect/service/cmd/chain/ether/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ func TestService_GetBlockByNumber(t *testing.T) {
func TestService_GetTx(t *testing.T) {
s, _, x := Init()
tx := s.GetTx("0xb7959ab3ed0f8b424f897ba8ec28168358079be0030a9337d20252f7d4c18cfd", x.WithFields(logrus.Fields{}))
t.Log(tx)
if tx == nil {
t.Error("fail")
} else {
t.Logf("%+v", tx.Tx)
}
}

func TestService_GetReceipt(t *testing.T) {
Expand Down
14 changes: 10 additions & 4 deletions collect/service/cmd/chain/polygonpos/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (s *Service) GetBlockByHash(blockHash string, eLog *logrus.Entry, flag bool
return nil, nil
}

r := &collect.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block}
r := &collect.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block, BlockTime: block.BlockTime}
if !flag { //仅区块,不涉及交易
return r, nil
}
Expand Down Expand Up @@ -118,7 +118,6 @@ func (s *Service) GetBlockByHash(blockHash string, eLog *logrus.Entry, flag bool
txs = append(txs, t)
}
}
//r := &service.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block}
return r, txs
}

Expand Down Expand Up @@ -158,7 +157,7 @@ func (s *Service) GetBlockByNumber(blockNumber string, eLog *logrus.Entry, flag
return nil, nil
}

r := &collect.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block}
r := &collect.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block, BlockTime: block.BlockTime}
if !flag { //仅区块数据,不涉及交易
return r, nil
}
Expand Down Expand Up @@ -191,7 +190,6 @@ func (s *Service) GetBlockByNumber(blockNumber string, eLog *logrus.Entry, flag
eLog.Warnf("the tx is ignored,hash=%v", tx.TxHash)
}
}
//r := &service.BlockInterface{BlockHash: block.BlockHash, BlockNumber: block.BlockNumber, Block: block}
return r, txs
}

Expand Down Expand Up @@ -220,6 +218,14 @@ func (s *Service) GetTx(txHash string, eLog *logrus.Entry) *collect.TxInterface
return nil
}

//fix tx.time
if len(tx.TxTime) < 1 {
b, _ := s.GetBlockByNumber(tx.BlockNumber, eLog, false)
if b != nil {
tx.TxTime = b.BlockTime
}
}

receipt, err := s.GetReceipt(tx.TxHash, eLog)
if err != nil {
eLog.Errorf("GetTx|BlockChainCode=%v,err=%v,txHash=%v", s.chain.BlockChainCode, err.Error(), tx.TxHash)
Expand Down
1 change: 1 addition & 0 deletions collect/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ type Block struct {

type BlockInterface struct {
BlockHash string `json:"hash" gorm:"column:hash"`
BlockTime string `json:"blockTime"`
BlockNumber string `json:"number" gorm:"column:block_number"`
Block interface{} `json:"block"`
}