-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathtypes.go
46 lines (38 loc) · 1.33 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2023 The AthanorLabs/atomic-swap Authors
// SPDX-License-Identifier: LGPL-3.0-only
package net
import (
libp2pnetwork "github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/athanorlabs/atomic-swap/common"
"github.com/athanorlabs/atomic-swap/common/types"
"github.com/athanorlabs/atomic-swap/net/message"
)
type SwapState = common.SwapStateNet //nolint:revive
//nolint:revive
type (
MessageType = byte
Message = common.Message
QueryResponse = message.QueryResponse
SendKeysMessage = message.SendKeysMessage
RelayClaimRequest = message.RelayClaimRequest
RelayClaimResponse = message.RelayClaimResponse
)
// MakerHandler handles swap initiation messages and offer queries. It is
// implemented by *xmrmaker.Instance.
type MakerHandler interface {
GetOffers() []*types.Offer
HandleInitiateMessage(peerID peer.ID, msg *SendKeysMessage) (SwapState, error)
}
// RelayHandler handles relay claim requests. It is implemented by
// *backend.backend.
type RelayHandler interface {
GetRelayerAddressHash() (types.Hash, error)
HandleRelayClaimRequest(remotePeer peer.ID, msg *RelayClaimRequest) (*RelayClaimResponse, error)
HasOngoingSwapAsTaker(remotePeer peer.ID) error
}
type swap struct {
swapState SwapState
stream libp2pnetwork.Stream
streamClosed bool
}