http://cryptoicons.co/
https://github.com/mirgj/cryptocurrency-icons-font
https://github.com/rizalrenaldi/coinicon
您正在查看: 2019年5月
ScatterDesktop Backup
BackService 调用 saveFile
export default class BackupService {
static async setBackupStrategy(strategy){
const scatter = store.state.scatter.clone();
scatter.settings.autoBackup = strategy;
return store.dispatch(Actions.SET_SCATTER, scatter);
}
static async createBackup(){
const location = getFolderLocation();
if(! location) return false;
await saveFile(location[0]);
}
static async setBackupLocation(){
const location = getFolderLocation();
if(!location) return false;
const scatter = store.state.scatter.clone();
scatter.settings.backupLocation = location[0];
return store.dispatch(Actions.SET_SCATTER, scatter);
}
static async createAutoBackup(){
if(!store.state.scatter || !store.state.scatter.settings) return;
const strategy = store.state.scatter.settings.autoBackup;
if(!strategy || !strategy.length || strategy === BACKUP_STRATEGIES.MANUAL) return;
const backupLocation = store.state.scatter.settings.backupLocation;
if(!backupLocation || !backupLocation.length) return false;
await saveFile(backupLocation);
}
}
写入备份文件
const saveFile = (filepath) => {
return new Promise(resolve => {
const scatter = getLatestScatter();
const date = new Date();
const month = date.getUTCMonth();
const year = date.getUTCFullYear();
const salt = StorageService.getSalt();
const file = scatter + '|SLT|' + salt;
const name = `${filepath}/scatter__${store.state.scatter.hash.substr(0,4)}-${store.state.scatter.hash.slice(-4)}__${store.state.scatter.meta.version}__${month}-${year}.json`;
try {
fs.writeFileSync(name, file, 'utf-8');
resolve(true);
}
catch(e) {
console.error('Error saving file', e);
resolve(false);
}
})
};
备份文件的内容
const scatter = getLatestScatter();
const salt = StorageService.getSalt();
const file = scatter + '|SLT|' + salt;
const getLatestScatter = () => StorageService.getScatter();
StorageService
export default class StorageService {
constructor(){}
static async setScatter(scatter){
return new Promise(async resolve => {
clearSaveTimeouts();
saveResolvers.push(resolve);
safeSetScatter(scatter, resolve);
})
};
static getScatter() {
return scatterStorage().get('scatter');
}
actions
[Actions.SET_SCATTER]:async ({commit, state}, scatter) => {
return new Promise(async resolve => {
const process = Process.savingData();
const seed = await ipcAsync('seed');
const savable = AES.encrypt(scatter.savable(seed), seed);
StorageService.setLocalScatter(savable);
process.updateProgress(50);
StorageService.setScatter(savable).then(() => {
BackupService.createAutoBackup()
});
commit(Actions.SET_SCATTER, scatter);
resolve(scatter);
process.updateProgress(100);
})
},
其中的
const seed = await ipcAsync('seed');
是从
[Actions.SET_SEED]:({commit}, password) => {
return new Promise(async (resolve, reject) => {
const [mnemonic, seed] = await PasswordService.seedPassword(password, true);
resolve(mnemonic);
})
},
static async seedPassword(password, setToState = true){
return new Promise(async (resolve, reject) => {
try {
let seed, mnemonic;
if(password.split(' ').length >= 12) {
seed = await Mnemonic.mnemonicToSeed(password);
mnemonic = password;
} else {
const [m, s] = await Mnemonic.generateMnemonic(password);
seed = s;
mnemonic = m;
}
if(setToState) ipcFaF('seeding', seed);
resolve([mnemonic, seed]);
} catch(e){
resolve([null, null]);
}
})
}
Scatter
https://sourcegraph.com/github.com/GetScatter/ScatterDesktop/-/blob/src/models/Scatter.js#L76:1
savable(seed){
this.keychain.keypairs.map(keypair => keypair.encrypt(seed));
const clone = this.clone();
clone.keychain.identities.map(id => id.encrypt(seed));
// Keychain is always stored encrypted.
clone.encrypt(seed);
return clone;
}
Keychain
static fromJson(json){
let p = Object.assign(this.placeholder(), json);
if(json.hasOwnProperty('keypairs')) p.keypairs = json.keypairs.map(x => Keypair.fromJson(x));
if(json.hasOwnProperty('accounts')) p.accounts = json.accounts.map(x => Account.fromJson(x));
if(json.hasOwnProperty('identities')) p.identities = json.identities.map(x => Identity.fromJson(x));
if(json.hasOwnProperty('permissions')) p.permissions = json.permissions.map(x => Permission.fromJson(x));
if(json.hasOwnProperty('apps')) p.apps = json.apps.map(x => AuthorizedApp.fromJson(x));
return p;
}
nodeos 输出log方式
bool configure_logging( const logging_config& cfg )
{
try {
static bool reg_console_appender = appender::register_appender<console_appender>( "console" );
static bool reg_gelf_appender = appender::register_appender<gelf_appender>( "gelf" );
get_logger_map().clear();
get_appender_map().clear();
支持输出到 console 和 gelf 两种方式
namespace fc
{
// Log appender that sends log messages in JSON format over UDP
// https://www.graylog2.org/resources/gelf/specification
class gelf_appender final : public appender
{
public:
struct config
{
string endpoint = "127.0.0.1:12201";
string host = "fc"; // the name of the host, source or application that sent this message (just passed through to GELF server)
};
EOS 代币命名规则
constexpr explicit symbol_code( std::string_view str )
:value(0)
{
if( str.size() > 7 ) {
eosio::check( false, "string is too long to be a valid symbol_code" );
}
for( auto itr = str.rbegin(); itr != str.rend(); ++itr ) {
if( *itr < 'A' || *itr > 'Z') {
eosio::check( false, "only uppercase letters allowed in symbol_code string" );
}
value <<= 8;
value |= *itr;
}
}
格式
<=7位,A-Z
最新回复
fzd: 请问这个解决了吗
StarkWare explained: layer 2 solution provider of dYdX and iMMUTABLE R11; BitKeep News: [...]Layer 2: https://...
一文读懂 StarkWare:dYdX 和 Immutable 背后的 L2 方案 R11; BitKeep 博客: [...]Layer 2:Comparing Laye...
http://andere.strikingly.com/: Regards, Great stuff!
surou: 需要先执行提案合约申请,等待出块节点地址同意后,才会进...
heco: WARN [11-19|11:26:09.459] N...
P: 你好,我在heco链上遇到了“tx fee excee...
Peng: 楼主安装成功了吗?我正在同步区块链,一天了,差不多才同...
joyhu: 你好,请问下安装好之后如何获取到bee.yaml配置文...
kaka: 支票最终怎么提币呢?
归档
December 2024November 2024October 2024September 2024August 2024July 2024June 2024May 2024April 2024March 2024January 2024December 2023November 2023October 2023September 2023August 2023July 2023June 2023April 2023March 2023February 2023January 2023December 2022November 2022October 2022August 2022July 2022June 2022May 2022March 2022February 2022January 2022December 2021November 2021October 2021September 2021August 2021July 2021June 2021May 2021April 2021March 2021February 2021January 2021December 2020November 2020October 2020September 2020July 2020June 2020May 2020April 2020March 2020February 2020January 2020December 2019November 2019October 2019September 2019August 2019July 2019June 2019May 2019April 2019March 2019February 2019January 2019December 2018November 2018October 2018September 2018August 2018July 2018June 2018