Browse Source

Merge pull request #7069 from bitromortac/2102-mpp-split-params

mpp_split: optimize split parameters
patch-4
ThomasV 4 years ago
committed by GitHub
parent
commit
5dc7b5bffe
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      electrum/mpp_split.py
  2. 7
      electrum/tests/test_mpp_split.py

6
electrum/mpp_split.py

@ -12,9 +12,9 @@ REDISTRIBUTION_FRACTION = 10
SPLIT_FRACTION = 10 SPLIT_FRACTION = 10
# these parameters affect the computational work in the probabilistic algorithm # these parameters affect the computational work in the probabilistic algorithm
STARTING_CONFIGS = 30 STARTING_CONFIGS = 50
CANDIDATES_PER_LEVEL = 20 CANDIDATES_PER_LEVEL = 10
REDISTRIBUTE = 5 REDISTRIBUTE = 10
def unique_hierarchy(hierarchy: Dict[int, List[Dict[bytes, int]]]) -> Dict[int, List[Dict[bytes, int]]]: def unique_hierarchy(hierarchy: Dict[int, List[Dict[bytes, int]]]) -> Dict[int, List[Dict[bytes, int]]]:

7
electrum/tests/test_mpp_split.py

@ -13,8 +13,6 @@ class TestMppSplit(ElectrumTestCase):
super().setUp() super().setUp()
# to make tests reproducible: # to make tests reproducible:
random.seed(0) random.seed(0)
# undo side effect
mpp_split.PART_PENALTY = PART_PENALTY
self.channels_with_funds = { self.channels_with_funds = {
0: 1_000_000_000, 0: 1_000_000_000,
1: 500_000_000, 1: 500_000_000,
@ -22,6 +20,11 @@ class TestMppSplit(ElectrumTestCase):
3: 101_000_000, 3: 101_000_000,
} }
def tearDown(self):
super().tearDown()
# undo side effect
mpp_split.PART_PENALTY = PART_PENALTY
def test_suggest_splits(self): def test_suggest_splits(self):
with self.subTest(msg="do a payment with the maximal amount spendable over a single channel"): with self.subTest(msg="do a payment with the maximal amount spendable over a single channel"):
splits = mpp_split.suggest_splits(1_000_000_000, self.channels_with_funds, exclude_single_parts=True) splits = mpp_split.suggest_splits(1_000_000_000, self.channels_with_funds, exclude_single_parts=True)

Loading…
Cancel
Save