Versions in this module Expand all Collapse all v1 v1.0.0 Jun 26, 2019 Changes in this version + const BridgeAddrJournal + const ErrDecode + const ErrInvalidMsgCode + const ErrMsgTooLarge + const ErrNetworkIdMismatch + const ErrNoStatusMsg + const ErrProtocolVersionMismatch + const ErrUnexpectedTxType + const GasLimit + const KLAY + const NFT + const ProtocolMaxMsgSize + const ServiceChainParentChainInfoRequestMsg + const ServiceChainParentChainInfoResponseMsg + const ServiceChainReceiptRequestMsg + const ServiceChainReceiptResponseMsg + const ServiceChainTxsMsg + const StatusMsg + const SyncRequestInterval + const TOKEN + const TokenEventChanSize + var ConnectionFailErr = errors.New("fail to connect remote chain") + var DefaultBridgeTxPoolConfig = BridgeTxPoolConfig + var DefaultConfig = SCConfig + var ErrAlreadyExistentBridgePair = errors.New("bridge already exists") + var ErrDuplicatedNonceTx = errors.New("Duplicated Nonce Transaction") + var ErrGetServiceChainPHInCCEH = errors.New("ServiceChainPH isn't set in ChildChainEventHandler") + var ErrGetServiceChainPHInMCEH = errors.New("ServiceChainPH isn't set in MainChainEventHandler") + var ErrInvalidBridgePair = errors.New("invalid bridge pair") + var ErrKnownTx = errors.New("Known Transaction") + var ErrNoChildChainID = errors.New("There is no childChainID") + var ErrUnknownTx = errors.New("Unknown Transaction") + var ErrVtrAlreadyStarted = errors.New("VTR is already started") + var ErrVtrDisabled = errors.New("VTR is disabled") + var SCProtocolLength = []uint64 + var SCProtocolName = "servicechain" + var SCProtocolVersion = []uint + func CreateDB(ctx *node.ServiceContext, config *SCConfig, name string) database.DBManager + func MakeTransactOpts(accountKey *ecdsa.PrivateKey, nonce *big.Int, chainID *big.Int, ...) *bind.TransactOpts + func NewValueTransferRecovery(config *SCConfig, scBridgeInfo, mcBridgeInfo *BridgeInfo) *valueTransferRecovery + type AddressManager struct + func NewAddressManager() (*AddressManager, error) + func (am *AddressManager) AddBridge(bridge1 common.Address, bridge2 common.Address) error + func (am *AddressManager) AddToken(token1 common.Address, token2 common.Address) error + func (am *AddressManager) DeleteBridge(bridge1 common.Address) (common.Address, common.Address, error) + func (am *AddressManager) DeleteToken(token1 common.Address) (common.Address, common.Address, error) + func (am *AddressManager) GetCounterPartBridge(addr common.Address) common.Address + func (am *AddressManager) GetCounterPartToken(addr common.Address) common.Address + type Backend interface + type BridgeAccountManager struct + func NewBridgeAccountManager(mcKey, scKey *ecdsa.PrivateKey) (*BridgeAccountManager, error) + type BridgeInfo struct + func NewBridgeInfo(subBridge *SubBridge, addr common.Address, bridge *bridgecontract.Bridge, ...) *BridgeInfo + func (bi *BridgeInfo) AddRequestValueTransferEvents(evs []*RequestValueTransferEvent) + func (bi *BridgeInfo) GetReadyRequestValueTransferEvents() []*RequestValueTransferEvent + func (bi *BridgeInfo) UpdateHandledNonce(nonce uint64) + func (bi *BridgeInfo) UpdateInfo() error + func (bi *BridgeInfo) UpdateRequestNonce(nonce uint64) + func (bi *BridgeInfo) UpdateRequestNonceFromCounterpart(nonce uint64) + type BridgeJournal struct + LocalAddress common.Address + RemoteAddress common.Address + Subscribed bool + func (b *BridgeJournal) DecodeRLP(s *rlp.Stream) error + func (b *BridgeJournal) EncodeRLP(w io.Writer) error + type BridgeManager struct + func NewBridgeManager(main *SubBridge) (*BridgeManager, error) + func (bm *BridgeManager) AddRecovery(localAddress, remoteAddress common.Address) error + func (bm *BridgeManager) DeleteBridgeInfo(addr common.Address) error + func (bm *BridgeManager) DeleteRecovery(localAddress, remoteAddress common.Address) error + func (bm *BridgeManager) DeployBridge(backend bind.ContractBackend, local bool) (*bridgecontract.Bridge, common.Address, error) + func (bm *BridgeManager) GetAllBridge() []*BridgeJournal + func (bm *BridgeManager) GetBridgeInfo(addr common.Address) (*BridgeInfo, bool) + func (bm *BridgeManager) LogBridgeStatus() + func (bm *BridgeManager) ResetAllSubscribedEvents() error + func (bm *BridgeManager) RestoreBridges() error + func (bm *BridgeManager) SetBridgeInfo(addr common.Address, bridge *bridgecontract.Bridge, cpAddr common.Address, ...) error + func (bm *BridgeManager) SetJournal(localAddress, remoteAddress common.Address) error + func (bm *BridgeManager) Stop() + func (bm *BridgeManager) SubscribeEvent(addr common.Address) error + func (bm *BridgeManager) SubscribeTokenReceived(ch chan<- RequestValueTransferEvent) event.Subscription + func (bm *BridgeManager) SubscribeTokenWithDraw(ch chan<- HandleValueTransferEvent) event.Subscription + func (bm *BridgeManager) UnsubscribeEvent(addr common.Address) + type BridgePeer interface + AddToKnownTxs func(hash common.Hash) + Close func() + ConnType func() p2p.ConnType + GetAddr func() common.Address + GetChainID func() *big.Int + GetID func() string + GetP2PPeer func() *p2p.Peer + GetP2PPeerID func() discover.NodeID + GetRW func() p2p.MsgReadWriter + GetVersion func() int + Handle func(bn *MainBridge) error + Handshake func(network uint64, chainID, td *big.Int, head common.Hash) error + Head func() (hash common.Hash, td *big.Int) + Info func() *BridgePeerInfo + KnowsTx func(hash common.Hash) bool + Send func(msgcode uint64, data interface{}) error + SendServiceChainInfoRequest func(addr *common.Address) error + SendServiceChainInfoResponse func(pcInfo *parentChainInfo) error + SendServiceChainReceiptRequest func(txHashes []common.Hash) error + SendServiceChainReceiptResponse func(receipts []*types.ReceiptForStorage) error + SendServiceChainTxs func(txs types.Transactions) error + SetAddr func(addr common.Address) + type BridgePeerInfo struct + Head string + Version int + type BridgeTxPool struct + func NewBridgeTxPool(config BridgeTxPoolConfig) *BridgeTxPool + func (pool *BridgeTxPool) AddLocal(tx *types.Transaction) error + func (pool *BridgeTxPool) AddLocals(txs []*types.Transaction) []error + func (pool *BridgeTxPool) Content() map[common.Address]types.Transactions + func (pool *BridgeTxPool) Get(hash common.Hash) *types.Transaction + func (pool *BridgeTxPool) GetMaxTxNonce(from *common.Address) uint64 + func (pool *BridgeTxPool) GetTx(txHash common.Hash) (*types.Transaction, error) + func (pool *BridgeTxPool) Pending() map[common.Address]types.Transactions + func (pool *BridgeTxPool) PendingTxHashesByAddress(from *common.Address, limit int) []common.Hash + func (pool *BridgeTxPool) PendingTxsByAddress(from *common.Address, limit int) types.Transactions + func (pool *BridgeTxPool) Remove(txs types.Transactions) []error + func (pool *BridgeTxPool) RemoveTx(tx *types.Transaction) error + func (pool *BridgeTxPool) SetEIP155Signer(chainID *big.Int) + func (pool *BridgeTxPool) Stats() int + func (pool *BridgeTxPool) Stop() + type BridgeTxPoolConfig struct + GlobalQueue uint64 + Journal string + ParentChainID *big.Int + Rejournal time.Duration + type ChildChainEventHandler struct + func NewChildChainEventHandler(bridge *SubBridge, handler *SubBridgeHandler) (*ChildChainEventHandler, error) + func (cce *ChildChainEventHandler) ConvertServiceChainBlockHashToMainChainTxHash(scBlockHash common.Hash) common.Hash + func (cce *ChildChainEventHandler) HandleChainHeadEvent(block *types.Block) error + func (cce *ChildChainEventHandler) HandleLogsEvent(logs []*types.Log) error + func (cce *ChildChainEventHandler) HandleTxEvent(tx *types.Transaction) error + func (cce *ChildChainEventHandler) HandleTxsEvent(txs []*types.Transaction) error + func (cce *ChildChainEventHandler) ProcessHandleEvent(ev HandleValueTransferEvent) error + func (cce *ChildChainEventHandler) ProcessRequestEvent(ev RequestValueTransferEvent) error + type HandleValueTransferEvent struct + Amount *big.Int + ContractAddr common.Address + HandleNonce uint64 + Owner common.Address + TokenAddr common.Address + TokenType uint8 + type LocalBackend struct + func NewLocalBackend(main *SubBridge) (*LocalBackend, error) + func (lb *LocalBackend) CallContract(ctx context.Context, call klaytn.CallMsg, blockNumber *big.Int) ([]byte, error) + func (lb *LocalBackend) ChainID(ctx context.Context) (*big.Int, error) + func (lb *LocalBackend) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error) + func (lb *LocalBackend) EstimateGas(ctx context.Context, call klaytn.CallMsg) (gas uint64, err error) + func (lb *LocalBackend) FilterLogs(ctx context.Context, query klaytn.FilterQuery) ([]types.Log, error) + func (lb *LocalBackend) PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error) + func (lb *LocalBackend) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) + func (lb *LocalBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error + func (lb *LocalBackend) SubscribeFilterLogs(ctx context.Context, query klaytn.FilterQuery, ch chan<- types.Log) (klaytn.Subscription, error) + func (lb *LocalBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error) + func (lb *LocalBackend) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) + type MainBridge struct + APIBackend *MainBridgeAPI + func NewMainBridge(ctx *node.ServiceContext, config *SCConfig) (*MainBridge, error) + func (mb *MainBridge) BridgePeerSet() *bridgePeerSet + func (pm *MainBridge) NodeInfo() *MainBridgeInfo + func (s *MainBridge) APIs() []rpc.API + func (s *MainBridge) AccountManager() *accounts.Manager + func (s *MainBridge) ChainDB() database.DBManager + func (s *MainBridge) Components() []interface{} + func (s *MainBridge) EventMux() *event.TypeMux + func (s *MainBridge) IsListening() bool + func (s *MainBridge) NetVersion() uint64 + func (s *MainBridge) ProtocolVersion() int + func (s *MainBridge) Protocols() []p2p.Protocol + func (s *MainBridge) SCProtocol() SCProtocol + func (s *MainBridge) Start(srvr p2p.Server) error + func (s *MainBridge) Stop() error + func (sc *MainBridge) SetComponents(components []interface{}) + type MainBridgeAPI struct + func (mbapi *MainBridgeAPI) ConvertServiceChainBlockHashToMainChainTxHash(scBlockHash common.Hash) common.Hash + func (mbapi *MainBridgeAPI) GetChildChainIndexingEnabled() bool + func (mbapi *MainBridgeAPI) NodeInfo() (*p2p.NodeInfo, error) + func (mbapi *MainBridgeAPI) Peers() ([]*p2p.PeerInfo, error) + type MainBridgeHandler struct + func NewMainBridgeHandler(scc *SCConfig, main *MainBridge) (*MainBridgeHandler, error) + func (mbh *MainBridgeHandler) HandleSubMsg(p BridgePeer, msg p2p.Msg) error + type MainBridgeInfo struct + BlockScore *big.Int + Config *params.ChainConfig + Genesis common.Hash + Head common.Hash + Network uint64 + type MainChainEventHandler struct + func NewMainChainEventHandler(bridge *MainBridge, handler *MainBridgeHandler) (*MainChainEventHandler, error) + func (mce *MainChainEventHandler) ConvertServiceChainBlockHashToMainChainTxHash(scBlockHash common.Hash) common.Hash + func (mce *MainChainEventHandler) GetChildChainIndexingEnabled() bool + func (mce *MainChainEventHandler) GetLastIndexedBlockNumber() uint64 + func (mce *MainChainEventHandler) HandleChainHeadEvent(block *types.Block) error + func (mce *MainChainEventHandler) HandleLogsEvent(logs []*types.Log) error + func (mce *MainChainEventHandler) HandleTxEvent(tx *types.Transaction) error + func (mce *MainChainEventHandler) HandleTxsEvent(txs []*types.Transaction) error + func (mce *MainChainEventHandler) WriteChildChainTxHash(ccBlockHash common.Hash, ccTxHash common.Hash) + func (mce *MainChainEventHandler) WriteLastIndexedBlockNumber(blockNum uint64) + type PeerSetManager interface + BridgePeerSet func() *bridgePeerSet + type RemoteBackend struct + func NewRemoteBackend(main *SubBridge, rawUrl string) (*RemoteBackend, error) + func (rb *RemoteBackend) CallContract(ctx context.Context, call klaytn.CallMsg, blockNumber *big.Int) ([]byte, error) + func (rb *RemoteBackend) ChainID(ctx context.Context) (*big.Int, error) + func (rb *RemoteBackend) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error) + func (rb *RemoteBackend) EstimateGas(ctx context.Context, call klaytn.CallMsg) (gas uint64, err error) + func (rb *RemoteBackend) FilterLogs(ctx context.Context, query klaytn.FilterQuery) ([]types.Log, error) + func (rb *RemoteBackend) PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error) + func (rb *RemoteBackend) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) + func (rb *RemoteBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error + func (rb *RemoteBackend) SubscribeFilterLogs(ctx context.Context, query klaytn.FilterQuery, ch chan<- types.Log) (klaytn.Subscription, error) + func (rb *RemoteBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error) + func (rb *RemoteBackend) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) + type RequestValueTransferEvent struct + Amount *big.Int + BlockNumber uint64 + ContractAddr common.Address + From common.Address + RequestNonce uint64 + To common.Address + TokenAddr common.Address + TokenType uint8 + type SCConfig struct + AnchoringPeriod uint64 + ChildChainIndexing bool + DataDir string + DatabaseHandles int + EnabledMainBridge bool + EnabledSubBridge bool + LevelDBCacheSize int + MainBridgePort string + MainChainAccountAddr *common.Address + MainChainURL string + MaxPeer int + Name string + NetworkId uint64 + ParentChainID uint64 + SentChainTxsLimit uint64 + ServiceChainAccountAddr *common.Address + ServiceChainConsensus string + SkipBcVersionCheck bool + SubBridgePort string + TrieBlockInterval uint + TrieCacheSize int + TrieTimeout time.Duration + VTRecovery bool + VTRecoveryInterval uint64 + func (c *SCConfig) ChainKey() *ecdsa.PrivateKey + func (c *SCConfig) MainBridges() []*discover.Node + func (c *SCConfig) NodeKey() *ecdsa.PrivateKey + func (c *SCConfig) NodeName() string + func (c *SCConfig) ResolvePath(path string) string + func (s *SCConfig) UnmarshalTOML(unmarshal func(interface{}) error) error + func (s SCConfig) MarshalTOML() (interface{}, error) + type SCProtocol struct + Lengths []uint64 + Name string + Versions []uint + type SubBridge struct + APIBackend *SubBridgeAPI + func NewSubBridge(ctx *node.ServiceContext, config *SCConfig) (*SubBridge, error) + func (pm *SubBridge) NodeInfo() *SubBridgeInfo + func (s *SubBridge) APIs() []rpc.API + func (s *SubBridge) AccountManager() *accounts.Manager + func (s *SubBridge) AddressManager() *AddressManager + func (s *SubBridge) ChainDB() database.DBManager + func (s *SubBridge) Components() []interface{} + func (s *SubBridge) EventMux() *event.TypeMux + func (s *SubBridge) IsListening() bool + func (s *SubBridge) NetVersion() uint64 + func (s *SubBridge) ProtocolVersion() int + func (s *SubBridge) Protocols() []p2p.Protocol + func (s *SubBridge) SCProtocol() SCProtocol + func (s *SubBridge) Start(srvr p2p.Server) error + func (s *SubBridge) Stop() error + func (sb *SubBridge) BridgePeerSet() *bridgePeerSet + func (sb *SubBridge) GetAnchoringTx() bool + func (sb *SubBridge) GetBridgeTxPool() *BridgeTxPool + func (sb *SubBridge) SetAnchoringTx(flag bool) bool + func (sc *SubBridge) SetComponents(components []interface{}) + type SubBridgeAPI struct + func (sbapi *SubBridgeAPI) AddPeer(url string) (bool, error) + func (sbapi *SubBridgeAPI) Anchoring(flag bool) bool + func (sbapi *SubBridgeAPI) ConvertRequestTxHashToHandleTxHash(hash common.Hash) common.Hash + func (sbapi *SubBridgeAPI) ConvertServiceChainBlockHashToMainChainTxHash(scBlockHash common.Hash) common.Hash + func (sbapi *SubBridgeAPI) DeployBridge() ([]common.Address, error) + func (sbapi *SubBridgeAPI) DeregisterBridge(cBridgeAddr common.Address, pBridgeAddr common.Address) error + func (sbapi *SubBridgeAPI) DeregisterToken(cBridgeAddr, pBridgeAddr, cTokenAddr, pTokenAddr common.Address) error + func (sbapi *SubBridgeAPI) GetAnchoring() bool + func (sbapi *SubBridgeAPI) GetAnchoringPeriod() uint64 + func (sbapi *SubBridgeAPI) GetBridgeInformation(bridgeAddr common.Address) (map[string]interface{}, error) + func (sbapi *SubBridgeAPI) GetLatestAnchoredBlockNumber() uint64 + func (sbapi *SubBridgeAPI) GetMainChainAccountAddr() string + func (sbapi *SubBridgeAPI) GetMainChainAccountNonce() uint64 + func (sbapi *SubBridgeAPI) GetReceiptFromParentChain(blockHash common.Hash) *types.Receipt + func (sbapi *SubBridgeAPI) GetSentChainTxsLimit() uint64 + func (sbapi *SubBridgeAPI) GetServiceChainAccountAddr() string + func (sbapi *SubBridgeAPI) GetServiceChainAccountNonce() uint64 + func (sbapi *SubBridgeAPI) ListBridge() []*BridgeJournal + func (sbapi *SubBridgeAPI) NodeInfo() (*p2p.NodeInfo, error) + func (sbapi *SubBridgeAPI) Peers() ([]*p2p.PeerInfo, error) + func (sbapi *SubBridgeAPI) RegisterBridge(cBridgeAddr common.Address, pBridgeAddr common.Address) error + func (sbapi *SubBridgeAPI) RegisterToken(cBridgeAddr, pBridgeAddr, cTokenAddr, pTokenAddr common.Address) error + func (sbapi *SubBridgeAPI) RemovePeer(url string) (bool, error) + func (sbapi *SubBridgeAPI) SubscribeBridge(cBridgeAddr, pBridgeAddr common.Address) error + func (sbapi *SubBridgeAPI) TxPending() map[common.Address]types.Transactions + func (sbapi *SubBridgeAPI) TxPendingCount() int + func (sbapi *SubBridgeAPI) UnsubscribeBridge(cBridgeAddr, pBridgeAddr common.Address) error + type SubBridgeHandler struct + MainChainAccountAddr *common.Address + ServiceChainAccountAddr *common.Address + func NewSubBridgeHandler(scc *SCConfig, main *SubBridge) (*SubBridgeHandler, error) + func (sbh *SubBridgeHandler) GetAnchoringPeriod() uint64 + func (sbh *SubBridgeHandler) GetLatestAnchoredBlockNumber() uint64 + func (sbh *SubBridgeHandler) GetMainChainAccountAddr() *common.Address + func (sbh *SubBridgeHandler) GetNextAnchoringBlockNumber() uint64 + func (sbh *SubBridgeHandler) GetReceiptFromParentChain(blockHash common.Hash) *types.Receipt + func (sbh *SubBridgeHandler) GetSentChainTxsLimit() uint64 + func (sbh *SubBridgeHandler) GetServiceChainAccountAddr() *common.Address + func (sbh *SubBridgeHandler) HandleMainMsg(p BridgePeer, msg p2p.Msg) error + func (sbh *SubBridgeHandler) LocalChainHeadEvent(block *types.Block) + func (sbh *SubBridgeHandler) LockMainChainAccount() + func (sbh *SubBridgeHandler) RegisterNewPeer(p BridgePeer) error + func (sbh *SubBridgeHandler) UnLockMainChainAccount() + func (sbh *SubBridgeHandler) UpdateLastestAnchoredBlockNumber(newLastestAnchoredBN uint64) + func (sbh *SubBridgeHandler) WriteAnchoredBlockNumber(blockNum uint64) + func (sbh *SubBridgeHandler) WriteReceiptFromParentChain(blockHash common.Hash, receipt *types.Receipt) + func (scpm *SubBridgeHandler) SyncNonceAndGasPrice() + type SubBridgeInfo struct + ChainID *big.Int + Config *params.ChainConfig + Genesis common.Hash + Head common.Hash + Network uint64