浅谈随机
随机是一个十分有意思的问题。 随机是一种选择方式 生活中最常见的例子就有这些: 抽签 抽奖 抛硬币 随机是一种隐藏方式 同样拿抽奖为例,将少量的中奖者隐藏在抽奖参与者中。从概率论的角度上看就是将分子隐藏分母当中。 ...
随机是一个十分有意思的问题。 随机是一种选择方式 生活中最常见的例子就有这些: 抽签 抽奖 抛硬币 随机是一种隐藏方式 同样拿抽奖为例,将少量的中奖者隐藏在抽奖参与者中。从概率论的角度上看就是将分子隐藏分母当中。 ...
原因 陷入困境的原因从以下几个方面展开。 基础 不知道自己不知道unknown unknown 技能进入高原与瓶颈期,技能达不到解决问题的要求 缺少信息 陷入低水平的重复 自我限制 陷入固定的框架之中 陷入固定的观念之中 不能主动寻求帮助 只是重复而不是迭代 目标 目标不具体明确 目标太大,没有通过分解降低难度 目标太难 路径与方法 不知道如何开始与入手 缺少明确的路径 路径与方法错误如先后顺序出错 没有从最简单与最基础的开始 不要死磕,停下来,休息一下,改变一下 等待不存在的条件与环境如等完全只需要照抄的教程 能量 缺少动机 拖延症 心理负担重,不能轻装上阵 韧性不足,如前期失败几次后,直接放弃 专注不够,导致不能深度思考与工作 状态不好 示例 假设遇到一个leetcode题目不会解,可以参考以下步骤来解决: ...
简介 以太坊交易池有以下功能: 缓存交易 清理交易 实现交易gasPrice竞价功能 配合出块,提供打包交易 交易查询 配置 配置描述 geth中用数据结构TxPoolConfig描述交易池配置,具体如下: ...
Programming “All problems in computer science can be solved by another level of indirection.” — David Wheeler “But that usually will create another problem.” — David Wheeler “Simplicity is prerequisite for reliability.” — Edsger Dijkstra ...
前言 优秀的技术人员与技术管理人员会一直紧缺。一个好的技术管理人员应该有自己的管理及领导指导原则。(Ps:最近在读《原则》这本书,深受其影响,虽然已经有很多人在推荐,这里再推荐一下,这本书真的值得一读。) 结合个人的工作经历与思考,提出自己对研发管理与技术领导的一些原则性思考。 ...
没有什么是不可改变的。 Facebook有22亿用户。 MySpace曾经是世界之王。现在人们都已经遗忘了。 QQ还是让位微信,活跃度下降,用户时长下降。 ...
说明 代码基于go-ethereum,版本v1.8.10。 RPC代码入口 SendTransaction 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 // SendTransaction will create a transaction from the given arguments and // tries to sign it with the key associated with args.To. If the given passwd isn't // able to decrypt the key it fails. func (s *PrivateAccountAPI) SendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error) { if args.Nonce == nil { // Hold the addresse's mutex around signing to prevent concurrent assignment of // the same nonce to multiple accounts. s.nonceLock.LockAddr(args.From) defer s.nonceLock.UnlockAddr(args.From) } signed, err := s.signTransaction(ctx, args, passwd) if err != nil { return common.Hash{}, err } return submitTransaction(ctx, s.b, signed) } SendTxArgs的数据结构如下: ...
背景 苏格拉底说过:我唯一知道的就是我一无所知。 我不知道 我不知道自己 我不知道过去 我不知道现在 我不知道未来 我不知道别人 我不知道变化 我不知道系统 我更不知道所有 我知道我不知道,所以我会犯错,我会坦然面对错误。 ...
推荐 Ethereum Virtual Machine Opcodes Arithmetic Operations 1 2 3 4 5 6 7 8 9 10 11 12 ADD //Add the top two stack items MUL //Multiply the top two stack items SUB //Subtract the top two stack items DIV //Integer division SDIV //Signed integer division MOD //Modulo (remainder) operation SMOD //Signed modulo operation ADDMOD //Addition modulo any number MULMOD //Multiplication modulo any number EXP //Exponential operation SIGNEXTEND //Extend the length of a two’s complement signed integer SHA3 //Compute the Keccak-256 hash of a block of memory Stack Operations 1 2 3 4 5 6 7 8 9 10 POP //Remove the top item from the stack MLOAD //Load a word from memory MSTORE //Save a word to memory MSTORE8 //Save a byte to memory SLOAD //Load a word from storage SSTORE //Save a word to storage MSIZE //Get the size of the active memory in bytes PUSHx //Place x-byte item on the stack, where x can be any integer from 1 to 32 (full word) inclusive DUPx //Duplicate the x-th stack item, where x can be any integer from 1 to 16 inclusive SWAPx //Exchange 1st and (x+1)-th stack items, where x can by any integer from 1 to 16 inclusive Process Flow Operations 1 2 3 4 5 STOP //Halts execution JUMP //Set the program counter to any value JUMPI //Conditionally alter the program counter PC //Get the value of the program counter (prior to the increment corresponding to this instruction) JUMPDEST //Mark a valid destination for jumps System Operations 1 2 3 4 5 6 7 8 9 10 LOGx //Append a log record with +x+ topics, where +x+ is any integer from 0 to 4 inclusive CREATE //Create a new account with associated code CALL //Message-call into another account, i.e. run another account's code CALLCODE //Message-call into this account with an another account’s code RETURN //Halt execution and return output data DELEGATECALL //Message-call into this account with an alternative account’s code, but persisting the current values for sender and value STATICCALL //Static message-call into an account REVERT //Halt execution reverting state changes but returning data and remaining gas INVALID //The designated invalid instruction SELFDESTRUCT //Halt execution and register account for deletion Logic Operations 1 2 3 4 5 6 7 8 9 10 11 LT //Less-than comparison GT //Greater-than comparison SLT //Signed less-than comparison SGT //Signed greater-than comparison EQ //Equality comparison ISZERO //Simple not operator AND //Bitwise AND operation OR //Bitwise OR operation XOR //Bitwise XOR operation NOT //Bitwise NOT operation BYTE //Retrieve a single byte from a full-width 256 bit word Environmental Operations 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 GAS //Get the amount of available gas (after the reduction for this instruction) ADDRESS //Get the address of the currently executing account BALANCE //Get the account balance of any given account ORIGIN //Get the address of the EOA that initiated this EVM execution CALLER //Get the address of the caller immediately responsible for this execution CALLVALUE //Get the ether amount deposited by the caller responsible for this execution CALLDATALOAD //Get the input data sent by the caller responsible for this execution CALLDATASIZE //Get the size of the input data CALLDATACOPY //Copy the input data to memory CODESIZE //Get the size of code running in the current environment CODECOPY //Copy the code running in the current environment to memory GASPRICE //Get the gas price specified by the originating transaction EXTCODESIZE //Get the size of any account's code EXTCODECOPY //Copy any account’s code to memory RETURNDATASIZE //Get the size of the output data from the previous call in the current environment RETURNDATACOPY //Copy of data output from the previous call to memory Block Operations 1 2 3 4 5 6 BLOCKHASH //Get the hash of one of the 256 most recently completed blocks COINBASE //Get the block’s beneficiary address for the block reward TIMESTAMP //Get the block’s timestamp NUMBER //Get the block’s number DIFFICULTY //Get the block’s difficulty GASLIMIT //Get the block’s gas limit
相信很多人都知道,BFT(Byzantine fault tolerance)要求诚实节点数量大于总节点的三分之二。 为什么会有这个要求? 多数派原则 多数派原则在分布式系统很常见,即确保网络分化情况下的决议唯一。其原理是,假如节点总数是2f+1,那么一项决议得到多于f个节点赞成则获得通过。leader选举中,网络分化下,只有具有多数派节点的部分才可能选出leader。多数派还可以用于副本管理,根据实际情况调整写副本数和读副本数,在可靠性和性能之间取得平衡。 在分布式系统,无论paxos,还是raft,以投票来达成共识,在整个达成共识的过程中都遵守多数派原则。 ...