Rise的自留地

记录生活中的点滴,分享编程技术和游戏开发经验。

0%

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
--QPTreasureDB为需要清除日志的数据库名称
USE [master]
GO
ALTER DATABASE QPTreasureDB SET RECOVERY SIMPLE WITH NO_WAIT
GO
ALTER DATABASE QPTreasureDB SET RECOVERY SIMPLE   --简单模式
GO
USE QPTreasureDB 
GO
DBCC SHRINKFILE (N'QPTreasureDB_Log' , 11, TRUNCATEONLY) --设置压缩后的日志大小为11M,可以自行指定
GO

USE [master]
GO
ALTER DATABASE QPTreasureDB SET RECOVERY FULL WITH NO_WAIT
GO
ALTER DATABASE QPTreasureDB SET RECOVERY FULL  --还原为完全模式
GO

由于有些规定,要保密个人信息,只能通过这种方法来把个人信息给过滤掉。

修改OLD_EMAIL为要替换的旧邮箱,NEW_NAMENEW_EMAIL为新的个人名字和邮箱,修改完成后强制更新到服务器。

打开项目文件夹下 node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

查找

1
if (!version.startsWith('iOS') && !version.startsWith('tvOS'))

修改为

1
if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS'))

查找

1
simulator.isAvailable !== 'YES'

修改为

1
if (simulator.isAvailable !== true)

原方法地址 https://github.com/facebook/react-native/issues/21498#issuecomment-476621627

1. 名词解释

  1. 创世节点(BIOS) 用于创建初始区块,加载基础合约,供其它节点同步连接。
  2. 矿工节点(BP) 主要用于生产同步区块,计算合约产生的费用归矿工账号所有。
  3. 查询节点 不产生区块,同步区块信息,提供区块信息查询功能。
  4. 私钥 用来进行签名操作,私钥可以生成唯一对应公钥。
  5. 公钥 用来对私钥的签名进行验证。
  6. 钱包 生成和保存私钥的地方,当需要进行签名操作时,会从钱包读取私钥列表,进行签名。
  7. 带宽 带宽分为cpu带宽和net带宽两种,每次执行合约都会消耗一定的带宽(从账号中扣取)。
  8. 合约 一段在链上可执行代码,绑定在账号上,每个账号只能绑定一份合约。
  9. 账号 存储用户信息,包括余额、带宽、合约(如果有)等。
  10. 总票数 总票数=总发行的货币数量。
  11. 投票 投票者抵押货币投票给矿工,当矿工投票数大于总票数的15%时创世节点停止产生区块,转由矿工生产区块。 所谓的矿工节点与查询节点,只是为了区分是否生产区块的不同配置。

2. 节点代码编译、程序安装

注意:后面编译依赖GIT,所以务必保证代码根目录的.git完整,以及系统安装有git。 以下以ubuntu系统为例,其它系统步骤类似。

最近老被一些人问些问题,其实都看过,只是印象不深刻,或者觉得不那么重要,就没花更多的精力去研究。

工作上的东西,也只是写在onenote或者公司的文档上,写完也没记,反正用时可以看文档。

  • 阿里云镜像
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# 替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

# 应用生效
brew update -v

# 替换homebrew-bottles(最好保存到配置文件):
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles
  • 中科大镜像
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
brew update -v
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles

  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
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112

const TX_TYPE_IN = 1;

const TX_TYPE_OUT = 2;



export const CreateUtxos = async (address: string, data: any) => {

    let mapData = new Map();

    let temp = new Map();

    for (const iter of data) {

        mapData.set(iter.hash, iter);

        // console.log(iter.hash);

        let type = TX_TYPE_IN;

        for (const input of iter.inputs) {

            if (input.coin.coinbase) continue;

            if (address == input.coin.address) {

                type = TX_TYPE_OUT;

            }

        }

        let out = -1;

        let balance = 0;

        for (const output of iter.outputs) {

            out++;

            if (address == output.address) {

                balance = output.value;

                break;

            }

        }

        temp.set(iter.hash, { type, out, balance, spentTxid: null, spentHeight: 0 });

    }



    for (const [key, value] of mapData) {

        for (const input of value.inputs) {

            if (input.coinbase) continue;

            if (temp.has(input.prevout.hash)) {

                const pre = temp.get(input.prevout.hash);

                const local = temp.get(key);

                if (pre.spentHeight <= 0 && (pre.type != local.type || local.type == TX_TYPE_OUT)) {

                    pre.spentTxid = value.hash;

                    pre.spentHeight = value.height;

                }

            }

        }

    }

    let balance = 0;

    let unspentList: Array<any> = [];

    for (const [key, value] of temp) {

        if (value.spentHeight === 0) {

            balance += value.balance;

            // console.info(key, value.out);

            unspentList.push(value);

        } /*else {

            temp.delete(key);

        }*/

    }



    // return {balance, unspentList: Array.from(temp.values())}

    return { balance, unspentList };

}

