This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as net from 'net'; | |
// TCP 连接类,仅处理发送和接收 | |
export class TcpConnection { | |
// Socket 由外部传入 | |
private socket: net.Socket; | |
// 存储接收到的数据 | |
private buffer: Buffer; | |
// 读取数据限制, 0 表示无限制 | |
private readLimit: number; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// jsonrpc.hpp | |
// ~~~~~~~~~~~ | |
// | |
// Copyright (c) 2023 Jack (jack dot wgm at gmail dot com) | |
// | |
// Distributed under the Boost Software License, Version 1.0. (See accompanying | |
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 需要安装以下依赖: | |
* yarn add ethers bitcoinjs-lib ecpair tiny-secp256k1 bs58 | |
* yarn add @types/bitcoinjs-lib @types/ecpair @types/tiny-secp256k1 @types/bs58 | |
* yarn add ts-node typescript | |
*/ | |
import { ethers } from 'ethers'; | |
import { ECPairFactory } from 'ecpair'; | |
import bitcoin from 'bitcoinjs-lib'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <fstream> | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include "async_simple/coro/Lazy.h" | |
#include "async_simple/coro/SyncAwait.h" | |
// asio_coro_util.hpp 在 demo_example 下, 这里仅仅为了调用 AsioCallbackAwaiter 这个简单的 Awaiter 而已. | |
#include "asio_coro_util.hpp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <coroutine> | |
#include <functional> | |
#include <type_traits> | |
#if defined(DEBUG) || defined(_DEBUG) | |
#include <unordered_set> | |
std::unordered_set<void*> global_crors; | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ssl_stream.hpp | |
// ~~~~~~~~~~~~~~ | |
// | |
// Copyright (c) 2023 Jack (jack dot wgm at gmail dot com) | |
// | |
// Distributed under the Boost Software License, Version 1.0. (See accompanying | |
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void print_data_len(const std::vector<uint8_t>& data, uint16_t target_len = 0x7FFF) | |
{ | |
if (data.size() < 4) { | |
std::cerr << "数据长度小于4,无法转换为 uint16_t。" << std::endl; | |
return; | |
} | |
std::cout << "print len: " << data.size() << "\n"; | |
uint16_t p1 = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Copyright (C) 2019 Jack. | |
// | |
// Author: jack | |
// Email: jack.wgm at gmail dot com | |
// | |
#pragma once | |
#include <version> | |
#include <codecvt> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// yield_cancellation_slot_bind.hpp | |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
// | |
// Copyright (c) 2019 Jack (jack dot wgm at gmail dot com) | |
// | |
// Distributed under the Boost Software License, Version 1.0. (See accompanying | |
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// async_connect.hpp | |
// ~~~~~~~~~~~~~~~~~ | |
// | |
// Copyright (c) 2019 Jack (jack dot wgm at gmail dot com) | |
// | |
// Distributed under the Boost Software License, Version 1.0. (See accompanying | |
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
// |
NewerOlder