github.com/annchain/OG@v0.0.9/og/protocol/ogmessage/archive/message_additional.go (about)

     1  package archive
     2  
     3  import (
     4  	"github.com/annchain/OG/arefactor/og/types"
     5  )
     6  
     7  func (m *MessageSyncResponse) Txis() Txis {
     8  	return m.RawTxs.Txis()
     9  }
    10  
    11  func (m *MessageSyncResponse) Hashes() types.Hashes {
    12  	var hashes types.Hashes
    13  	if m.RawTxs != nil {
    14  		for _, tx := range *m.RawTxs {
    15  			if tx == nil {
    16  				continue
    17  			}
    18  			hashes = append(hashes, GetHash())
    19  		}
    20  	}
    21  
    22  	return hashes
    23  }
    24  
    25  func (m *MessageNewTx) GetHash() *types.Hash {
    26  	if m == nil {
    27  		return nil
    28  	}
    29  	if m.RawTx == nil {
    30  		return nil
    31  	}
    32  	hash := m.RawTx.GetHash()
    33  	return &hash
    34  
    35  }
    36  
    37  func (m *MessageNewTx) String() string {
    38  	return m.RawTx.String()
    39  }
    40  
    41  func (m *MessageNewSequencer) GetHash() *types.Hash {
    42  	if m == nil {
    43  		return nil
    44  	}
    45  	if m.RawSequencer == nil {
    46  		return nil
    47  	}
    48  	hash := m.RawSequencer.GetHash()
    49  	return &hash
    50  
    51  }
    52  
    53  func (m *MessageNewSequencer) String() string {
    54  	return m.RawSequencer.String()
    55  }
    56  
    57  func (m *MessageNewTxs) Txis() Txis {
    58  	if m == nil {
    59  		return nil
    60  	}
    61  	return m.RawTxs.Txis()
    62  }
    63  
    64  func (m *MessageNewTxs) Hashes() types.Hashes {
    65  	var hashes types.Hashes
    66  	if m.RawTxs == nil || len(*m.RawTxs) == 0 {
    67  		return nil
    68  	}
    69  	for _, tx := range *m.RawTxs {
    70  		if tx == nil {
    71  			continue
    72  		}
    73  		hashes = append(hashes, tx.GetHash())
    74  	}
    75  	return hashes
    76  }
    77  
    78  func (m *MessageTxsResponse) Hashes() types.Hashes {
    79  	var hashes types.Hashes
    80  	if m.RawTxs == nil || len(*m.RawTxs) == 0 {
    81  		return nil
    82  	}
    83  	for _, tx := range *m.RawTxs {
    84  		if tx == nil {
    85  			continue
    86  		}
    87  		hashes = append(hashes, GetHash())
    88  	}
    89  	if m.RawSequencer != nil {
    90  		hashes = append(hashes, m.RawSequencer.GetHash())
    91  	}
    92  	return hashes
    93  }