使用阿里源

新建一个init.gradle 文件到$USER_HOME/.gradle/目录下,这们就省的翻墙了。

init.gradle 文件内容如下:

 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

allprojects {

    repositories {

        maven {

            url 'https://maven.aliyun.com/repository/public/'

        }

        maven {

            url 'https://maven.aliyun.com/repository/google/'

        }



        all { ArtifactRepository repo ->

            if (repo instanceof MavenArtifactRepository) {

                def url = repo.url.toString()



                if (url.startsWith('https://repo.maven.apache.org/maven2/') || url.startsWith('https://repo.maven.org/maven2') 

                    || url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')

                    || url.startsWith('https://maven.google.com/') || url.startsWith('https://dl.google.com/dl/android/maven2/')) {

                    //project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."

                    remove repo

                }

            }

        }

    }



    buildscript {

        repositories {

            maven{ url 'https://maven.aliyun.com/repository/public/'}

            maven{ url 'https://maven.aliyun.com/repository/google/'}



            all { ArtifactRepository repo ->

                if (repo instanceof MavenArtifactRepository) {

                    def url = repo.url.toString()

                    if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')

                         || url.startsWith('https://dl.google.com/dl/android/maven2/')) {

                        //project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."

                        remove repo

                    }

                }

            }

        }

    }



}

全局翻墙代理配置

同样新建一个gradle.properties 文件到$USER_HOME/.gradle/目录下,如果放在项目目录下,则只对当前项目生效。

  • 转账的时候需要手动寻找每一笔未花费记录实在太费时。

  • 比特币转账需要提取或合并所有未花费的交易中的比特币,才能实现交易。

 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
47
48
49
50
51
52
53
54
55
56
57
58
import * as bitcoin from 'bitcoinjs-lib';
import fetch, { Response } from 'node-fetch';

const quantitySat = 0.0001 * 1e8;
const feeSat = 0.0001 * 1e8;

(async () => {
  try {
    let NETWORK = bitcoin.networks.testnet;
    const keyPair = bitcoin.ECPair.fromWIF(from_pvtkey, NETWORK);
    const p2pkh = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey, network: NETWORK });
    let from = p2pkh.address;
    const utxoResponse: Response = await fetch(`https://api.blockcypher.com/v1/btc/test3/addrs/${from}`);
    const json = await utxoResponse.json();
    console.log(json);
    let balance = json.balance;
    let unspentList: Array<any> = [];
    // 过滤掉已经被花费了的交易和未确认的交易,以及自己不在接收列表的交易
    const txrefs = json.txrefs;
    const unconfirmed_txrefs = json.unconfirmed_txrefs;
    if (unconfirmed_txrefs && unconfirmed_txrefs.length > 0) {
      // 要把未确认的余额给去掉
      balance += json.unconfirmed_balance;
      unspentList = unspentList.concat(unconfirmed_txrefs.filter((item: any) => !item.spent_by && item.tx_output_n !== -1));
    }
    if (txrefs.length > 0) {
      unspentList = unspentList.concat(txrefs.filter((item: any) => !item.spent_by && item.tx_output_n !== -1));
    }

    // 构建交易对象
    let txb = new bitcoin.TransactionBuilder(NETWORK);

    // 批量插入未花费交易
    unspentList.forEach((item: any) => txb.addInput(item.tx_hash, item.tx_output_n));

    // 转出账户
    txb.addOutput(to, quantitySat);

    // 预留手续费
    txb.addOutput(from, balance - quantitySat - feeSat);

    // 批量签名,根据索引即可
    unspentList.forEach((item: any, index: any) => { txb.sign(index, keyPair) });

    // 序列化交易
    let tx = txb.build();
    console.log(tx.getHash().toString('hex'));

    // 在一个测试链的节点把交易广布出去
    const result = await fetch('https://api.blockcypher.com/v1/btc/test3/txs/push',{
      method:'post',
      headers:{'Content-Type':'application/json'},
      body:JSON.stringify({tx: tx.toHex()})
    });
  } catch (error) {
    console.error(error);
  }
})();