1 | <?php |
||
16 | class Bitcoin |
||
17 | { |
||
18 | /** |
||
19 | * @var NetworkInterface |
||
20 | */ |
||
21 | private static $network; |
||
22 | |||
23 | /** |
||
24 | * @var EcAdapterInterface |
||
25 | */ |
||
26 | private static $adapter; |
||
27 | |||
28 | /** |
||
29 | * @var ParamsInterface |
||
30 | */ |
||
31 | private static $params; |
||
32 | |||
33 | /** |
||
34 | * @return Math |
||
35 | */ |
||
36 | 2928 | public static function getMath() |
|
40 | |||
41 | /** |
||
42 | * Load the generator to be used throughout |
||
43 | */ |
||
44 | 4 | public static function getGenerator() |
|
48 | |||
49 | /** |
||
50 | * @param Math $math |
||
51 | * @param GeneratorPoint $generator |
||
52 | * @return EcAdapterInterface |
||
53 | */ |
||
54 | 296 | public static function getEcAdapter(Math $math = null, GeneratorPoint $generator = null) |
|
55 | { |
||
56 | 296 | if (null === self::$adapter) { |
|
57 | self::$adapter = EcAdapterFactory::getAdapter( |
||
58 | ($math ?: self::getMath()), |
||
59 | ($generator ?: self::getGenerator()) |
||
60 | ); |
||
61 | } |
||
62 | |||
63 | 296 | return self::$adapter; |
|
64 | } |
||
65 | |||
66 | /** |
||
67 | * @param ParamsInterface $params |
||
68 | */ |
||
69 | public static function setParams(ParamsInterface $params) |
||
70 | { |
||
71 | self::$params = $params; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * @return ParamsInterface |
||
76 | */ |
||
77 | public static function getParams() |
||
78 | { |
||
79 | if (null === self::$params) { |
||
80 | self::$params = self::getDefaultParams(); |
||
81 | } |
||
82 | |||
83 | return self::$params; |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * @param Math|null $math |
||
88 | * @return ParamsInterface |
||
89 | */ |
||
90 | public static function getDefaultParams(Math $math = null) |
||
91 | { |
||
92 | return new Params($math ?: self::getMath()); |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @param EcAdapterInterface $adapter |
||
97 | */ |
||
98 | public static function setAdapter(EcAdapterInterface $adapter) |
||
102 | |||
103 | /** |
||
104 | * @param NetworkInterface $network |
||
105 | */ |
||
106 | 2 | public static function setNetwork(NetworkInterface $network) |
|
110 | |||
111 | /** |
||
112 | * @return Network |
||
113 | */ |
||
114 | 54 | public static function getNetwork() |
|
115 | { |
||
116 | 54 | if (null === self::$network) { |
|
117 | self::$network = self::getDefaultNetwork(); |
||
118 | } |
||
119 | |||
120 | 54 | return self::$network; |
|
121 | } |
||
122 | |||
123 | /** |
||
124 | * @return NetworkInterface |
||
125 | */ |
||
126 | 4 | public static function getDefaultNetwork() |
|
130 | } |
||
131 |