github.com/supragya/TendermintConnector@v0.0.0-20210619045051-113e32b84fb1/chains/cosmos/structsMarlin.go (about)

     1  package cosmos
     2  
     3  import (
     4  	"bufio"
     5  	"net"
     6  	"sync"
     7  	"time"
     8  
     9  	lru "github.com/hashicorp/golang-lru"
    10  	"github.com/supragya/TendermintConnector/chains/cosmos/conn"
    11  	"github.com/supragya/TendermintConnector/chains/cosmos/crypto/ed25519"
    12  	flow "github.com/supragya/TendermintConnector/chains/cosmos/libs/flowrate"
    13  	"github.com/supragya/TendermintConnector/chains/cosmos/libs/timer"
    14  	tmp2p "github.com/supragya/TendermintConnector/chains/cosmos/proto/tendermint/p2p"
    15  	marlinTypes "github.com/supragya/TendermintConnector/types"
    16  	// "github.com/tendermint/go-amino"
    17  )
    18  
    19  type keyData struct {
    20  	Chain      string
    21  	IdString   string
    22  	PrivateKey []byte
    23  	PublicKey  []byte
    24  	Integrity  string
    25  }
    26  
    27  type TendermintHandler struct {
    28  	servicedChainId        uint8
    29  	listenPort             int
    30  	isConnectionOutgoing   bool
    31  	peerAddr               string
    32  	rpcAddr                string
    33  	privateKey             ed25519.PrivKey
    34  	baseConnection         net.Conn
    35  	validatorCache         *lru.TwoQueueCache
    36  	maxValidHeight         int64
    37  	secretConnection       *conn.SecretConnection
    38  	marlinTo               chan marlinTypes.MarlinMessage
    39  	marlinFrom             chan marlinTypes.MarlinMessage
    40  	channelBuffer          map[byte][]marlinTypes.PacketMsg
    41  	proposerCache          map[int64]Validator
    42  	peerNodeInfo           tmp2p.DefaultNodeInfo
    43  	p2pConnection          P2PConnection
    44  	throughput             throughPutData
    45  	cahcedDcProposal       *ProposalMessage
    46  	cachedDcProposalPacket []marlinTypes.PacketMsg
    47  	signalConnError        chan struct{}
    48  	signalShutSend         chan struct{}
    49  	signalShutRecv         chan struct{}
    50  	signalShutThroughput   chan struct{}
    51  }
    52  
    53  type P2PConnection struct {
    54  	conn          net.Conn
    55  	bufConnReader *bufio.Reader
    56  	bufConnWriter *bufio.Writer
    57  	sendMonitor   *flow.Monitor
    58  	recvMonitor   *flow.Monitor
    59  	send          chan struct{}
    60  	pong          chan struct{}
    61  	// channels      []*Channel
    62  	// channelsIdx   map[byte]*Channel
    63  	errored uint32
    64  
    65  	// Closing quitSendRoutine will cause the sendRoutine to eventually quit.
    66  	// doneSendRoutine is closed when the sendRoutine actually quits.
    67  	quitSendRoutine chan struct{}
    68  	doneSendRoutine chan struct{}
    69  
    70  	// Closing quitRecvRouting will cause the recvRouting to eventually quit.
    71  	quitRecvRoutine chan struct{}
    72  
    73  	// used to ensure FlushStop and OnStop
    74  	// are safe to call concurrently.
    75  	stopMtx sync.Mutex
    76  
    77  	flushTimer *timer.ThrottleTimer // flush writes as necessary but throttled.
    78  	pingTimer  *time.Ticker         // send pings periodically
    79  
    80  	// close conn if pong is not received in pongTimeout
    81  	pongTimer     *time.Timer
    82  	pongTimeoutCh chan bool // true - timeout, false - peer sent pong
    83  
    84  	chStatsTimer *time.Ticker // update channel stats periodically
    85  
    86  	created time.Time // time of creation
    87  
    88  	_maxPacketMsgSize int
    89  }
    90  
    91  type throughPutData struct {
    92  	isDataConnect bool
    93  	toTMCore      map[string]uint32
    94  	fromTMCore    map[string]uint32
    95  	spam          map[string]uint32
    96  	mu            sync.Mutex
    97  }
    98  
    99  type Validator struct {
   100  	PublicKey ed25519.PubKey
   101  	Address   string
   102  }